]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: ignore -Dsmack-run-label= if -Dsmack=false 20800/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 Sep 2021 17:53:20 +0000 (19:53 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 Sep 2021 18:13:37 +0000 (20:13 +0200)
Compilation would fail because we could have HAVE_SMACK_RUN_LABEL without
HAVE_SMACK. This doesn't make much sense, so let's just make -Dsmack=false
completely disable smack.

Also, the logic in smack-setup.c seems dubious: '#ifdef SMACK_RUN_LABEL'
would evaluate to true even if -Dsmack-run-label='' is used. I think
this was introduced in the conversion to meson:
8b197c3a8a57c3f7c231b39e5660856fd9580c80 added

AC_ARG_WITH(smack-run-label,
AS_HELP_STRING([--with-smack-run-label=STRING],
        [run systemd --system with a specific SMACK label]),
        [AC_DEFINE_UNQUOTED(SMACK_RUN_LABEL, ["$withval"], [Run with a smack label])],
        [])

i.e. it really was undefined if not specified. And it was same
still in 72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8 when configure.ac
was dropped.

So let's use the single conditional HAVE_SMACK_RUN_LABEL everywhere.

meson.build
src/core/smack-setup.c
src/shared/mount-setup.c

index 8261b131555ca7378032285cfba42e71bb4c9e05..fe6b26b8357c33d11f37a4fb321c2f4b7346ecbf 100644 (file)
@@ -1024,8 +1024,11 @@ else
 endif
 conf.set10('HAVE_APPARMOR', have)
 
-conf.set10('HAVE_SMACK_RUN_LABEL', get_option('smack-run-label') != '')
-conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
+have = get_option('smack') and get_option('smack-run-label') != ''
+conf.set10('HAVE_SMACK_RUN_LABEL', have)
+if have
+        conf.set_quoted('SMACK_RUN_LABEL', get_option('smack-run-label'))
+endif
 
 want_polkit = get_option('polkit')
 install_polkit = false
index 79c480847340bedac6b4cc058e67db4346386451..5b2671ff406c2ade70c3b4537c2b3417dd77eb19 100644 (file)
@@ -322,7 +322,7 @@ int mac_smack_setup(bool *loaded_policy) {
                 return 0;
         }
 
-#ifdef SMACK_RUN_LABEL
+#if HAVE_SMACK_RUN_LABEL
         r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, WRITE_STRING_FILE_DISABLE_BUFFER);
         if (r < 0)
                 log_warning_errno(r, "Failed to set SMACK label \"" SMACK_RUN_LABEL "\" on self: %m");
index 0f2fb5d098a4592253e7d0abb5fc9f4cb4e70b4d..ae148541d7d3a54b2938899d293c83348640eecc 100644 (file)
@@ -278,7 +278,7 @@ static int symlink_controller(const char *target, const char *alias) {
         if (r < 0)
                 return log_error_errno(r, "Failed to create symlink %s: %m", a);
 
-#ifdef SMACK_RUN_LABEL
+#if HAVE_SMACK_RUN_LABEL
         const char *p;
 
         p = strjoina("/sys/fs/cgroup/", target);