rework the password subsystem
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 13 Feb 1991 14:38:05 +0000 (06:38 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 13 Feb 1991 14:38:05 +0000 (06:38 -0800)
SCCS-vsn: usr.bin/chpass/Makefile 5.4
SCCS-vsn: usr.bin/chpass/chpass.1 5.10
SCCS-vsn: usr.bin/chpass/chpass.c 5.16
SCCS-vsn: usr.bin/chpass/chpass.h 5.3
SCCS-vsn: usr.bin/chpass/field.c 5.13
SCCS-vsn: usr.bin/chpass/util.c 5.14

usr/src/usr.bin/chpass/Makefile
usr/src/usr.bin/chpass/chpass.1
usr/src/usr.bin/chpass/chpass.c
usr/src/usr.bin/chpass/chpass.h
usr/src/usr.bin/chpass/field.c
usr/src/usr.bin/chpass/util.c

index e976f88..7236a61 100644 (file)
@@ -1,9 +1,10 @@
-#      @(#)Makefile    5.3 (Berkeley) %G%
+#      @(#)Makefile    5.4 (Berkeley) %G%
 
 PROG=  chpass
 
 PROG=  chpass
-SRCS=  chpass.c field.c util.c
+SRCS=  chpass.c edit.c field.c pw_copy.c pw_scan.c pw_util.c table.c util.c
 BINOWN=        root
 BINMODE=4555
 BINOWN=        root
 BINMODE=4555
+.PATH: ${.CURDIR}/../../usr.sbin/pwd_mkdb ${.CURDIR}/../../sbin/vipw
 LINKS= ${BINDIR}/chpass ${BINDIR}/chfn ${BINDIR}/chpass ${BINDIR}/chsh
 MLINKS=        chpass.1 chfn.1 chpass.1 chsh.1
 
 LINKS= ${BINDIR}/chpass ${BINDIR}/chfn ${BINDIR}/chpass ${BINDIR}/chsh
 MLINKS=        chpass.1 chfn.1 chpass.1 chsh.1
 
index f5c45b4..47e3c85 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)chpass.1   5.9 (Berkeley) %G%
+.\"     @(#)chpass.1   5.10 (Berkeley) %G%
 .\"
 .Dd 
 .Dt CHPASS 1
 .\"
 .Dd 
 .Dt CHPASS 1
@@ -160,11 +160,8 @@ numbers.
 Once the information has been verified,
 .Nm chpass
 uses
 Once the information has been verified,
 .Nm chpass
 uses
-.Xr mkpasswd 8
-to update the user database.  This is run in the background, and,
-at very large sites could take several minutes.  Until this update
-is completed, the password file is unavailable for other updates
-and the new information will not be available to programs.
+.Xr pwd_mkdb 8
+to update the user database.
 .Sh ENVIRONMENT
 The
 .Xr vi 1
 .Sh ENVIRONMENT
 The
 .Xr vi 1
@@ -179,15 +176,20 @@ with the user.
 .Di L
 .Dp Pa /etc/master.passwd
 The user database
 .Di L
 .Dp Pa /etc/master.passwd
 The user database
+.Dp Pa /etc/passwd
+A Version 7 format password file
+.Dp Pa /etc/chpass.XXXXXX
+Temporary copy of the password file
 .Dp Pa /etc/shells
 The list of approved shells
 .Dp
 .Sh SEE ALSO
 .Xr login 1 ,
 .Xr finger 1 ,
 .Dp Pa /etc/shells
 The list of approved shells
 .Dp
 .Sh SEE ALSO
 .Xr login 1 ,
 .Xr finger 1 ,
+.Xr passwd 1 ,
 .Xr getusershell 3 ,
 .Xr passwd 5 ,
 .Xr getusershell 3 ,
 .Xr passwd 5 ,
-.Xr mkpasswd 8 ,
+.Xr pwd_mkdb 8 ,
 .Xr vipw 8
 .Pp
 Robert Morris and Ken Thompson,
 .Xr vipw 8
 .Pp
 Robert Morris and Ken Thompson,
