diff options
author | Sami Kerola | 2014-12-14 22:38:56 +0100 |
---|---|---|
committer | Sami Kerola | 2015-01-05 23:52:50 +0100 |
commit | 144ae70ef3f1fe2738d4f3ad15a62ae37fb71985 (patch) | |
tree | ebe9dad3ccf186749072b928caada5af6a20e9a6 /login-utils/ch-common.c | |
parent | chsh: remove function prototypes (diff) | |
download | kernel-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/ch-common.c')
-rw-r--r-- | login-utils/ch-common.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/login-utils/ch-common.c b/login-utils/ch-common.c new file mode 100644 index 000000000..34b09f32d --- /dev/null +++ b/login-utils/ch-common.c @@ -0,0 +1,34 @@ +/* + * chfn and chsh shared functions + * + * this program is free software. you can redistribute it and + * modify it under the terms of the gnu general public license. + * there is no warranty. + */ + +#include <ctype.h> +#include <string.h> + +#include "c.h" +#include "nls.h" + +#include "ch-common.h" + +/* + * illegal_passwd_chars () - + * check whether a string contains illegal characters + */ +int illegal_passwd_chars(const char *str) +{ + const char illegal[] = ",:=\"\n"; + const size_t len = strlen(str); + size_t i; + + if (strpbrk(str, illegal)) + return 1; + for (i = 0; i < len; i++) { + if (iscntrl(str[i])) + return 1; + } + return 0; +} |