diff options
author | Tom Gundersen <teg@jklm.no> | 2015-10-06 12:06:56 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-10-06 12:06:56 +0200 |
commit | e1719ef19d542c88e319e77aaf970dc36c2269f4 (patch) | |
tree | 674f2f4b65756cb993709a8c75b82c082fb68a36 /src/basic/util.c | |
parent | f0990739fc24e60facb7ef0c3e97a046bd1d9d17 (diff) | |
parent | df9d6993b677c05c7f502acafc5c8efa642792fe (diff) |
Merge pull request #1468 from poettering/fdnames
Add support for naming fds for socket activation and more
Diffstat (limited to 'src/basic/util.c')
-rw-r--r-- | src/basic/util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index 9f520462cf..630c7ea9ff 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -6845,3 +6845,28 @@ int version(void) { SYSTEMD_FEATURES); return 0; } + +bool fdname_is_valid(const char *s) { + const char *p; + + /* Validates a name for $LISTEN_NAMES. We basically allow + * everything ASCII that's not a control character. Also, as + * special exception the ":" character is not allowed, as we + * use that as field separator in $LISTEN_NAMES. + * + * Note that the empty string is explicitly allowed here.*/ + + if (!s) + return false; + + for (p = s; *p; p++) { + if (*p < ' ') + return false; + if (*p >= 127) + return false; + if (*p == ':') + return false; + } + + return p - s < 256; +} |