X-Git-Url: https://git.saurik.com/apple/system_cmds.git/blobdiff_plain/20e66415abeb3fec26bdbd0c220fb926593ab135..ef8ad44b9b5d9c6d8c0fa5b5494f449fb6717387:/chkpasswd.tproj/file_passwd.c diff --git a/chkpasswd.tproj/file_passwd.c b/chkpasswd.tproj/file_passwd.c index 51fc8c1..56e7a00 100644 --- a/chkpasswd.tproj/file_passwd.c +++ b/chkpasswd.tproj/file_passwd.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "stringops.h" #define TEMP_FILE "/tmp/.pwtmp" @@ -37,8 +38,6 @@ extern void checkpasswd(char *, char *); -static int do_compat = 1; - char * getline(FILE *fp) { @@ -197,7 +196,7 @@ rewrite_file(char *pwname, FILE *fp, struct passwd *newpw) continue; } - fprintf(tfp, "%s:%s:%d:%d:%s:%d:%d:%s:%s:%s\n", + fprintf(tfp, "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s\n", newpw->pw_name, newpw->pw_passwd, newpw->pw_uid, newpw->pw_gid, newpw->pw_class, newpw->pw_change, newpw->pw_expire, newpw->pw_gecos, newpw->pw_dir, newpw->pw_shell); @@ -253,8 +252,7 @@ file_check_passwd(char *uname, char *locn) fname = _PASSWD_FILE; if (locn != NULL) fname = locn; - fp = fopen(fname, "r"); - if (fp == NULL) + if (access(fname,R_OK) || (fp = fopen(fname, "r")) == NULL) { fprintf(stderr, "can't read file \"%s\": ", fname); perror("");