tree-wide: use structured initialization for sockaddr_un
This commit is contained in:
@@ -964,9 +964,11 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
|
||||
} else
|
||||
b->nspid = 0;
|
||||
|
||||
b->sockaddr.un.sun_family = AF_UNIX;
|
||||
/* Note that we use the old /var/run prefix here, to increase compatibility with really old containers */
|
||||
strncpy(b->sockaddr.un.sun_path, "/var/run/dbus/system_bus_socket", sizeof(b->sockaddr.un.sun_path));
|
||||
b->sockaddr.un = (struct sockaddr_un) {
|
||||
.sun_family = AF_UNIX,
|
||||
/* Note that we use the old /var/run prefix here, to increase compatibility with really old containers */
|
||||
.sun_path = "/var/run/dbus/system_bus_socket",
|
||||
};
|
||||
b->sockaddr_size = SOCKADDR_UN_LEN(b->sockaddr.un);
|
||||
b->is_local = false;
|
||||
|
||||
|
||||
+3
-3
@@ -2815,7 +2815,8 @@ static int setup_sd_notify_child(void) {
|
||||
static const int one = 1;
|
||||
int fd = -1;
|
||||
union sockaddr_union sa = {
|
||||
.sa.sa_family = AF_UNIX,
|
||||
.un.sun_family = AF_UNIX,
|
||||
.un.sun_path = NSPAWN_NOTIFY_SOCKET_PATH,
|
||||
};
|
||||
int r;
|
||||
|
||||
@@ -2826,11 +2827,10 @@ static int setup_sd_notify_child(void) {
|
||||
(void) mkdir_parents(NSPAWN_NOTIFY_SOCKET_PATH, 0755);
|
||||
(void) unlink(NSPAWN_NOTIFY_SOCKET_PATH);
|
||||
|
||||
strncpy(sa.un.sun_path, NSPAWN_NOTIFY_SOCKET_PATH, sizeof(sa.un.sun_path));
|
||||
r = bind(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
|
||||
if (r < 0) {
|
||||
safe_close(fd);
|
||||
return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
|
||||
return log_error_errno(errno, "bind(" NSPAWN_NOTIFY_SOCKET_PATH ") failed: %m");
|
||||
}
|
||||
|
||||
r = userns_lchown(NSPAWN_NOTIFY_SOCKET_PATH, 0, 0);
|
||||
|
||||
@@ -101,8 +101,11 @@ struct udev_ctrl *udev_ctrl_new_from_fd(int fd) {
|
||||
if (r < 0)
|
||||
log_warning_errno(errno, "could not set SO_PASSCRED: %m");
|
||||
|
||||
uctrl->saddr.un.sun_family = AF_LOCAL;
|
||||
strscpy(uctrl->saddr.un.sun_path, sizeof(uctrl->saddr.un.sun_path), "/run/udev/control");
|
||||
uctrl->saddr.un = (struct sockaddr_un) {
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path = "/run/udev/control",
|
||||
};
|
||||
|
||||
uctrl->addrlen = SOCKADDR_UN_LEN(uctrl->saddr.un);
|
||||
return uctrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user