]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: move fdname_is_valid() to fd-util.[ch]
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 13:57:44 +0000 (14:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 13:57:44 +0000 (14:57 +0100)
src/basic/fd-util.c
src/basic/fd-util.h
src/basic/util.c
src/basic/util.h

index 830522cdb5a30bdd1435749172bad1efc2a43b85..d1b1db3a4ddc83b8c73ecf7c3ff51a19885d2fef 100644 (file)
@@ -322,3 +322,30 @@ void cmsg_close_all(struct msghdr *mh) {
                 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
                         close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
 }
+
+bool fdname_is_valid(const char *s) {
+        const char *p;
+
+        /* Validates a name for $LISTEN_FDNAMES. 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_FDNAMES.
+         *
+         * Note that the empty string is explicitly allowed
+         * here. However, we limit the length of the names to 255
+         * characters. */
+
+        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;
+}
index be00d881c363c0948629a0dca178eb021213157b..1ca10f03830bc9f10e0c6934c02526348b3a547f 100644 (file)
@@ -67,3 +67,5 @@ int close_all_fds(const int except[], unsigned n_except);
 int same_fd(int a, int b);
 
 void cmsg_close_all(struct msghdr *mh);
+
+bool fdname_is_valid(const char *s);
index 7d9dad472b925d23c0f8c47aa67768d034cb17ff..08bdcd28f256abc52323d62c9290da7a4765fcbf 100644 (file)
@@ -838,30 +838,3 @@ int version(void) {
              SYSTEMD_FEATURES);
         return 0;
 }
-
-bool fdname_is_valid(const char *s) {
-        const char *p;
-
-        /* Validates a name for $LISTEN_FDNAMES. 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_FDNAMES.
-         *
-         * Note that the empty string is explicitly allowed
-         * here. However, we limit the length of the names to 255
-         * characters. */
-
-        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;
-}
index 57dc5e8d46b4bd8177a813515846ae76dfbaadc4..2c2cb36190b81ebc0a8c5b766238c1970311b363 100644 (file)
@@ -194,5 +194,3 @@ union inotify_event_buffer {
 };
 
 int version(void);
-
-bool fdname_is_valid(const char *s);