summaryrefslogtreecommitdiff
path: root/src/tmpfiles
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-06-14 16:01:19 +0200
committerMichal Schmidt <mschmidt@redhat.com>2012-06-14 16:01:19 +0200
commite7aee75932e8a5bee54eefcc77f4702a3ea79db2 (patch)
treee435499c0e3d8b08d3893a20e2eda8dba1aa3274 /src/tmpfiles
parent48899192a7b28b6a338cc8ec18aa35ccd8867acb (diff)
tmpfiles: create char devices with correct SELinux context
https://bugzilla.redhat.com/show_bug.cgi?id=824059
Diffstat (limited to 'src/tmpfiles')
-rw-r--r--src/tmpfiles/tmpfiles.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 22362eaa4c..6e0c093a82 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -744,10 +744,11 @@ static int create_item(Item *i) {
case CREATE_BLOCK_DEVICE:
case CREATE_CHAR_DEVICE: {
+ mode_t file_type = (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR);
u = umask(0);
- label_context_set(i->path, CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR);
- r = mknod(i->path, i->mode | (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR), i->major_minor);
+ label_context_set(i->path, file_type);
+ r = mknod(i->path, i->mode | file_type, i->major_minor);
e = errno;
label_context_clear();
umask(u);
@@ -763,7 +764,7 @@ static int create_item(Item *i) {
return -errno;
}
- if (i->type == CREATE_BLOCK_DEVICE ? !S_ISBLK(st.st_mode) : !S_ISCHR(st.st_mode)) {
+ if ((st.st_mode & S_IFMT) != file_type) {
log_error("%s is not a device node.", i->path);
return -EEXIST;
}