diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c index 0f2df7a77bef..22662dbd0b34 100644 --- a/usr.sbin/pw/pwupd.c +++ b/usr.sbin/pw/pwupd.c @@ -146,7 +146,11 @@ pw_update(struct passwd * pwd, char const * user) pw_fini(); err(1, "pw_copy()"); } - if (pw_mkdb(user) == -1) { + /* + * in case of deletion of a user, the whole database + * needs to be regenerated + */ + if (pw_mkdb(pw != NULL ? user : NULL) == -1) { pw_fini(); err(1, "pw_mkdb()"); }