]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - libutil/pw_util.c
Remove bogus reference to _use_yp.
[pw-darwin.git] / libutil / pw_util.c
index 5930342229b315dc11723f7c38a80abd6a5b9288..c5327ccfbf8b5945f85f0bd9c4bb4ad37924b182 100644 (file)
@@ -36,7 +36,7 @@
 static const char sccsid[] = "@(#)pw_util.c    8.3 (Berkeley) 4/2/94";
 #endif
 static const char rcsid[] =
-       "$Id: pw_util.c,v 1.14 1999/06/26 07:16:38 sheldonh Exp $";
+  "$FreeBSD$";
 #endif /* not lint */
 
 /*
@@ -66,12 +66,14 @@ static const char rcsid[] =
 extern char *tempname;
 static pid_t editpid = -1;
 static int lockfd;
-char *mppath = _PATH_PWD;
-char *masterpasswd = _PATH_MASTERPASSWD;
+static char _default_editor[] = _PATH_VI;
+char mppath[] = _PATH_PWD;
+char masterpasswd[] = _PATH_MASTERPASSWD;
+
+void            pw_cont(int);
 
 void
-pw_cont(sig)
-       int sig;
+pw_cont(int sig)
 {
 
        if (editpid != -1)
@@ -79,7 +81,7 @@ pw_cont(sig)
 }
 
 void
-pw_init()
+pw_init(void)
 {
        struct rlimit rlim;
 
@@ -103,10 +105,13 @@ pw_init()
        (void)signal(SIGQUIT, SIG_IGN);
        (void)signal(SIGTERM, SIG_IGN);
        (void)signal(SIGCONT, pw_cont);
+
+       /* Create with exact permissions. */
+       (void)umask(0);
 }
 
 int
-pw_lock()
+pw_lock(void)
 {
        /*
         * If the master password file doesn't exist, the system is hosed.
@@ -139,7 +144,7 @@ pw_lock()
 }
 
 int
-pw_tmp()
+pw_tmp(void)
 {
        static char path[MAXPATHLEN];
        int fd;
@@ -160,8 +165,7 @@ pw_tmp()
 }
 
 int
-pw_mkdb(username)
-char *username;
+pw_mkdb(const char *username)
 {
        int pstat;
        pid_t pid;
@@ -171,11 +175,11 @@ char *username;
                if(!username) {
                        warnx("rebuilding the database...");
                        execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
-                           tempname, NULL);
+                           tempname, (char *)NULL);
                } else {
                        warnx("updating the database...");
                        execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
-                           "-u", username, tempname, NULL);
+                           "-u", username, tempname, (char *)NULL);
                }
                pw_error(_PATH_PWD_MKDB, 1, 1);
        }
@@ -187,14 +191,13 @@ char *username;
 }
 
 void
-pw_edit(notsetuid)
-       int notsetuid;
+pw_edit(int notsetuid)
 {
        int pstat;
        char *p, *editor;
 
        if (!(editor = getenv("EDITOR")))
-               editor = _PATH_VI;
+               editor = _default_editor;
        if ((p = strrchr(editor, '/')))
                ++p;
        else
@@ -206,7 +209,7 @@ pw_edit(notsetuid)
                        (void)setuid(getuid());
                }
                errno = 0;
-               execlp(editor, p, tempname, NULL);
+               execlp(editor, p, tempname, (char *)NULL);
                _exit(errno);
        }
        for (;;) {
@@ -225,7 +228,7 @@ pw_edit(notsetuid)
 }
 
 void
-pw_prompt()
+pw_prompt(void)
 {
        int c, first;
 
@@ -239,21 +242,15 @@ pw_prompt()
 }
 
 void
-pw_error(name, err, eval)
-       char *name;
-       int err, eval;
+pw_error(const char *name, int error, int eval)
 {
-#ifdef YP
-       extern int _use_yp;
-#endif /* YP */
-       if (err)
-               warn(name);
-#ifdef YP
-       if (_use_yp)
-               warnx("NIS information unchanged");
-       else
-#endif /* YP */
-       warnx("%s: unchanged", masterpasswd);
+       if (error) {
+               if (name != NULL)
+                       warn("%s", name);
+               else
+                       warn(NULL);
+       }
+       warnx("password information unchanged");
        (void)unlink(tempname);
        exit(eval);
 }