]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
selinux: invoke selinux_set_callback(3) more type-safe 19551/head
authorChristian Göttsche <cgzones@googlemail.com>
Fri, 14 May 2021 12:14:25 +0000 (14:14 +0200)
committerChristian Göttsche <cgzones@googlemail.com>
Fri, 14 May 2021 14:53:04 +0000 (16:53 +0200)
src/core/selinux-access.c
src/core/selinux-setup.c

index cdb82dd8947ad33d46f2bcc52773aa0d7581d4ca..d077d5dea751c6e936c5f99ce8c5648549825038 100644 (file)
@@ -162,8 +162,8 @@ static int access_init(sd_bus_error *error) {
                 return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to open the SELinux AVC: %s", strerror_safe(saved_errno));
         }
 
-        selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback) audit_callback);
-        selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) log_callback);
+        selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback) { .func_audit = audit_callback });
+        selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) { .func_log = log_callback });
 
         initialized = true;
         return 1;
index 1ac05b81e8e9a19aa032f40db15e98a35d59e683..2bafbee3eb6a18f13fb7c89172a742b3fc71af60 100644 (file)
@@ -30,16 +30,12 @@ int mac_selinux_setup(bool *loaded_policy) {
         usec_t before_load, after_load;
         char *con;
         int r;
-        static const union selinux_callback cb = {
-                .func_log = null_log,
-        };
-
         bool initialized = false;
 
         assert(loaded_policy);
 
         /* Turn off all of SELinux' own logging, we want to do that */
-        selinux_set_callback(SELINUX_CB_LOG, cb);
+        selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) { .func_log = null_log });
 
         /* Don't load policy in the initrd if we don't appear to have
          * it.  For the real root, we check below if we've already