diff options
-rw-r--r-- | loginutils/passwd.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index c1481c65e..b447af2f5 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -128,12 +128,20 @@ int passwd_main(int argc UNUSED_PARAM, char **argv) | |||
128 | /* getspnam_r may return 0 yet set result to NULL. | 128 | /* getspnam_r may return 0 yet set result to NULL. |
129 | * At least glibc 2.4 does this. Be extra paranoid here. */ | 129 | * At least glibc 2.4 does this. Be extra paranoid here. */ |
130 | struct spwd *result = NULL; | 130 | struct spwd *result = NULL; |
131 | if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result) | 131 | errno = 0; |
132 | || !result || strcmp(result->sp_namp, pw->pw_name) != 0) { | 132 | if (getspnam_r(pw->pw_name, &spw, buffer, sizeof(buffer), &result) != 0 |
133 | /* LOGMODE_BOTH */ | 133 | || !result /* no error, but no record found either */ |
134 | bb_error_msg("no record of %s in %s, using %s", | 134 | || strcmp(result->sp_namp, pw->pw_name) != 0 /* paranoia */ |
135 | ) { | ||
136 | if (errno != ENOENT) { | ||
137 | /* LOGMODE_BOTH */ | ||
138 | bb_perror_msg("no record of %s in %s, using %s", | ||
135 | name, bb_path_shadow_file, | 139 | name, bb_path_shadow_file, |
136 | bb_path_passwd_file); | 140 | bb_path_passwd_file); |
141 | } | ||
142 | /* else: /etc/shadow does not exist, | ||
143 | * apparently we are on a shadow-less system, | ||
144 | * no surprise there */ | ||
137 | } else { | 145 | } else { |
138 | pw->pw_passwd = result->sp_pwdp; | 146 | pw->pw_passwd = result->sp_pwdp; |
139 | } | 147 | } |