From ab7d9be17cd75772c015b8eab885e176f271691e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 11 Jul 2006 16:19:17 +0000 Subject: Patch from Tito to remove pwd_to_spwd (which we don't actually need), with some #ifdef removal from me. --- loginutils/passwd.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'loginutils') diff --git a/loginutils/passwd.c b/loginutils/passwd.c index a1ad02bf0..607e8fd65 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c @@ -146,9 +146,6 @@ int passwd_main(int argc, char **argv) int dflg = 0; /* -d - delete password */ const struct passwd *pw; -#if ENABLE_FEATURE_SHADOWPASSWDS - const struct spwd *sp; -#endif amroot = (getuid() == 0); openlog("passwd", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); while ((flag = getopt(argc, argv, "a:dlu")) != EOF) { @@ -187,18 +184,13 @@ int passwd_main(int argc, char **argv) syslog(LOG_WARNING, "can't change pwd for `%s'", name); bb_error_msg_and_die("Permission denied.\n"); } -#if ENABLE_FEATURE_SHADOWPASSWDS - sp = getspnam(name); - if (!sp) { - sp = (struct spwd *) pwd_to_spwd(pw); - } - cp = sp->sp_pwdp; - np = sp->sp_namp; -#else - cp = pw->pw_passwd; - np = name; -#endif + if (ENABLE_FEATURE_SHADOWPASSWDS) { + struct spwd *sp = getspnam(name); + if (!sp) bb_error_msg_and_die("Unknown user %s", name); + cp = sp->sp_pwdp; + } else cp = pw->pw_passwd; + np = name; safe_strncpy(crypt_passwd, cp, sizeof(crypt_passwd)); if (!(dflg || lflg || uflg)) { if (!amroot) { @@ -243,6 +235,7 @@ int passwd_main(int argc, char **argv) syslog(LOG_WARNING, "an error occurred updating the password file"); bb_error_msg_and_die("An error occurred updating the password file.\n"); } + if (ENABLE_FEATURE_CLEAN_UP) free(myname); return (0); } -- cgit v1.2.3