dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Blob Blame History Raw
From 543afdc63c02a5af3cf6bd2a264162f23474346a Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Thu, 18 Sep 2014 19:22:09 +0200
Subject: [PATCH] udev: node - warn if chmod/chown fails

No functional change, just log the warning.

Fonud by Coverity. Fixes CID #1237544.
---
 src/udev/udev-node.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index c164603795..8ef788954d 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -281,8 +281,12 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
 
                 if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
                         log_debug("set permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
-                        chmod(devnode, mode);
-                        chown(devnode, uid, gid);
+                        err = chmod(devnode, mode);
+                        if (err < 0)
+                                log_warning("setting mode of %s to %#o failed: %m", devnode, mode);
+                        err = chown(devnode, uid, gid);
+                        if (err < 0)
+                                log_warning("setting owner of %s to uid=%u, gid=%u failed: %m", devnode, uid, gid);
                 } else {
                         log_debug("preserve permissions %s, %#o, uid=%u, gid=%u", devnode, mode, uid, gid);
                 }