|
Harald Hoyer |
fe20ad |
From cc1ab04e1ce05fc0aa917249677ab2818ea87eee Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
fe20ad |
From: Tom Gundersen <teg@jklm.no>
|
|
Harald Hoyer |
fe20ad |
Date: Wed, 24 Jul 2013 14:55:19 +0200
|
|
Harald Hoyer |
fe20ad |
Subject: [PATCH] udev: log error if chmod/chown of static dev nodes fails
|
|
Harald Hoyer |
fe20ad |
|
|
Harald Hoyer |
fe20ad |
---
|
|
Harald Hoyer |
fe20ad |
src/udev/udev-rules.c | 16 ++++++++++++----
|
|
Harald Hoyer |
fe20ad |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
Harald Hoyer |
fe20ad |
|
|
Harald Hoyer |
fe20ad |
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
|
|
Harald Hoyer |
fe20ad |
index 8ace705..fe4965f 100644
|
|
Harald Hoyer |
fe20ad |
--- a/src/udev/udev-rules.c
|
|
Harald Hoyer |
fe20ad |
+++ b/src/udev/udev-rules.c
|
|
Harald Hoyer |
fe20ad |
@@ -2593,13 +2593,21 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
|
|
Harald Hoyer |
fe20ad |
mode = 0600;
|
|
Harald Hoyer |
fe20ad |
}
|
|
Harald Hoyer |
fe20ad |
if (mode != (stats.st_mode & 01777)) {
|
|
Harald Hoyer |
fe20ad |
- chmod(device_node, mode);
|
|
Harald Hoyer |
fe20ad |
- log_debug("chmod '%s' %#o\n", device_node, mode);
|
|
Harald Hoyer |
fe20ad |
+ r = chmod(device_node, mode);
|
|
Harald Hoyer |
fe20ad |
+ if (r < 0) {
|
|
Harald Hoyer |
fe20ad |
+ log_error("failed to chmod '%s' %#o\n", device_node, mode);
|
|
Harald Hoyer |
fe20ad |
+ return -errno;
|
|
Harald Hoyer |
fe20ad |
+ } else
|
|
Harald Hoyer |
fe20ad |
+ log_debug("chmod '%s' %#o\n", device_node, mode);
|
|
Harald Hoyer |
fe20ad |
}
|
|
Harald Hoyer |
fe20ad |
|
|
Harald Hoyer |
fe20ad |
if ((uid != 0 && uid != stats.st_uid) || (gid != 0 && gid != stats.st_gid)) {
|
|
Harald Hoyer |
fe20ad |
- chown(device_node, uid, gid);
|
|
Harald Hoyer |
fe20ad |
- log_debug("chown '%s' %u %u\n", device_node, uid, gid);
|
|
Harald Hoyer |
fe20ad |
+ r = chown(device_node, uid, gid);
|
|
Harald Hoyer |
fe20ad |
+ if (r < 0) {
|
|
Harald Hoyer |
fe20ad |
+ log_error("failed to chown '%s' %u %u \n", device_node, uid, gid);
|
|
Harald Hoyer |
fe20ad |
+ return -errno;
|
|
Harald Hoyer |
fe20ad |
+ } else
|
|
Harald Hoyer |
fe20ad |
+ log_debug("chown '%s' %u %u\n", device_node, uid, gid);
|
|
Harald Hoyer |
fe20ad |
}
|
|
Harald Hoyer |
fe20ad |
|
|
Harald Hoyer |
fe20ad |
utimensat(AT_FDCWD, device_node, NULL, 0);
|