]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/smack-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 Copyright © 2013 Intel Corporation
7 Author: Auke Kok <auke-jan.h.kok@intel.com>
11 #include <sys/types.h>
13 #include "label-util.h"
16 #define SMACK_FLOOR_LABEL "_"
17 #define SMACK_STAR_LABEL "*"
19 typedef enum SmackAttr
{
27 _SMACK_ATTR_INVALID
= -EINVAL
,
30 bool mac_smack_use(void);
31 int mac_smack_init(void);
33 int mac_smack_fix_full(int atfd
, const char *inode_path
, const char *label_path
, LabelFixFlags flags
);
34 static inline int mac_smack_fix(const char *path
, LabelFixFlags flags
) {
35 return mac_smack_fix_full(AT_FDCWD
, path
, path
, flags
);
38 const char* smack_attr_to_string(SmackAttr i
) _const_
;
39 SmackAttr
smack_attr_from_string(const char *s
) _pure_
;
40 int mac_smack_read(const char *path
, SmackAttr attr
, char **label
);
41 int mac_smack_read_fd(int fd
, SmackAttr attr
, char **label
);
42 int mac_smack_apply_at(int dir_fd
, const char *path
, SmackAttr attr
, const char *label
);
43 static inline int mac_smack_apply(const char *path
, SmackAttr attr
, const char *label
) {
44 return mac_smack_apply_at(AT_FDCWD
, path
, attr
, label
);
46 int mac_smack_apply_fd(int fd
, SmackAttr attr
, const char *label
);
47 int mac_smack_apply_pid(pid_t pid
, const char *label
);
48 int mac_smack_copy(const char *dest
, const char *src
);
50 int renameat_and_apply_smack_floor_label(int fdf
, const char *from
, int fdt
, const char *to
);
51 static inline int rename_and_apply_smack_floor_label(const char *from
, const char *to
) {
52 return renameat_and_apply_smack_floor_label(AT_FDCWD
, from
, AT_FDCWD
, to
);