adduser: fix a bug of getpwnam() overwriting shell name, closes 8586

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2019-01-12 11:51:58 +01:00
parent 3109d1f965
commit b67d900395

View 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, "^"