]>
Commit | Line | Data |
---|---|---|
144ae70e SK |
1 | /* |
2 | * chfn and chsh shared functions | |
3 | * | |
4 | * this program is free software. you can redistribute it and | |
5 | * modify it under the terms of the gnu general public license. | |
6 | * there is no warranty. | |
7 | */ | |
8 | ||
9 | #include <ctype.h> | |
10 | #include <string.h> | |
11 | ||
12 | #include "c.h" | |
13 | #include "nls.h" | |
14 | ||
15 | #include "ch-common.h" | |
16 | ||
17 | /* | |
18 | * illegal_passwd_chars () - | |
19 | * check whether a string contains illegal characters | |
20 | */ | |
21 | int illegal_passwd_chars(const char *str) | |
22 | { | |
23 | const char illegal[] = ",:=\"\n"; | |
24 | const size_t len = strlen(str); | |
25 | size_t i; | |
26 | ||
27 | if (strpbrk(str, illegal)) | |
28 | return 1; | |
29 | for (i = 0; i < len; i++) { | |
30 | if (iscntrl(str[i])) | |
31 | return 1; | |
32 | } | |
33 | return 0; | |
34 | } |