X-Git-Url: https://git.saurik.com/apple/system_cmds.git/blobdiff_plain/2fc1e207eccd68aee093ed29dae719e77bac17dd..916eb79ee6e2fd3e1ab08275e76ec4e126cab685:/chkpasswd.tproj/file_passwd.c?ds=sidebyside 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("");