]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/selinux-util.h
selinux: cache enforced status and treat retrieve failure as enforced mode
[thirdparty/systemd.git] / src / basic / selinux-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <sys/socket.h>
6 #include <sys/types.h>
7
8 #include "macro.h"
9 #include "label.h"
10
11 #if HAVE_SELINUX
12 #include <selinux/selinux.h>
13
14 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);
15 #define _cleanup_freecon_ _cleanup_(freeconp)
16 #endif
17
18 bool mac_selinux_use(void);
19 bool mac_selinux_enforcing(void);
20 void mac_selinux_retest(void);
21
22 int mac_selinux_init(void);
23 void mac_selinux_finish(void);
24
25 int mac_selinux_fix(const char *path, LabelFixFlags flags);
26 int mac_selinux_apply(const char *path, const char *label);
27
28 int mac_selinux_get_create_label_from_exe(const char *exe, char **label);
29 int mac_selinux_get_our_label(char **label);
30 int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **label);
31 char* mac_selinux_free(char *label);
32
33 int mac_selinux_create_file_prepare(const char *path, mode_t mode);
34 int mac_selinux_create_file_prepare_at(int dirfd, const char *path, mode_t mode);
35 void mac_selinux_create_file_clear(void);
36
37 int mac_selinux_create_socket_prepare(const char *label);
38 void mac_selinux_create_socket_clear(void);
39
40 int mac_selinux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
41
42 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, mac_selinux_free);