int l;
char *pw;
- pw = (pwd->pw_passwd == NULL || !*pwd->pw_passwd) ? "" : (type == PWF_MASTER) ? pwd->pw_passwd : "*";
+ pw = (type == PWF_MASTER) ?
+ ((pwd->pw_passwd == NULL) ? "" : pwd->pw_passwd) : "*";
if (type == PWF_PASSWD)
l = sprintf(buf, "%s:*:%ld:%ld:%s:%s:%s\n",
char pwbuf[PWBUFSZ];
int l = snprintf(pfx, PWBUFSZ, "%s:", user);
#ifdef HAVE_PWDB_U
- int isrename = strcmp(user, pwd->pw_name);
+ int isrename = pwd!=NULL && strcmp(user, pwd->pw_name);
#endif
/*
else
fmtpwentry(pwbuf, pwd, PWF_PASSWD);
+ if (l < 0)
+ l = 0;
rc = fileupdate(getpwpath(_PASSWD), 0644, pwbuf, pfx, l, mode);
if (rc == 0) {
*/
if (pwd != NULL)
fmtpwentry(pwbuf, pwd, PWF_MASTER);
- rc = fileupdate(getpwpath(_MASTERPASSWD), 0644, pwbuf, pfx, l, mode);
+ rc = fileupdate(getpwpath(_MASTERPASSWD), 0600, pwbuf, pfx, l, mode);
if (rc == 0) {
#ifdef HAVE_PWDB_U
if (mode == UPD_DELETE || isrename)