[git commit] passwd, chpasswd: reset password in /etc/passwd to "x" if /etc/shadow was updated

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 4 22:18:33 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=9eb7bfd4d4ede3b6aa6a42595fd8824316ab4e2f
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Tito Ragusa <farmatito at tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 loginutils/chpasswd.c |    5 ++++-
 loginutils/passwd.c   |    9 ++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index c2d8666..6c4296f 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -67,7 +67,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
 		 * we try to find & change his passwd in /etc/passwd */
 #if ENABLE_FEATURE_SHADOWPASSWDS
 		rc = update_passwd(bb_path_shadow_file, name, pass, NULL);
-		if (rc == 0) /* no lines updated, no errors detected */
+		if (rc > 0) /* password in /etc/shadow was updated */
+			pass = (char*)"x";
+		if (rc >= 0)
+			/* 0 = /etc/shadow missing (not an error), >0 = passwd changed in /etc/shadow */
 #endif
 			rc = update_passwd(bb_path_passwd_file, name, pass, NULL);
 		/* LOGMODE_BOTH logs to syslog also */
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 8b6a63e..810644e 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -184,8 +184,7 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
 		 * strdup'ing to avoid nasty surprizes */
 		newp = xstrdup(&pw->pw_passwd[1]);
 	} else if (opt & OPT_delete) {
-		//newp = xstrdup("");
-		newp = (char*)"";
+		newp = (char*)""; //xstrdup("");
 	}
 
 	rlimit_fsize.rlim_cur = rlimit_fsize.rlim_max = 512L * 30000;
@@ -201,7 +200,11 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_SHADOWPASSWDS
 	filename = bb_path_shadow_file;
 	rc = update_passwd(bb_path_shadow_file, name, newp, NULL);
-	if (rc == 0) /* no lines updated, no errors detected */
+	if (rc > 0)
+		/* password in /etc/shadow was updated */
+		newp = (char*) "x"; //xstrdup("x");
+	if (rc >= 0)
+		/* 0 = /etc/shadow missing (not an error), >0 = passwd changed in /etc/shadow */
 #endif
 	{
 		filename = bb_path_passwd_file;
-- 
1.7.3.4



More information about the busybox-cvs mailing list