chiark / gitweb /
unit: use weaker dependencies between mount and device units in --user mode
[elogind.git] / src / core / selinux-access.h
index 0926a5e..b5758e2 100644 (file)
 ***/
 
 #include "sd-bus.h"
-#include "bus-error.h"
 #include "bus-util.h"
+#include "manager.h"
 
-void selinux_access_free(void);
+void mac_selinux_access_free(void);
 
-int selinux_access_check(sd_bus *bus, sd_bus_message *message, const char *path, const char *permission, sd_bus_error *error);
+int mac_selinux_generic_access_check(sd_bus_message *message, const char *path, const char *permission, sd_bus_error *error);
+
+int mac_selinux_unit_access_check_strv(char **units, sd_bus_message *message, Manager *m, const char *permission, sd_bus_error *error);
 
 #ifdef HAVE_SELINUX
 
-#define SELINUX_ACCESS_CHECK(bus, message, permission)                  \
-        do {                                                            \
-                _cleanup_bus_error_free_ sd_bus_error _error = SD_BUS_ERROR_NULL; \
-                sd_bus_message *_m = (message);                         \
-                sd_bus *_b = (bus);                                     \
-                int _r;                                                 \
-                _r = selinux_access_check(_b, _m, NULL, (permission), &_error); \
-                if (_r < 0)                                             \
-                        return sd_bus_reply_method_errno(_b, _m, _r, &_error); \
-        } while (false)
-
-#define SELINUX_UNIT_ACCESS_CHECK(unit, bus, message, permission)       \
-        do {                                                            \
-                _cleanup_bus_error_free_ sd_bus_error _error = SD_BUS_ERROR_NULL; \
-                sd_bus_message *_m = (message);                         \
-                sd_bus *_b = (bus);                                     \
-                Unit *_u = (unit);                                      \
-                int _r;                                                 \
-                _r = selinux_access_check(_b, _m, _u->source_path ?: _u->fragment_path, (permission), &_error); \
-                if (_r < 0)                                             \
-                        return sd_bus_reply_method_errno(_b, _m, _r, &_error); \
-        } while (false)
+#define mac_selinux_access_check(message, permission, error) \
+        mac_selinux_generic_access_check((message), NULL, (permission), (error))
+
+#define mac_selinux_unit_access_check(unit, message, permission, error) \
+        ({                                                              \
+                Unit *_unit = (unit);                                   \
+                mac_selinux_generic_access_check((message), _unit->source_path ?: _unit->fragment_path, (permission), (error)); \
+        })
 
 #else
 
-#define SELINUX_ACCESS_CHECK(bus, message, permission) do { } while (false)
-#define SELINUX_UNIT_ACCESS_CHECK(unit, bus, message, permission) do { } while (false)
+#define mac_selinux_access_check(message, permission, error) 0
+#define mac_selinux_unit_access_check(unit, message, permission, error) 0
 
 #endif