[git commit] passwd, cryptpw: make default encryption algorithm configurable

Denys Vlasenko vda.linux at googlemail.com
Sun Jan 8 15:44:37 UTC 2012


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

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 loginutils/Config.src |    7 +++++++
 loginutils/chpasswd.c |    2 ++
 loginutils/cryptpw.c  |    2 +-
 loginutils/passwd.c   |    2 +-
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/loginutils/Config.src b/loginutils/Config.src
index 14ce534..9bf79af 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -283,6 +283,13 @@ config CHPASSWD
 	  Reads a file of user name and password pairs from standard input
 	  and uses this information to update a group of existing users.
 
+config FEATURE_DEFAULT_PASSWD_ALGO
+	string "Default password encryption method (passwd -a, cryptpw -m parameter)"
+	default "des"
+	depends on PASSWD || CRYPTPW
+	help
+	  Possible choices are "d[es]", "m[d5]", "s[ha256]" or "sha512".
+
 config SU
 	bool "su"
 	default y
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index b7df57e..54ed737 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -20,6 +20,8 @@
 //usage:     "\n	-m	Use MD5 encryption instead of DES"
 //usage:	)
 
+//TODO: implement -c ALGO
+
 #if ENABLE_LONG_OPTS
 static const char chpasswd_longopts[] ALIGN1 =
 	"encrypted\0" No_argument "e"
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index b244f55..a36f920 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -105,7 +105,7 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv)
 	applet_long_options = mkpasswd_longopts;
 #endif
 	fd = STDIN_FILENO;
-	opt_m = "d";
+	opt_m = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
 	opt_S = NULL;
 	/* at most two non-option arguments; -P NUM */
 	opt_complementary = "?2:P+";
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 1cfafae..b83db00 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -94,7 +94,7 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
 	};
 	unsigned opt;
 	int rc;
-	const char *opt_a = "d"; /* des */
+	const char *opt_a = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
 	const char *filename;
 	char *myname;
 	char *name;


More information about the busybox-cvs mailing list