summaryrefslogtreecommitdiffstats
path: root/login-utils/chsh.c
diff options
context:
space:
mode:
authorSami Kerola2014-12-14 22:38:56 +0100
committerSami Kerola2015-01-05 23:52:50 +0100
commit144ae70ef3f1fe2738d4f3ad15a62ae37fb71985 (patch)
treeebe9dad3ccf186749072b928caada5af6a20e9a6 /login-utils/chsh.c
parentchsh: remove function prototypes (diff)
downloadkernel-qcow2-util-linux-144ae70ef3f1fe2738d4f3ad15a62ae37fb71985.tar.gz
kernel-qcow2-util-linux-144ae70ef3f1fe2738d4f3ad15a62ae37fb71985.tar.xz
kernel-qcow2-util-linux-144ae70ef3f1fe2738d4f3ad15a62ae37fb71985.zip
chfn, chsh: share illegal_passwd_chars() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/chsh.c')
-rw-r--r--login-utils/chsh.c18
1 files changed, 5 insertions, 13 deletions
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 <selinux/selinux.h>
# include <selinux/av_permissions.h>
@@ -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)) {