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",
* Note: -C is only available in FreeBSD 2.2 and above
*/
#ifdef HAVE_PWDB_C
- if (pwdb("-C", NULL) == 0) { /* Check only */
+ if (pwdb("-C", (char *)NULL) == 0) { /* Check only */
#else
{ /* No -C */
#endif
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)
rc = pwdb(NULL);
#ifdef HAVE_PWDB_U
else
- rc = pwdb("-u", user, NULL);
+ rc = pwdb("-u", user, (char *)NULL);
#endif
}
}