From 144ae70ef3f1fe2738d4f3ad15a62ae37fb71985 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 14 Dec 2014 21:38:56 +0000 Subject: chfn, chsh: share illegal_passwd_chars() function Signed-off-by: Sami Kerola --- login-utils/chsh.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'login-utils/chsh.c') diff --git a/login-utils/chsh.c b/login-utils/chsh.c index 1327614d0..2245f4161 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -42,6 +42,8 @@ #include "setpwnam.h" #include "xalloc.h" +#include "ch-common.h" + #ifdef HAVE_LIBSELINUX # include # include @@ -205,8 +207,6 @@ static char *prompt(char *question, char *def_val) */ static int check_shell(char *shell) { - unsigned int i, c; - if (!shell) return -1; @@ -222,17 +222,9 @@ static int check_shell(char *shell) printf(_("\"%s\" is not executable"), shell); return -1; } - /* keep /etc/passwd clean. */ - for (i = 0; i < strlen(shell); i++) { - c = shell[i]; - if (c == ',' || c == ':' || c == '=' || c == '"' || c == '\n') { - warnx(_("'%c' is not allowed"), c); - return -1; - } - if (iscntrl(c)) { - warnx(_("control characters are not allowed")); - return -1; - } + if (illegal_passwd_chars(shell)) { + warnx(_("%s: has illegal characters"), shell); + return -1; } #ifdef ONLY_LISTED_SHELLS if (!get_shell_list(shell)) { -- cgit v1.2.3-55-g7522