]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: move journal_field_valid() to journal_file.c
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Dec 2020 19:36:14 +0000 (04:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Dec 2020 19:48:44 +0000 (04:48 +0900)
src/core/dbus-execute.c
src/core/load-fragment.c
src/journal/journal-file.c
src/journal/journal-file.h
src/shared/journal-util.c
src/shared/journal-util.h
src/systemctl/systemctl-show.c

index abe009c3956a382a3184a38461e3973b7155938b..04735354a33bf479d64d5fcc9f3c94286f0d4fdd 100644 (file)
@@ -24,7 +24,7 @@
 #include "hexdecoct.h"
 #include "io-util.h"
 #include "ioprio.h"
-#include "journal-util.h"
+#include "journal-file.h"
 #include "mountpoint-util.h"
 #include "namespace.h"
 #include "parse-util.h"
index ffc58dde9cd92aa8be1d5b5220fa6c8f0f0ef385..4964249bf213e2cdf00bfa288d6ef17359609dcb 100644 (file)
@@ -38,7 +38,7 @@
 #include "io-util.h"
 #include "ioprio.h"
 #include "ip-protocol-list.h"
-#include "journal-util.h"
+#include "journal-file.h"
 #include "limits-util.h"
 #include "load-fragment.h"
 #include "log.h"
index 20c4edb6caa635089d53a3537c4e48eb155697b2..18dc3072b483cca6b345d01fc33384688dc9f9da 100644 (file)
@@ -1521,6 +1521,44 @@ int journal_file_find_data_object(
                         ret, ret_offset);
 }
 
+bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
+        const char *a;
+
+        /* We kinda enforce POSIX syntax recommendations for
+           environment variables here, but make a couple of additional
+           requirements.
+
+           http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
+
+        if (l == (size_t) -1)
+                l = strlen(p);
+
+        /* No empty field names */
+        if (l <= 0)
+                return false;
+
+        /* Don't allow names longer than 64 chars */
+        if (l > 64)
+                return false;
+
+        /* Variables starting with an underscore are protected */
+        if (!allow_protected && p[0] == '_')
+                return false;
+
+        /* Don't allow digits as first character */
+        if (p[0] >= '0' && p[0] <= '9')
+                return false;
+
+        /* Only allow A-Z0-9 and '_' */
+        for (a = p; a < p + l; a++)
+                if ((*a < 'A' || *a > 'Z') &&
+                    (*a < '0' || *a > '9') &&
+                    *a != '_')
+                        return false;
+
+        return true;
+}
+
 static int journal_file_append_field(
                 JournalFile *f,
                 const void *field, uint64_t size,
index 263d032b90dd0b2a9c4fe17d950bb6597d40a39a..931c8742686ef4163696e1d93000dda4069df9a5 100644 (file)
@@ -271,3 +271,5 @@ static inline bool JOURNAL_FILE_COMPRESS(JournalFile *f) {
 }
 
 uint64_t journal_file_hash_data(JournalFile *f, const void *data, size_t sz);
+
+bool journal_field_valid(const char *p, size_t l, bool allow_protected);
index 29659aa6b75d709ff353f341d3b8063dd009df3b..9e1870e176c763ef25b2562413016bc0cf017cca 100644 (file)
@@ -137,41 +137,3 @@ int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_use
 
         return r;
 }
-
-bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
-        const char *a;
-
-        /* We kinda enforce POSIX syntax recommendations for
-           environment variables here, but make a couple of additional
-           requirements.
-
-           http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
-
-        if (l == (size_t) -1)
-                l = strlen(p);
-
-        /* No empty field names */
-        if (l <= 0)
-                return false;
-
-        /* Don't allow names longer than 64 chars */
-        if (l > 64)
-                return false;
-
-        /* Variables starting with an underscore are protected */
-        if (!allow_protected && p[0] == '_')
-                return false;
-
-        /* Don't allow digits as first character */
-        if (p[0] >= '0' && p[0] <= '9')
-                return false;
-
-        /* Only allow A-Z0-9 and '_' */
-        for (a = p; a < p + l; a++)
-                if ((*a < 'A' || *a > 'Z') &&
-                    (*a < '0' || *a > '9') &&
-                    *a != '_')
-                        return false;
-
-        return true;
-}
index db7000ffefee6414c7b2b8dd7073876d0790a7bc..86fcba058dbc285f53d12905a10cb9a6c7ab57c7 100644 (file)
@@ -6,6 +6,5 @@
 
 #include "sd-journal.h"
 
-bool journal_field_valid(const char *p, size_t l, bool allow_protected);
 int journal_access_blocked(sd_journal *j);
 int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users);
index fabaa545e14972e81d46a67c4be2dfd9ddd2820c..d5efecbe65e70509848ca82afca5ad96d7c0851f 100644 (file)
@@ -16,7 +16,7 @@
 #include "hexdecoct.h"
 #include "hostname-util.h"
 #include "in-addr-util.h"
-#include "journal-util.h"
+#include "journal-file.h"
 #include "list.h"
 #include "locale-util.h"
 #include "memory-util.h"