index 2975f1d..210b6dd 100644 (file)
@@ -12,15 +12,15 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)chpass.c   5.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)chpass.c   5.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/signal.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
 #include <sys/signal.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include <errno.h>
 #include <stdio.h>
 #include <pwd.h>
 #include <errno.h>
 #include <stdio.h>
@@ -29,67 +29,32 @@ static char sccsid[] = "@(#)chpass.c        5.15 (Berkeley) %G%";
 #include "chpass.h"
 #include "pathnames.h"
 
 #include "chpass.h"
 #include "pathnames.h"
 
-char e1[] = ": ";
-char e2[] = ":,";
-
-int p_change(), p_class(), p_expire(), p_gecos(), p_gid(), p_hdir();
-int p_login(), p_passwd(), p_shell(), p_uid();
-
-struct entry list[] = {
-       { "Login",              p_login,  1,   5, e1,   },
-       { "Password",           p_passwd, 1,   8, e1,   },
-       { "Uid",                p_uid,    1,   3, e1,   },
-       { "Gid",                p_gid,    1,   3, e1,   },
-       { "Class",              p_class,  1,   5, e1,   },
-       { "Change",             p_change, 1,   6, NULL, },
-       { "Expire",             p_expire, 1,   6, NULL, },
-#define        E_NAME          7
-       { "Full Name",          p_gecos,  0,   9, e2,   },
-#define        E_BPHONE        8
-       { "Office Phone",       p_gecos,  0,  12, e2,   },
-#define        E_HPHONE        9
-       { "Home Phone",         p_gecos,  0,  10, e2,   },
-#define        E_LOCATE        10
-       { "Location",           p_gecos,  0,   8, e2,   },
-       { "Home directory",     p_hdir,   1,  14, e1,   },
-#define        E_SHELL         12
-       { "Shell",              p_shell,  0,   5, e1,   },
-       { NULL, 0, },
-};
-
+char *progname = "chpass";
+char *tempname;
 uid_t uid;
 
 main(argc, argv)
        int argc;
        char **argv;
 {
 uid_t uid;
 
 main(argc, argv)
        int argc;
        char **argv;
 {
-       extern int errno, optind;
+       extern int optind;
        extern char *optarg;
        extern char *optarg;
-       register char *p;
-       struct passwd lpw, *pw;
-       struct rlimit rlim;
-       FILE *temp_fp;
-       int aflag, ch, fd;
-       char *fend, *newsh, *passwd, *temp, *tend;
-       char from[MAXPATHLEN], to[MAXPATHLEN];
-       char *getusershell();
+       register enum { NEWSH, LOADENTRY, EDITENTRY } op;
+       register struct passwd *pw;
+       struct passwd lpw;
+       int ch, pfd, tfd;
+       char *arg;
 
 
-       uid = getuid();
-       aflag = 0;
-       newsh = NULL;
+       op = EDITENTRY;
        while ((ch = getopt(argc, argv, "a:s:")) != EOF)
                switch(ch) {
                case 'a':
        while ((ch = getopt(argc, argv, "a:s:")) != EOF)
                switch(ch) {
                case 'a':
-                       if (uid)
-                               baduser();
-                       loadpw(optarg, pw = &lpw);
-                       aflag = 1;
+                       op = LOADENTRY;
+                       arg = optarg;
                        break;
                case 's':
                        break;
                case 's':
-                       newsh = optarg;
-                       /* protect p_field -- it thinks NULL is /bin/sh */
-                       if (!*newsh)
-                               usage();
+                       op = NEWSH;
+                       arg = optarg;
                        break;
                case '?':
                default:
                        break;
                case '?':
                default:
@@ -98,7 +63,9 @@ main(argc, argv)
        argc -= optind;
        argv += optind;
 
        argc -= optind;
        argv += optind;
 
-       if (!aflag)
+       uid = getuid();
+
+       if (op == EDITENTRY || op == NEWSH)
                switch(argc) {
                case 0:
                        if (!(pw = getpwuid(uid))) {
                switch(argc) {
                case 0:
                        if (!(pw = getpwuid(uid))) {
@@ -120,361 +87,55 @@ main(argc, argv)
                        usage();
                }
 
                        usage();
                }
 
-       (void)signal(SIGHUP, SIG_IGN);
-       (void)signal(SIGINT, SIG_IGN);
-       (void)signal(SIGQUIT, SIG_IGN);
-       (void)signal(SIGTSTP, SIG_IGN);
-
-       rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
-       (void)setrlimit(RLIMIT_CPU, &rlim);
-       (void)setrlimit(RLIMIT_FSIZE, &rlim);
-
-       (void)umask(0);
-
-       temp = _PATH_PTMP;
-       if ((fd = open(temp, O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0) {
-               if (errno == EEXIST) {
-                       (void)fprintf(stderr,
-                           "chpass: password file busy -- try again later.\n");
-                       exit(1);
-               }
-               (void)fprintf(stderr, "chpass: %s: %s; ",
-                   temp, strerror(errno));
-               goto bad;
-       }
-       if (!(temp_fp = fdopen(fd, "w"))) {
-               (void)fprintf(stderr, "chpass: can't write %s; ", temp);
-               goto bad;
-       }
-
-       if (newsh) {
-               if (p_shell(newsh, pw, (struct entry *)NULL))
-                       goto bad;
+       if (op == NEWSH) {
+               /* protect p_shell -- it thinks NULL is /bin/sh */
+               if (!arg[0])
+                       usage();
+               if (p_shell(arg, pw, (ENTRY *)NULL))
+                       pw_error((char *)NULL, 0, 1);
        }
        }
-       else if (!aflag && !info(pw))
-               goto bad;
 
 
-       /* root should have a 0 uid and a reasonable shell */
-       if (!strcmp(pw->pw_name, "root")) {
-               if (pw->pw_uid) {
-                       (void)fprintf(stderr, "chpass: root uid should be 0.");
+       if (op == LOADENTRY) {
+               if (uid)
+                       baduser();
+               pw = &lpw;
+               if (!pw_scan(arg, pw))
                        exit(1);
                        exit(1);
-               }
-               setusershell();
-               for (;;)
-                       if (!(p = getusershell())) {
-                               (void)fprintf(stderr,
-                                   "chpass: warning, unknown root shell.");
-                               break;
-                       }
-                       else if (!strcmp(pw->pw_shell, p))
-                               break;
-       }
-
-       passwd = _PATH_MASTERPASSWD;
-       if (!freopen(passwd, "r", stdin)) {
-               (void)fprintf(stderr, "chpass: can't read %s; ", passwd);
-               goto bad;
-       }
-       if (!copy(pw, temp_fp))
-               goto bad;
-
-       (void)fclose(temp_fp);
-       (void)fclose(stdin);
-
-       switch(fork()) {
-       case 0:
-               break;
-       case -1:
-               (void)fprintf(stderr, "chpass: can't fork; ");
-               goto bad;
-               /* NOTREACHED */
-       default:
-               exit(0);
-               /* NOTREACHED */
-       }
-
-       if (makedb(temp)) {
-               (void)fprintf(stderr, "chpass: mkpasswd failed; ");
-bad:           (void)fprintf(stderr, "%s unchanged.\n", _PATH_MASTERPASSWD);
-               (void)unlink(temp);
-               exit(1);
-       }
-
-       /*
-        * possible race; have to rename four files, and someone could slip
-        * in between them.  LOCK_EX and rename the ``passwd.dir'' file first
-        * so that getpwent(3) can't slip in; the lock should never fail and
-        * it's unclear what to do if it does.  Rename ``ptmp'' last so that
-        * passwd/vipw/chpass can't slip in.
-        */
-       (void)setpriority(PRIO_PROCESS, 0, -20);
-       fend = strcpy(from, temp) + strlen(temp);
-       tend = strcpy(to, _PATH_PASSWD) + strlen(_PATH_PASSWD);
-       bcopy(".dir", fend, 5);
-       bcopy(".dir", tend, 5);
-       if ((fd = open(from, O_RDONLY, 0)) >= 0)
-               (void)flock(fd, LOCK_EX);
-       /* here we go... */
-       (void)rename(from, to);
-       bcopy(".pag", fend, 5);
-       bcopy(".pag", tend, 5);
-       (void)rename(from, to);
-       bcopy(".orig", fend, 6);
-       (void)rename(from, _PATH_PASSWD);
-       (void)rename(temp, passwd);
-       /* done! */
-       exit(0);
-}
-
-info(pw)
-       struct passwd *pw;
-{
-       struct stat begin, end;
-       FILE *fp;
-       int fd, rval;
-       char *tfile;
-
-       tfile = _PATH_TMP;
-       if ((fd = mkstemp(tfile)) == -1 || !(fp = fdopen(fd, "w+"))) {
-               (void)fprintf(stderr, "chpass: no temporary file");
-               return(0);
-       }
-
-       /*
-        * if print doesn't print out a shell field, make it restricted.
-        * Not particularly pretty, but print is the routine that checks
-        * to see if the user can change their shell.
-        */
-       if (!print(fp, pw))
-               list[E_SHELL].restricted = 1;
-       (void)fflush(fp);
-
-       /*
-        * give the file to the real user; setuid permissions
-        * are discarded in edit()
-        */
-       (void)fchown(fd, getuid(), getgid());
-
-       for (rval = 0;;) {
-               (void)fstat(fd, &begin);
-               if (edit(tfile)) {
-                       (void)fprintf(stderr, "chpass: edit failed; ");
-                       break;
-               }
-               (void)fstat(fd, &end);
-               if (begin.st_mtime == end.st_mtime) {
-                       (void)fprintf(stderr, "chpass: no changes made; ");
-                       break;
-               }
-               (void)rewind(fp);
-               if (check(fp, pw)) {
-                       rval = 1;
-                       break;
-               }
-               (void)fflush(stderr);
-               if (prompt())
-                       break;
        }
        }
-       (void)fclose(fp);
-       (void)unlink(tfile);
-       return(rval);
-}
-
-check(fp, pw)
-       FILE *fp;
-       struct passwd *pw;
-{
-       register struct entry *ep;
-       register char *p;
-       static char buf[1024];
 
 
-       while (fgets(buf, sizeof(buf), fp)) {
-               if (!buf[0] || buf[0] == '#')
-                       continue;
-               if (!(p = index(buf, '\n'))) {
-                       (void)fprintf(stderr, "chpass: line too long.\n");
-                       return(0);
-               }
-               *p = '\0';
-               for (ep = list;; ++ep) {
-                       if (!ep->prompt) {
-                               (void)fprintf(stderr,
-                                   "chpass: unrecognized field.\n");
-                               return(0);
-                       }
-                       if (!strncasecmp(buf, ep->prompt, ep->len)) {
-                               if (ep->restricted && uid) {
-                                       (void)fprintf(stderr,
-                                           "chpass: you may not change the %s field.\n",
-                                           ep->prompt);
-                                       return(0);
-                               }
-                               if (!(p = index(buf, ':'))) {
-                                       (void)fprintf(stderr,
-                                           "chpass: line corrupted.\n");
-                                       return(0);
-                               }
-                               while (isspace(*++p));
-                               if (ep->except && strpbrk(p, ep->except)) {
-                                       (void)fprintf(stderr,
-                                           "chpass: illegal character in the \"%s\" field.\n",
-                                           ep->prompt);
-                                       return(0);
-                               }
-                               if ((ep->func)(p, pw, ep))
-                                       return(0);
-                               break;
-                       }
-               }
-       }
        /*
        /*
-        * special checks...
-        *
-        * there has to be a limit on the size of the gecos fields,
-        * otherwise getpwent(3) can choke.
-        * ``if I swallow anything evil, put your fingers down my throat...''
-        *      -- The Who
+        * The file descriptor usage is a little tricky through here.
+        * 1:   We start off with two fd's, one for the master password
+        *      file, and one for the temporary file.
+        * 2:   Get an fp for the temporary file, copy the info to be
+        *      edited into it, and close the fp (closing the underlying
+        *      fd).
+        * 3:   The user edits the temporary file some number of times.
+        * 4:   Get an fp for the temporary file, and verify the contents.
+        *      We can't use the fp from step 2, because the user's editor
+        *      may have created a new instance of the file.  Close the
+        *      fp when done.
+        * 5:   Get an fp for the temporary file, truncating it as we do
+        *      so.  Get an fp for the master password file.  Copy the
+        *      master password file into the temporary file, replacing the
+        *      user record with a new one.  Close the temporary file fp
+        *      when done -- can't close the password fp, or we'd lose the
+        *      lock.
+        * 6:   Call pw_mkdb() and exit.  The exit closes the master password
+        *      fd from step 1, and the master password fp from step 5.
         */
         */
-       if (strlen(list[E_NAME].save) + strlen(list[E_BPHONE].save) +
-           strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save)
-           > 512) {
-               (void)fprintf(stderr, "chpass: gecos field too large.\n");
-               exit(1);
-       }
-       (void)sprintf(pw->pw_gecos = buf, "%s,%s,%s,%s",
-           list[E_NAME].save, list[E_LOCATE].save, list[E_BPHONE].save,
-           list[E_HPHONE].save);
-       return(1);
-}
-
-copy(pw, fp)
-       struct passwd *pw;
-       FILE *fp;
-{
-       register int done;
-       register char *p;
-       char buf[1024];
-
-       for (done = 0; fgets(buf, sizeof(buf), stdin);) {
-               /* skip lines that are too big */
-               if (!index(buf, '\n')) {
-                       (void)fprintf(stderr, "chpass: line too long; ");
-                       return(0);
-               }
-               if (done) {
-                       (void)fprintf(fp, "%s", buf);
-                       continue;
-               }
-               if (!(p = index(buf, ':'))) {
-                       (void)fprintf(stderr, "chpass: corrupted entry; ");
-                       return(0);
-               }
-               *p = '\0';
-               if (strcmp(buf, pw->pw_name)) {
-                       *p = ':';
-                       (void)fprintf(fp, "%s", buf);
-                       continue;
-               }
-               (void)fprintf(fp, "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s\n",
-                   pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
-                   pw->pw_class, pw->pw_change, pw->pw_expire, pw->pw_gecos,
-                   pw->pw_dir, pw->pw_shell);
-               done = 1;
-       }
-       if (!done)
-               (void)fprintf(fp, "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s\n",
-                   pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
-                   pw->pw_class, pw->pw_change, pw->pw_expire, pw->pw_gecos,
-                   pw->pw_dir, pw->pw_shell);
-       return(1);
-}
-
-makedb(file)
-       char *file;
-{
-       int status, pid, w;
-
-       if (!(pid = vfork())) {
-               execl(_PATH_MKPASSWD, "mkpasswd", "-p", file, NULL);
-               (void)fprintf(stderr, "chpass: can't find \"mkpasswd\".\n");
-               _exit(127);
-       }
-       while ((w = wait(&status)) != pid && w != -1);
-       return(w == -1 || status);
-}
+       pw_init();
+       pfd = pw_lock();
+       tfd = pw_tmp();
 
 
-edit(file)
-       char *file;
-{
-       int status, pid, w;
-       char *p, *editor, *getenv();
+       if (op == EDITENTRY) 
+               edit(tfd, pw);
 
 
-       if (editor = getenv("EDITOR")) {
-               if (p = rindex(editor, '/'))
-                       ++p;
-               else
-                       p = editor;
-       }
-       else
-               p = editor = "vi";
-       if (!(pid = vfork())) {
-               (void)setgid(getgid());
-               (void)setuid(getuid());
-               execlp(editor, p, file, NULL);
-               (void)fprintf(stderr, "chpass: can't find \"%s\".\n", editor);
-               _exit(127);
-       }
-       while ((w = wait(&status)) != pid && w != -1);
-       return(w == -1 || status);
-}
+       pw_copy(pfd, pw);
 
 
-loadpw(arg, pw)
-       char *arg;
-       register struct passwd *pw;
-{
-       register char *cp;
-       char *bp = arg;
-       long atol();
-       char *strsep();
-
-       pw->pw_name = strsep(&bp, ":");
-       pw->pw_passwd = strsep(&bp, ":");
-       if (!(cp = strsep(&bp, ":")))
-               goto bad;
-       pw->pw_uid = atoi(cp);
-       if (!(cp = strsep(&bp, ":")))
-               goto bad;
-       pw->pw_gid = atoi(cp);
-       pw->pw_class = strsep(&bp, ":");
-       if (!(cp = strsep(&bp, ":")))
-               goto bad;
-       pw->pw_change = atol(cp);
-       if (!(cp = strsep(&bp, ":")))
-               goto bad;
-       pw->pw_expire = atol(cp);
-       pw->pw_gecos = strsep(&bp, ":");
-       pw->pw_dir = strsep(&bp, ":");
-       pw->pw_shell = strsep(&bp, ":");
-       if (!pw->pw_shell || strsep(&bp, ":")) {
-bad:           (void)fprintf(stderr, "chpass: bad password list.\n");
-               exit(1);
-       }
-}
-
-prompt()
-{
-       register int c;
-
-       for (;;) {
-               (void)printf("re-edit the password file? [y]: ");
-               (void)fflush(stdout);
-               c = getchar();
-               if (c != EOF && c != (int)'\n')
-                       while (getchar() != (int)'\n');
-               return(c == (int)'n');
-       }
-       /* NOTREACHED */
+       if (!pw_mkdb())
+               pw_error((char *)NULL, 0, 1);
+       exit(0);
 }
 
 baduser()
 }
 
 baduser()
index 34cac02..0ae8b0f 100644 (file)
@@ -4,13 +4,21 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)chpass.h    5.2 (Berkeley) %G%
+ *     @(#)chpass.h    5.3 (Berkeley) %G%
  */
 
  */
 
-struct entry {
+typedef struct _entry {
        char *prompt;
        int (*func)(), restricted, len;
        char *except, *save;
        char *prompt;
        int (*func)(), restricted, len;
        char *except, *save;
-};
+} ENTRY;
 
 
+/* Field numbers. */
+#define        E_BPHONE        8
+#define        E_HPHONE        9
+#define        E_LOCATE        10
+#define        E_NAME          7
+#define        E_SHELL         12
+
+extern ENTRY list[];
 extern uid_t uid;
 extern uid_t uid;
index acccac6..919a72d 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)field.c    5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)field.c    5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -22,7 +22,7 @@ static char sccsid[] = "@(#)field.c   5.12 (Berkeley) %G%";
 p_login(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_login(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!*p) {
                (void)fprintf(stderr, "chpass: empty login field.\n");
 {
        if (!*p) {
                (void)fprintf(stderr, "chpass: empty login field.\n");
@@ -53,7 +53,7 @@ p_login(p, pw, ep)
 p_passwd(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_passwd(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!*p)
                pw->pw_passwd = "";     /* "NOLOGIN"; */
 {
        if (!*p)
                pw->pw_passwd = "";     /* "NOLOGIN"; */
@@ -69,7 +69,7 @@ p_passwd(p, pw, ep)
 p_uid(p, pw, ep)
        register char *p;
        struct passwd *pw;
 p_uid(p, pw, ep)
        register char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        int id;
 
 {
        int id;
 
@@ -95,7 +95,7 @@ p_uid(p, pw, ep)
 p_gid(p, pw, ep)
        register char *p;
        struct passwd *pw;
 p_gid(p, pw, ep)
        register char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        struct group *gr;
        int id;
 {
        struct group *gr;
        int id;
@@ -127,7 +127,7 @@ p_gid(p, pw, ep)
 p_class(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_class(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!*p)
                pw->pw_class = "";
 {
        if (!*p)
                pw->pw_class = "";
@@ -143,7 +143,7 @@ p_class(p, pw, ep)
 p_change(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_change(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!atot(p, &pw->pw_change))
                return(0);
 {
        if (!atot(p, &pw->pw_change))
                return(0);
@@ -155,7 +155,7 @@ p_change(p, pw, ep)
 p_expire(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_expire(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!atot(p, &pw->pw_expire))
                return(0);
 {
        if (!atot(p, &pw->pw_expire))
                return(0);
@@ -167,7 +167,7 @@ p_expire(p, pw, ep)
 p_gecos(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_gecos(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!*p)
                ep->save = "";
 {
        if (!*p)
                ep->save = "";
@@ -182,7 +182,7 @@ p_gecos(p, pw, ep)
 p_hdir(p, pw, ep)
        char *p;
        struct passwd *pw;
 p_hdir(p, pw, ep)
        char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        if (!*p) {
                (void)fprintf(stderr, "chpass: empty home directory field.\n");
 {
        if (!*p) {
                (void)fprintf(stderr, "chpass: empty home directory field.\n");
@@ -199,7 +199,7 @@ p_hdir(p, pw, ep)
 p_shell(p, pw, ep)
        register char *p;
        struct passwd *pw;
 p_shell(p, pw, ep)
        register char *p;
        struct passwd *pw;
-       struct entry *ep;
+       ENTRY *ep;
 {
        char *t, *ok_shell();
 
 {
        char *t, *ok_shell();
 
index 5ccd18f..4e2c53a 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     5.14 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -95,55 +95,6 @@ bad:         return(1);
        return(0);
 }
 
        return(0);
 }
 
-/*
- * print --
- *     print out the file for the user to edit; strange side-effect:
- *     return if the user is allowed to modify their shell.
- */
-print(fp, pw)
-       FILE *fp;
-       struct passwd *pw;
-{
-       register char *p;
-       int shellval;
-       char *bp;
-       char *getusershell(), *ok_shell(), *ttoa();
-
-       shellval = 1;
-       (void)fprintf(fp, "#Changing user database information for %s.\n",
-           pw->pw_name);
-       if (!uid) {
-               (void)fprintf(fp, "Login: %s\n", pw->pw_name);
-               (void)fprintf(fp, "Password: %s\n", pw->pw_passwd);
-               (void)fprintf(fp, "Uid [#]: %d\n", pw->pw_uid);
-               (void)fprintf(fp, "Gid [# or name]: %d\n", pw->pw_gid);
-               (void)fprintf(fp, "Change [month day year]: %s\n",
-                   ttoa(pw->pw_change));
-               (void)fprintf(fp, "Expire [month day year]: %s\n",
-                   ttoa(pw->pw_expire));
-               (void)fprintf(fp, "Class: %s\n", pw->pw_class);
-               (void)fprintf(fp, "Home directory: %s\n", pw->pw_dir);
-               (void)fprintf(fp, "Shell: %s\n",
-                   *pw->pw_shell ? pw->pw_shell : _PATH_BSHELL);
-       }
-       /* only admin can change "restricted" shells */
-       else if (ok_shell(pw->pw_shell))
-               (void)fprintf(fp, "Shell: %s\n",
-                   *pw->pw_shell ? pw->pw_shell : _PATH_BSHELL);
-       else
-               shellval = 0;
-       bp = pw->pw_gecos;
-       p = strsep(&bp, ",");
-       (void)fprintf(fp, "Full Name: %s\n", p ? p : "");
-       p = strsep(&bp, ",");
-       (void)fprintf(fp, "Location: %s\n", p ? p : "");
-       p = strsep(&bp, ",");
-       (void)fprintf(fp, "Office Phone: %s\n", p ? p : "");
-       p = strsep(&bp, ",");
-       (void)fprintf(fp, "Home Phone: %s\n", p ? p : "");
-       return(shellval);
-}
-
 char *
 ok_shell(name)
        register char *name;
 char *
 ok_shell(name)
        register char *name;