passwd: do not complain about /etc/shadow needlessly

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-01-09 22:21:55 +01:00
parent 4653e442ba
commit 8ced1e5dc5

View File

@ -128,12 +128,20 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
/* getspnam_r may return 0 yet set result to NULL. /* getspnam_r may return 0 yet set result to NULL.
* At least glibc 2.4 does this. Be extra paranoid here. */ * At least glibc 2.4 does this. Be extra paranoid here. */
struct spwd *result = NULL; struct spwd *result = NULL;
if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result) errno = 0;
|| !result || strcmp(result->sp_namp, pw->pw_name) != 0) { if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result) != 0
/* LOGMODE_BOTH */ || !result /* no error, but no record found either */
bb_error_msg("no record of %s in %s, using %s", || strcmp(result->sp_namp, pw->pw_name) != 0 /* paranoia */
) {
if (errno != ENOENT) {
/* LOGMODE_BOTH */
bb_perror_msg("no record of %s in %s, using %s",
name, bb_path_shadow_file, name, bb_path_shadow_file,
bb_path_passwd_file); bb_path_passwd_file);
}
/* else: /etc/shadow does not exist,
* apparently we are on a shadow-less system,
* no surprise there */
} else { } else {
pw->pw_passwd = result->sp_pwdp; pw->pw_passwd = result->sp_pwdp;
} }