tree-wide: use structured initialization for sockaddr_un

This commit is contained in:
Lennart Poettering
2018-10-15 19:35:00 +02:00
parent ececf6c082
commit 44ed5214ad
3 changed files with 13 additions and 8 deletions
+3 -3
View File
@@ -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);