[systemd-devel] [PATCH] tmpfiles: only change device permissions if mknod succeeded
Jan Synacek
jsynacek at redhat.com
Tue Oct 14 07:19:20 PDT 2014
https://bugzilla.redhat.com/show_bug.cgi?id=1147248
---
src/tmpfiles/tmpfiles.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 8108b43..ae0289d 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -824,6 +824,7 @@ static int create_item(Item *i) {
case CREATE_BLOCK_DEVICE:
case CREATE_CHAR_DEVICE: {
mode_t file_type;
+ bool mknod_succeeded;
if (have_effective_cap(CAP_MKNOD) == 0) {
/* In a container we lack CAP_MKNOD. We
@@ -842,6 +843,7 @@ static int create_item(Item *i) {
r = mknod(i->path, i->mode | file_type, i->major_minor);
label_context_clear();
}
+ mknod_succeeded = (r == 0);
if (r < 0) {
if (errno == EPERM) {
@@ -881,10 +883,11 @@ static int create_item(Item *i) {
}
}
- r = item_set_perms(i, i->path);
- if (r < 0)
- return r;
-
+ if (mknod_succeeded) {
+ r = item_set_perms(i, i->path);
+ if (r < 0)
+ return r;
+ }
break;
}
--
1.9.3
More information about the systemd-devel
mailing list