1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 /***
5   Copyright © 2013 Intel Corporation
6 
7   Author: Auke Kok <auke-jan.h.kok@intel.com>
8 ***/
9 
10 #include <stdbool.h>
11 #include <sys/types.h>
12 
13 #include "label.h"
14 #include "macro.h"
15 
16 #define SMACK_FLOOR_LABEL "_"
17 #define SMACK_STAR_LABEL  "*"
18 
19 typedef enum SmackAttr {
20         SMACK_ATTR_ACCESS,
21         SMACK_ATTR_EXEC,
22         SMACK_ATTR_MMAP,
23         SMACK_ATTR_TRANSMUTE,
24         SMACK_ATTR_IPIN,
25         SMACK_ATTR_IPOUT,
26         _SMACK_ATTR_MAX,
27         _SMACK_ATTR_INVALID = -EINVAL,
28 } SmackAttr;
29 
30 bool mac_smack_use(void);
31 
32 int mac_smack_fix_container(const char *path, const char *inside_path, LabelFixFlags flags);
mac_smack_fix(const char * path,LabelFixFlags flags)33 static inline int mac_smack_fix(const char *path, LabelFixFlags flags) {
34         return mac_smack_fix_container(path, path, flags);
35 }
36 
37 int mac_smack_fix_at(int dirfd, const char *path, LabelFixFlags flags);
38 
39 const char* smack_attr_to_string(SmackAttr i) _const_;
40 SmackAttr smack_attr_from_string(const char *s) _pure_;
41 int mac_smack_read(const char *path, SmackAttr attr, char **label);
42 int mac_smack_read_fd(int fd, SmackAttr attr, char **label);
43 int mac_smack_apply(const char *path, SmackAttr attr, const char *label);
44 int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label);
45 int mac_smack_apply_pid(pid_t pid, const char *label);
46 int mac_smack_copy(const char *dest, const char *src);
47 
48 int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);
49