]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - chpass/chpass.c
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
[pw-darwin.git] / chpass / chpass.c
index 8b716ba25c0b4a16670296ceacc468a2413794d2..9f9be5335a682376d0d8063669fbae7f20d45670 100644 (file)
@@ -53,15 +53,9 @@ static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94";
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/signal.h>
-#include <sys/time.h>
-#include <sys/resource.h>
 
-#include <ctype.h>
 #include <err.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -223,7 +217,12 @@ main(int argc, char *argv[])
                pw_fini();
                if (pw == NULL)
                        err(1, "edit()");
-               if (pw_equal(old_pw, pw))
+               /* 
+                * pw_equal does not check for crypted passwords, so we
+                * should do it explicitly
+                */
+               if (pw_equal(old_pw, pw) && 
+                   strcmp(old_pw->pw_passwd, pw->pw_passwd) == 0)
                        errx(0, "user information unchanged");
        }
 
@@ -242,8 +241,11 @@ main(int argc, char *argv[])
 #ifdef YP
        case _PWF_NIS:
                ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host);
-               if (ypclnt == NULL ||
-                   ypclnt_connect(ypclnt) == -1 ||
+               if (ypclnt == NULL) {
+                       warnx("ypclnt_new failed");
+                       exit(1);
+               }
+               if (ypclnt_connect(ypclnt) == -1 ||
                    ypclnt_passwd(ypclnt, pw, password) == -1) {
                        warnx("%s", ypclnt->error);
                        ypclnt_free(ypclnt);
@@ -292,7 +294,7 @@ usage(void)
 {
 
        (void)fprintf(stderr,
-           "Usage: chpass%s %s [user]\n",
+           "usage: chpass%s %s [user]\n",
 #ifdef YP
            " [-d domain] [-h host]",
 #else