]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/selinux-util.h
core: Record ExecMainStartTimestamp before forking
[thirdparty/systemd.git] / src / shared / selinux-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <fcntl.h>
5 #include <stdbool.h>
6 #include <sys/socket.h>
7 #include <sys/types.h>
8
9 #include "macro.h"
10 #include "label-util.h"
11
12 #if HAVE_SELINUX
13 #include <selinux/selinux.h>
14
15 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, freecon, NULL);
16 #define _cleanup_freecon_ _cleanup_(freeconp)
17 #endif
18
19 bool mac_selinux_use(void);
20 void mac_selinux_retest(void);
21 bool mac_selinux_enforcing(void);
22
23 int mac_selinux_init(void);
24 int mac_selinux_init_lazy(void);
25 void mac_selinux_maybe_reload(void);
26 void mac_selinux_finish(void);
27
28 int mac_selinux_fix_full(int atfd, const char *inode_path, const char *label_path, LabelFixFlags flags);
29
30 int mac_selinux_apply(const char *path, const char *label);
31 int mac_selinux_apply_fd(int fd, const char *path, const char *label);
32
33 int mac_selinux_get_create_label_from_exe(const char *exe, char **label);
34 int mac_selinux_get_our_label(char **label);
35 int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **label);
36 char* mac_selinux_free(char *label);
37
38 int mac_selinux_create_file_prepare_at(int dirfd, const char *path, mode_t mode);
39 static inline int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
40 return mac_selinux_create_file_prepare_at(AT_FDCWD, path, mode);
41 }
42 int mac_selinux_create_file_prepare_label(const char *path, const char *label);
43 void mac_selinux_create_file_clear(void);
44
45 int mac_selinux_create_socket_prepare(const char *label);
46 void mac_selinux_create_socket_clear(void);
47
48 int mac_selinux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
49
50 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, mac_selinux_free);