It was a redundant wrapper around freecon.
test-selinux needs to be adjusted because it now needs to be linked to
libselinux, instead of pulling it in via libshared.
before_load = now(CLOCK_MONOTONIC);
r = selinux_init_load_policy(&enforce);
if (r == 0) {
- _cleanup_(mac_selinux_freep) char *label = NULL;
+ _cleanup_freecon_ char *label = NULL;
mac_selinux_retest();
static int socket_open_fds(Socket *orig_s) {
_cleanup_(socket_close_fdsp) Socket *s = orig_s;
- _cleanup_(mac_selinux_freep) char *label = NULL;
+ _cleanup_freecon_ char *label = NULL;
bool know_label = false;
int r;
FOREACH_DIRENT(de, d, return log_debug_errno(errno, "Failed to read directory: %m")) {
_cleanup_(portable_metadata_unrefp) PortableMetadata *m = NULL;
- _cleanup_(mac_selinux_freep) char *con = NULL;
+ _cleanup_freecon_ char *con = NULL;
_cleanup_close_ int fd = -EBADF;
struct stat st;
#endif
}
-char* mac_selinux_free(char *label) {
-
-#if HAVE_SELINUX
- freecon(label);
-#else
- assert(!label);
-#endif
-
- return NULL;
-}
-
#if HAVE_SELINUX
static int selinux_create_file_prepare_abspath(const char *abspath, mode_t mode) {
_cleanup_freecon_ char *filecon = NULL;
#include <selinux/selinux.h>
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, freecon, NULL);
-#define _cleanup_freecon_ _cleanup_(freeconp)
+#else
+static inline char* freeconp(char **p) {
+ assert(*p == NULL);
+ return NULL;
+}
#endif
+#define _cleanup_freecon_ _cleanup_(freeconp)
+
bool mac_selinux_use(void);
void mac_selinux_retest(void);
bool mac_selinux_enforcing(void);
int mac_selinux_get_create_label_from_exe(const char *exe, char **label);
int mac_selinux_get_our_label(char **label);
int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **label);
-char* mac_selinux_free(char *label);
int mac_selinux_create_file_prepare_at(int dirfd, const char *path, mode_t mode);
static inline int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
void mac_selinux_create_socket_clear(void);
int mac_selinux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(char*, mac_selinux_free);
'test-sd-hwdb.c',
'test-sd-path.c',
'test-secure-bits.c',
- 'test-selinux.c',
'test-serialize.c',
'test-set.c',
'test-sha256.c',
'dependencies' : libseccomp,
'conditions' : ['HAVE_SECCOMP'],
},
+ test_template + {
+ 'sources' : files('test-selinux.c'),
+ 'dependencies' : libselinux,
+ },
test_template + {
'sources' : files('test-set-disable-mempool.c'),
'dependencies' : threads,
}
static void test_misc(const char* fname) {
- _cleanup_(mac_selinux_freep) char *label = NULL, *label2 = NULL, *label3 = NULL;
+ _cleanup_freecon_ char *label = NULL, *label2 = NULL, *label3 = NULL;
int r;
_cleanup_close_ int fd = -EBADF;