| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
/*** |
| 5 |
Copyright © 2013 Intel Corporation |
| 6 |
|
| 7 |
Author: Auke Kok <[email protected]> |
| 8 |
***/ |
| 9 |
|
| 10 |
#include "shared-forward.h" |
| 11 |
|
| 12 |
typedef enum SmackAttr { |
| 13 |
SMACK_ATTR_ACCESS, |
| 14 |
SMACK_ATTR_EXEC, |
| 15 |
SMACK_ATTR_MMAP, |
| 16 |
SMACK_ATTR_TRANSMUTE, |
| 17 |
SMACK_ATTR_IPIN, |
| 18 |
SMACK_ATTR_IPOUT, |
| 19 |
_SMACK_ATTR_MAX, |
| 20 |
_SMACK_ATTR_INVALID = -EINVAL, |
| 21 |
} SmackAttr; |
| 22 |
|
| 23 |
bool mac_smack_use(void); |
| 24 |
|
| 25 |
int mac_smack_read_at(int fd, const char *path, SmackAttr attr, char **ret); |
| 26 |
int mac_smack_apply_at(int fd, const char *path, SmackAttr attr, const char *label); |
| 27 |
|
| 28 |
int mac_smack_apply_pid(pid_t pid, const char *label); |
| 29 |
|
| 30 |
int mac_smack_fix_full(int atfd, const char *inode_path, const char *label_path, LabelFixFlags flags); |
| 31 |
|
| 32 |
int mac_smack_init(void); |
| 33 |
|
| 34 |
static inline int mac_smack_read(const char *path, SmackAttr attr, char **ret) { |
| 35 |
return mac_smack_read_at(AT_FDCWD, path, attr, ret); |
| 36 |
} |
| 37 |
static inline int mac_smack_read_fd(int fd, SmackAttr attr, char **ret) { |
| 38 |
return mac_smack_read_at(fd, NULL, attr, ret); |
| 39 |
} |
| 40 |
|
| 41 |
static inline int mac_smack_apply(const char *path, SmackAttr attr, const char *label) { |
| 42 |
return mac_smack_apply_at(AT_FDCWD, path, attr, label); |
| 43 |
} |
| 44 |
static inline int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label) { |
| 45 |
return mac_smack_apply_at(fd, NULL, attr, label); |
| 46 |
} |
| 47 |
|
| 48 |
int mac_smack_fix(const char *path, LabelFixFlags flags); |
| 49 |
|
| 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); |
| 53 |
} |