passwd,cryptpw: make default encryption algorithm configurable
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 8 Jan 2012 15:44:37 +0000 (16:44 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 8 Jan 2012 15:44:37 +0000 (16:44 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
loginutils/Config.src
loginutils/chpasswd.c
loginutils/cryptpw.c
loginutils/passwd.c

index 14ce53434d3259a0fcb73252d75c6089e9e1bca1..9bf79afee21f31ab737382e84be6bb0a92f41fc2 100644 (file)
@@ -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
index b7df57e5d461313e52f510750167b31f6dbffec2..54ed73795a464bcc293bef310e611eb21df0a4ff 100644 (file)
@@ -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"
index b244f55e36dd0de287ed1d67b3859d7729282375..a36f920f40a735ae106fbf1f8e61ded9a9951ff2 100644 (file)
@@ -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+";
index 1cfafaec3745f1f28dcb61f531d7a028c7d751fe..b83db0083624bf47866c9f2c9b914781632646c0 100644 (file)
@@ -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;