namespace: fix MAC labels of /dev when PrivateDevices=yes

Without changing the SELinux label for private /dev of a service, it will take
a generic file system label:
system_u:object_r:tmpfs_t:s0

After this change it is the same as without `PrivateDevices=yes`:
system_u:object_r:device_t:s0

This helps writing SELinux policies, as the same rules for `/dev` will apply
despite any `PrivateDevices=yes` setting.
This commit is contained in:
Topi Miettinen
2020-02-28 14:17:48 +00:00
committed by Topi Miettinen
parent 07336a0672
commit e6e81ec0a5
7 changed files with 40 additions and 12 deletions
+4 -1
View File
@@ -9,7 +9,10 @@ typedef enum LabelFixFlags {
LABEL_IGNORE_EROFS = 1 << 1,
} LabelFixFlags;
int label_fix(const char *path, LabelFixFlags flags);
int label_fix_container(const char *path, const char *inside_path, LabelFixFlags flags);
static inline int label_fix(const char *path, LabelFixFlags flags) {
return label_fix_container(path, path, flags);
}
int mkdir_label(const char *path, mode_t mode);
int mkdirat_label(int dirfd, const char *path, mode_t mode);