|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 543afdc63c02a5af3cf6bd2a264162f23474346a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Tom Gundersen <teg@jklm.no>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 18 Sep 2014 19:22:09 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] udev: node - warn if chmod/chown fails
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
No functional change, just log the warning.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Fonud by Coverity. Fixes CID #1237544.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/udev/udev-node.c | 8 ++++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index c164603795..8ef788954d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/udev/udev-node.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/udev/udev-node.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -281,8 +281,12 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug("set permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- chmod(devnode, mode);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- chown(devnode, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ err = chmod(devnode, mode);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (err < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_warning("setting mode of %s to %#o failed: %m", devnode, mode);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ err = chown(devnode, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (err < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_warning("setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug("preserve permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|