summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorRob Landley2006-07-11 16:19:17 +0000
committerRob Landley2006-07-11 16:19:17 +0000
commitab7d9be17cd75772c015b8eab885e176f271691e (patch)
tree6afc009d439dc7174f008ccd531f2452e26a833c /loginutils
parent2819f757ca093249f37a518371ad8d2b608191bb (diff)
downloadbusybox-ab7d9be17cd75772c015b8eab885e176f271691e.zip
busybox-ab7d9be17cd75772c015b8eab885e176f271691e.tar.gz
Patch from Tito to remove pwd_to_spwd (which we don't actually need), with
some #ifdef removal from me.
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/passwd.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index a1ad02b..607e8fd 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);
}