adduser: fix a bug of getpwnam() overwriting shell name, closes 8586
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 12 Jan 2019 10:51:58 +0000 (11:51 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 12 Jan 2019 10:51:58 +0000 (11:51 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
loginutils/adduser.c

index b2b5be5b3c30b95e2a229e43121ab8f3875fe096..850c810c493ad871f536ebe4d2a4279fb0d85c6a 100644 (file)
@@ -198,7 +198,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
 
        pw.pw_gecos = (char *)"Linux User,,,";
        /* We assume that newly created users "inherit" root's shell setting */
-       pw.pw_shell = (char *)get_shell_name();
+       pw.pw_shell = xstrdup(get_shell_name()); /* might come from getpwnam(), need to make a copy */
        pw.pw_dir = NULL;
 
        opts = getopt32long(argv, "^"