smack: introduce new mac_smack_copy() function
This adds a new mac_smack_copy() function in order to read the smack label from the source and apply it to the destination.
This commit is contained in:
@@ -185,6 +185,23 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int mac_smack_copy(const char *dest, const char *src) {
|
||||
int r = 0;
|
||||
_cleanup_free_ char *label = NULL;
|
||||
|
||||
assert(dest);
|
||||
assert(src);
|
||||
|
||||
r = mac_smack_read(src, SMACK_ATTR_ACCESS, &label);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = mac_smack_apply(dest, SMACK_ATTR_ACCESS, label);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
bool mac_smack_use(void) {
|
||||
@@ -214,4 +231,8 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
|
||||
int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mac_smack_copy(const char *dest, const char *src) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,5 +48,5 @@ int mac_smack_read(const char *path, SmackAttr attr, char **label);
|
||||
int mac_smack_read_fd(int fd, SmackAttr attr, char **label);
|
||||
int mac_smack_apply(const char *path, SmackAttr attr, const char *label);
|
||||
int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label);
|
||||
|
||||
int mac_smack_apply_pid(pid_t pid, const char *label);
|
||||
int mac_smack_copy(const char *dest, const char *src);
|
||||
|
||||
Reference in New Issue
Block a user