summaryrefslogtreecommitdiffstats
path: root/chpass
diff options
context:
space:
mode:
authorPeter Hawkins <thepish@FreeBSD.org>1998-08-14 03:18:32 +0000
committerPeter Hawkins <thepish@FreeBSD.org>1998-08-14 03:18:32 +0000
commite182f7f220d9f391c6d67964e4c0ec4a158d6be3 (patch)
treebe99d0d63e11630e7820ece494f381d151d44120 /chpass
parent79722705d4a9a042b75ce7f3045746de143af1ba (diff)
downloadpw-darwin-e182f7f220d9f391c6d67964e4c0ec4a158d6be3.tar.gz
pw-darwin-e182f7f220d9f391c6d67964e4c0ec4a158d6be3.tar.zst
pw-darwin-e182f7f220d9f391c6d67964e4c0ec4a158d6be3.zip
Submitted by: Peter Hawkins <thepish@FreeBSD.org>
Add functionality for support for more than 4 subfields within gcos. chsh, chpass etc did not parse beyond the 4th field previously and so truncated gcos on updating the database.
Diffstat (limited to 'chpass')
-rw-r--r--chpass/chpass.h1
-rw-r--r--chpass/edit.c15
-rw-r--r--chpass/table.c1
3 files changed, 13 insertions, 4 deletions
diff --git a/chpass/chpass.h b/chpass/chpass.h
index e7891ce..0446468 100644
--- a/chpass/chpass.h
+++ b/chpass/chpass.h
@@ -46,6 +46,7 @@ typedef struct _entry {
#define E_HPHONE 9
#define E_LOCATE 10
#define E_NAME 7
+#define E_OTHER 11
#define E_SHELL 12
extern ENTRY list[];
diff --git a/chpass/edit.c b/chpass/edit.c
index ad99822..68dbc0e 100644
--- a/chpass/edit.c
+++ b/chpass/edit.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: edit.c,v 1.10 1997/06/25 06:59:55 charnier Exp $
*/
#ifndef lint
@@ -163,6 +163,11 @@ display(fd, pw)
if (!list[E_HPHONE].restricted || !uid)
(void)fprintf(fp, "Home Phone: %s\n", p ? p : "");
+ if (bp!=NULL)
+ list[E_OTHER].save = strdup(bp);
+ if (!list[E_OTHER].restricted || !uid)
+ (void)fprintf(fp, "Other information: %s\n", bp ? bp : "");
+
(void)fchown(fd, getuid(), getgid());
(void)fclose(fp);
}
@@ -231,11 +236,13 @@ bad: (void)fclose(fp);
/* Build the gecos field. */
len = strlen(list[E_NAME].save) + strlen(list[E_BPHONE].save) +
- strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) + 4;
+ strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) +
+ strlen(list[E_OTHER].save) + 4;
if (!(p = malloc(len)))
err(1, NULL);
- (void)sprintf(pw->pw_gecos = p, "%s,%s,%s,%s", list[E_NAME].save,
- list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save);
+ (void)sprintf(pw->pw_gecos = p, "%s,%s,%s,%s,%s", list[E_NAME].save,
+ list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save,
+ list[E_OTHER].save);
while ((len = strlen(pw->pw_gecos)) && pw->pw_gecos[len - 1] == ',')
pw->pw_gecos[len - 1] = '\0';
diff --git a/chpass/table.c b/chpass/table.c
index 3363e1d..eed097e 100644
--- a/chpass/table.c
+++ b/chpass/table.c
@@ -58,6 +58,7 @@ ENTRY list[] = {
{ "office phone", p_gecos, 0, 12, e2, },
{ "home phone", p_gecos, 0, 10, e2, },
{ "location", p_gecos, 0, 8, e2, },
+ { "other information", p_gecos, 0, 11, e1, },
{ "home directory", p_hdir, 1, 14, e1, },
{ "shell", p_shell, 0, 5, e1, },
{ NULL, 0, },