]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
seccomp: move seccomp_parse_errno_or_action() into common definitions
authorLennart Poettering <lennart@poettering.net>
Mon, 21 Aug 2023 16:39:01 +0000 (18:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 21 Aug 2023 16:50:29 +0000 (18:50 +0200)
Let's remove some HAVE_SECCOMP ifdeffery by simply defining the funcion
in question (seccomp_parse_errno_or_action() + related calls) into
common code that is also compiled if HAVE_SECCOMP is off.

This is generally the better approach anyway, since we want as much as
possible and easily feasible parsers work even if the code implementing
them is disabled. THis is easy to achieve here, hence do.

src/shared/bus-unit-util.c
src/shared/seccomp-util.h

index e7b44cc39bac7e552389143944e2cb0be294e625..6ea5e138e0754f096e5c35fcccbd16ad754d853e 100644 (file)
@@ -117,9 +117,6 @@ DEFINE_BUS_APPEND_PARSE("i", ioprio_class_from_string);
 DEFINE_BUS_APPEND_PARSE("i", ip_tos_from_string);
 DEFINE_BUS_APPEND_PARSE("i", log_facility_unshifted_from_string);
 DEFINE_BUS_APPEND_PARSE("i", log_level_from_string);
-#if !HAVE_SECCOMP
-static inline int seccomp_parse_errno_or_action(const char *eq) { return -EINVAL; }
-#endif
 DEFINE_BUS_APPEND_PARSE("i", seccomp_parse_errno_or_action);
 DEFINE_BUS_APPEND_PARSE("i", sched_policy_from_string);
 DEFINE_BUS_APPEND_PARSE("i", secure_bits_from_string);
index 9c6016449e81a2464f9469c249e68fb04b9be1e6..7583357e8af64308f482264cd48cd5415115c388 100644 (file)
@@ -2,8 +2,8 @@
 #pragma once
 
 #if HAVE_SECCOMP
-
 #include <seccomp.h>
+#endif
 #include <stdbool.h>
 #include <stdint.h>
 
@@ -13,6 +13,8 @@
 #include "set.h"
 #include "string-util.h"
 
+#if HAVE_SECCOMP
+
 const char* seccomp_arch_to_string(uint32_t c);
 int seccomp_arch_from_string(const char *n, uint32_t *ret);
 
@@ -143,6 +145,18 @@ int parse_syscall_archs(char **l, Set **ret_archs);
 
 uint32_t scmp_act_kill_process(void);
 
+int parse_syscall_and_errno(const char *in, char **name, int *error);
+
+int seccomp_suppress_sync(void);
+
+#else
+
+static inline bool is_seccomp_available(void) {
+        return false;
+}
+
+#endif
+
 /* This is a special value to be used where syscall filters otherwise expect errno numbers, will be
    replaced with real seccomp action. */
 enum {
@@ -164,15 +178,3 @@ static inline const char *seccomp_errno_or_action_to_string(int num) {
                 return "kill";
         return errno_to_name(num);
 }
-
-int parse_syscall_and_errno(const char *in, char **name, int *error);
-
-int seccomp_suppress_sync(void);
-
-#else
-
-static inline bool is_seccomp_available(void) {
-        return false;
-}
-
-#endif