[systemd-commits] 2 commits - src/udev
Tom Gundersen
tomegun at kemper.freedesktop.org
Thu Sep 18 10:27:21 PDT 2014
src/udev/udev-ctrl.c | 10 ++++++++--
src/udev/udev-node.c | 8 ++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
New commits:
commit 4bbdff757ed4e718a3348b93439a03055cc5e3bc
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Sep 18 19:26:11 2014 +0200
udev: ctrl - log if setting SO_PASSCRED fails
No functional change.
Found by Coverity. Fixes CID #1237533.
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 6fb5bb4..d02147f 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -73,6 +73,7 @@ struct udev_ctrl_connection {
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
struct udev_ctrl *uctrl;
const int on = 1;
+ int r;
uctrl = new0(struct udev_ctrl, 1);
if (uctrl == NULL)
@@ -91,7 +92,9 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
uctrl->bound = true;
uctrl->sock = fd;
}
- setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ if (r < 0)
+ log_warning("could not set SO_PASSCRED: %m");
uctrl->saddr.sun_family = AF_LOCAL;
strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
@@ -200,7 +203,10 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
}
/* enable receiving of the sender credentials in the messages */
- setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ if (r < 0)
+ log_warning("colud not set SO_PASSCRED: %m");
+
udev_ctrl_ref(uctrl);
return conn;
err:
commit 543afdc63c02a5af3cf6bd2a264162f23474346a
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Sep 18 19:22:09 2014 +0200
udev: node - warn if chmod/chown fails
No functional change, just log the warning.
Fonud by Coverity. Fixes CID #1237544.
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index c164603..8ef7889 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);
}
More information about the systemd-commits
mailing list