summaryrefslogtreecommitdiff
path: root/src/basic/util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-06 12:06:56 +0200
committerTom Gundersen <teg@jklm.no>2015-10-06 12:06:56 +0200
commite1719ef19d542c88e319e77aaf970dc36c2269f4 (patch)
tree674f2f4b65756cb993709a8c75b82c082fb68a36 /src/basic/util.c
parentf0990739fc24e60facb7ef0c3e97a046bd1d9d17 (diff)
parentdf9d6993b677c05c7f502acafc5c8efa642792fe (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.c25
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;
+}