summaryrefslogtreecommitdiff
path: root/src/sysusers
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-14 12:23:39 +0200
committerLennart Poettering <lennart@poettering.net>2016-07-22 15:53:45 +0200
commite4631b48e17e63a3859456df639482063a0276fd (patch)
treee8dcdec9dbfda12093f4266ce495a27b65cfa580 /src/sysusers
parentbf3dd08a81f7500973d8a4add8c73a0856ae5f7d (diff)
downloadsystemd-e4631b48e17e63a3859456df639482063a0276fd.tar.gz
sysusers: move various user credential validity checks to src/basic/
This way we can reuse them for validating User=/Group= settings in unit files (to be added in a later commit). Also, add some tests for them.
Diffstat (limited to 'src/sysusers')
-rw-r--r--src/sysusers/sysusers.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 787d68a009..5d72493725 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -1299,81 +1299,6 @@ static bool item_equal(Item *a, Item *b) {
return true;
}
-static bool valid_user_group_name(const char *u) {
- const char *i;
- long sz;
-
- if (isempty(u))
- return false;
-
- if (!(u[0] >= 'a' && u[0] <= 'z') &&
- !(u[0] >= 'A' && u[0] <= 'Z') &&
- u[0] != '_')
- return false;
-
- for (i = u+1; *i; i++) {
- if (!(*i >= 'a' && *i <= 'z') &&
- !(*i >= 'A' && *i <= 'Z') &&
- !(*i >= '0' && *i <= '9') &&
- *i != '_' &&
- *i != '-')
- return false;
- }
-
- sz = sysconf(_SC_LOGIN_NAME_MAX);
- assert_se(sz > 0);
-
- if ((size_t) (i-u) > (size_t) sz)
- return false;
-
- if ((size_t) (i-u) > UT_NAMESIZE - 1)
- return false;
-
- return true;
-}
-
-static bool valid_gecos(const char *d) {
-
- if (!d)
- return false;
-
- if (!utf8_is_valid(d))
- return false;
-
- if (string_has_cc(d, NULL))
- return false;
-
- /* Colons are used as field separators, and hence not OK */
- if (strchr(d, ':'))
- return false;
-
- return true;
-}
-
-static bool valid_home(const char *p) {
-
- if (isempty(p))
- return false;
-
- if (!utf8_is_valid(p))
- return false;
-
- if (string_has_cc(p, NULL))
- return false;
-
- if (!path_is_absolute(p))
- return false;
-
- if (!path_is_safe(p))
- return false;
-
- /* Colons are used as field separators, and hence not OK */
- if (strchr(p, ':'))
- return false;
-
- return true;
-}
-
static int parse_line(const char *fname, unsigned line, const char *buffer) {
static const Specifier specifier_table[] = {