chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemd-hwdb: introduce new tool
[elogind.git]
/
src
/
udev
/
udev-ctrl.c
diff --git
a/src/udev/udev-ctrl.c
b/src/udev/udev-ctrl.c
index 6fb5bb4a7a87d03dfb6ac34aae07fb65bb67c22f..9cece4a85d9ebe963589e6d7441a017c210e637c 100644
(file)
--- 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;
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)
uctrl = new0(struct udev_ctrl, 1);
if (uctrl == NULL)
@@
-83,7
+84,7
@@
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
if (fd < 0) {
uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
if (uctrl->sock < 0) {
- log_error
(
"error getting socket: %m");
+ log_error
_errno(errno,
"error getting socket: %m");
udev_ctrl_unref(uctrl);
return NULL;
}
udev_ctrl_unref(uctrl);
return NULL;
}
@@
-91,7
+92,9
@@
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) {
uctrl->bound = true;
uctrl->sock = 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_errno(errno, "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");
uctrl->saddr.sun_family = AF_LOCAL;
strscpy(uctrl->saddr.sun_path, sizeof(uctrl->saddr.sun_path), "/run/udev/control");
@@
-115,14
+118,14
@@
int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
if (err < 0) {
err = -errno;
if (err < 0) {
err = -errno;
- log_error
(
"bind failed: %m");
+ log_error
_errno(errno,
"bind failed: %m");
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
return err;
}
err = listen(uctrl->sock, 0);
if (err < 0) {
err = -errno;
- log_error
(
"listen failed: %m");
+ log_error
_errno(errno,
"listen failed: %m");
return err;
}
return err;
}
@@
-184,14
+187,14
@@
struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (conn->sock < 0) {
if (errno != EINTR)
conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (conn->sock < 0) {
if (errno != EINTR)
- log_error
(
"unable to receive ctrl connection: %m");
+ log_error
_errno(errno,
"unable to receive ctrl connection: %m");
goto err;
}
/* check peer credential of connection */
r = getpeercred(conn->sock, &ucred);
if (r < 0) {
goto err;
}
/* check peer credential of connection */
r = getpeercred(conn->sock, &ucred);
if (r < 0) {
- log_error
("unable to receive credentials of ctrl connection: %s", strerror(-r)
);
+ log_error
_errno(r, "unable to receive credentials of ctrl connection: %m"
);
goto err;
}
if (ucred.uid > 0) {
goto err;
}
if (ucred.uid > 0) {
@@
-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 */
}
/* 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_errno(errno, "could not set SO_PASSCRED: %m");
+
udev_ctrl_ref(uctrl);
return conn;
err:
udev_ctrl_ref(uctrl);
return conn;
err:
@@
-355,7
+361,7
@@
struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
goto err;
} else {
if (!(pfd[0].revents & POLLIN)) {
- log_error
(
"ctrl connection error: %m");
+ log_error
_errno(errno,
"ctrl connection error: %m");
goto err;
}
}
goto err;
}
}
@@
-368,7
+374,7
@@
struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
size = recvmsg(conn->sock, &smsg, 0);
if (size < 0) {
- log_error
(
"unable to receive ctrl message: %m");
+ log_error
_errno(errno,
"unable to receive ctrl message: %m");
goto err;
}
cmsg = CMSG_FIRSTHDR(&smsg);
goto err;
}
cmsg = CMSG_FIRSTHDR(&smsg);