mirror of
https://github.com/systemd/systemd.git
synced 2025-02-14 05:57:40 +03:00
tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so that things properly aligned. Otherwise we might end up at an unaligned address and the counting goes all wrong, possibly making the kernel refuse our buffers. Also, let's make sure we initialize the control buffers to zero when sending, but leave them uninitialized when reading. Both the alignment and the initialization thing is mentioned in the cmsg(3) man page.
This commit is contained in:
parent
0d9d333672
commit
fb29cdbef2
@ -818,10 +818,7 @@ ssize_t send_one_fd_iov_sa(
|
|||||||
const struct sockaddr *sa, socklen_t len,
|
const struct sockaddr *sa, socklen_t len,
|
||||||
int flags) {
|
int flags) {
|
||||||
|
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control = {};
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
.msg_name = (struct sockaddr*) sa,
|
.msg_name = (struct sockaddr*) sa,
|
||||||
.msg_namelen = len,
|
.msg_namelen = len,
|
||||||
@ -875,10 +872,7 @@ ssize_t receive_one_fd_iov(
|
|||||||
int flags,
|
int flags,
|
||||||
int *ret_fd) {
|
int *ret_fd) {
|
||||||
|
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
.msg_control = &control,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(control),
|
.msg_controllen = sizeof(control),
|
||||||
|
@ -166,6 +166,17 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
|
|||||||
(ctype*) (_found ? CMSG_DATA(_found) : NULL); \
|
(ctype*) (_found ? CMSG_DATA(_found) : NULL); \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Resolves to a type that can carry cmsghdr structures. Make sure things are properly aligned, i.e. the type
|
||||||
|
* itself is placed properly in memory and the size is also aligned to what's appropriate for "cmsghdr"
|
||||||
|
* structures. */
|
||||||
|
#define CMSG_BUFFER_TYPE(size) \
|
||||||
|
union { \
|
||||||
|
struct cmsghdr cmsghdr; \
|
||||||
|
uint8_t buf[size]; \
|
||||||
|
uint8_t align_check[(size) >= CMSG_SPACE(0) && \
|
||||||
|
(size) == CMSG_ALIGN(size) ? 1 : -1]; \
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Certain hardware address types (e.g Infiniband) do not fit into sll_addr
|
* Certain hardware address types (e.g Infiniband) do not fit into sll_addr
|
||||||
* (8 bytes) and run over the structure. This macro returns the correct size that
|
* (8 bytes) and run over the structure. This macro returns the correct size that
|
||||||
|
@ -2349,11 +2349,8 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
|
|||||||
.iov_base = buf,
|
.iov_base = buf,
|
||||||
.iov_len = sizeof(buf)-1,
|
.iov_len = sizeof(buf)-1,
|
||||||
};
|
};
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) +
|
||||||
struct cmsghdr cmsghdr;
|
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)) control;
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
|
|
||||||
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
|
@ -884,10 +884,7 @@ static int process_socket(int fd) {
|
|||||||
log_debug("Processing coredump received on stdin...");
|
log_debug("Processing coredump received on stdin...");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
.msg_control = &control,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(control),
|
.msg_controllen = sizeof(control),
|
||||||
|
@ -946,10 +946,7 @@ static ssize_t read_datagram(int fd, struct ucred *ret_sender, void **ret) {
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (ret_sender) {
|
if (ret_sender) {
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
|
||||||
} control;
|
|
||||||
bool found_ucred = false;
|
bool found_ucred = false;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
|
@ -550,11 +550,8 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
|
|||||||
.iov_base = buf,
|
.iov_base = buf,
|
||||||
.iov_len = sizeof(buf)-1,
|
.iov_len = sizeof(buf)-1,
|
||||||
};
|
};
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) +
|
||||||
struct cmsghdr cmsghdr;
|
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)) control;
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
|
|
||||||
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
|
@ -1268,21 +1268,14 @@ int server_process_datagram(
|
|||||||
int *fds = NULL, v = 0;
|
int *fds = NULL, v = 0;
|
||||||
size_t n_fds = 0;
|
size_t n_fds = 0;
|
||||||
|
|
||||||
union {
|
/* We use NAME_MAX space for the SELinux label here. The kernel currently enforces no limit, but
|
||||||
struct cmsghdr cmsghdr;
|
* according to suggestions from the SELinux people this will change and it will probably be
|
||||||
|
* identical to NAME_MAX. For now we use that, but this should be updated one day when the final
|
||||||
/* We use NAME_MAX space for the SELinux label
|
* limit is known. */
|
||||||
* here. The kernel currently enforces no
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) +
|
||||||
* limit, but according to suggestions from
|
CMSG_SPACE(sizeof(struct timeval)) +
|
||||||
* the SELinux people this will change and it
|
CMSG_SPACE(sizeof(int)) + /* fd */
|
||||||
* will probably be identical to NAME_MAX. For
|
CMSG_SPACE(NAME_MAX) /* selinux label */) control;
|
||||||
* now we use that, but this should be updated
|
|
||||||
* one day when the final limit is known. */
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
|
|
||||||
CMSG_SPACE(sizeof(struct timeval)) +
|
|
||||||
CMSG_SPACE(sizeof(int)) + /* fd */
|
|
||||||
CMSG_SPACE(NAME_MAX)]; /* selinux label */
|
|
||||||
} control = {};
|
|
||||||
|
|
||||||
union sockaddr_union sa = {};
|
union sockaddr_union sa = {};
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ static int stdout_stream_scan(StdoutStream *s, bool force_flush) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
|
static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
StdoutStream *s = userdata;
|
StdoutStream *s = userdata;
|
||||||
struct ucred *ucred;
|
struct ucred *ucred;
|
||||||
struct iovec iovec;
|
struct iovec iovec;
|
||||||
@ -500,8 +500,8 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
|
|||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = buf,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(buf),
|
.msg_controllen = sizeof(control),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
|
@ -39,10 +39,7 @@ static void forward_syslog_iovec(
|
|||||||
.msg_iovlen = n_iovec,
|
.msg_iovlen = n_iovec,
|
||||||
};
|
};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
|
||||||
} control;
|
|
||||||
const char *j;
|
const char *j;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -147,11 +147,9 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
|
|||||||
|
|
||||||
int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
|
int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
|
||||||
triple_timestamp *timestamp) {
|
triple_timestamp *timestamp) {
|
||||||
union {
|
|
||||||
struct cmsghdr cmsghdr;
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int)) + /* ttl */
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int)) + /* ttl */
|
CMSG_SPACE(sizeof(struct timeval))) control;
|
||||||
CMSG_SPACE(sizeof(struct timeval))];
|
|
||||||
} control = {};
|
|
||||||
struct iovec iov = {};
|
struct iovec iov = {};
|
||||||
union sockaddr_union sa = {};
|
union sockaddr_union sa = {};
|
||||||
struct msghdr msg = {
|
struct msghdr msg = {
|
||||||
|
@ -1899,13 +1899,13 @@ static int client_receive_message_raw(
|
|||||||
|
|
||||||
sd_dhcp_client *client = userdata;
|
sd_dhcp_client *client = userdata;
|
||||||
_cleanup_free_ DHCPPacket *packet = NULL;
|
_cleanup_free_ DHCPPacket *packet = NULL;
|
||||||
uint8_t cmsgbuf[CMSG_SPACE(sizeof(struct tpacket_auxdata))];
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct tpacket_auxdata))) control;
|
||||||
struct iovec iov = {};
|
struct iovec iov = {};
|
||||||
struct msghdr msg = {
|
struct msghdr msg = {
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = cmsgbuf,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(cmsgbuf),
|
.msg_controllen = sizeof(control),
|
||||||
};
|
};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
bool checksum = true;
|
bool checksum = true;
|
||||||
|
@ -267,14 +267,14 @@ static int dhcp_server_send_udp(sd_dhcp_server *server, be32_t destination,
|
|||||||
.iov_base = message,
|
.iov_base = message,
|
||||||
.iov_len = len,
|
.iov_len = len,
|
||||||
};
|
};
|
||||||
uint8_t cmsgbuf[CMSG_SPACE(sizeof(struct in_pktinfo))] = {};
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct in_pktinfo))) control = {};
|
||||||
struct msghdr msg = {
|
struct msghdr msg = {
|
||||||
.msg_name = &dest,
|
.msg_name = &dest,
|
||||||
.msg_namelen = sizeof(dest.in),
|
.msg_namelen = sizeof(dest.in),
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = cmsgbuf,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(cmsgbuf),
|
.msg_controllen = sizeof(control),
|
||||||
};
|
};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
struct in_pktinfo *pktinfo;
|
struct in_pktinfo *pktinfo;
|
||||||
@ -970,14 +970,14 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
|
|||||||
static int server_receive_message(sd_event_source *s, int fd,
|
static int server_receive_message(sd_event_source *s, int fd,
|
||||||
uint32_t revents, void *userdata) {
|
uint32_t revents, void *userdata) {
|
||||||
_cleanup_free_ DHCPMessage *message = NULL;
|
_cleanup_free_ DHCPMessage *message = NULL;
|
||||||
uint8_t cmsgbuf[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct in_pktinfo))) control;
|
||||||
sd_dhcp_server *server = userdata;
|
sd_dhcp_server *server = userdata;
|
||||||
struct iovec iov = {};
|
struct iovec iov = {};
|
||||||
struct msghdr msg = {
|
struct msghdr msg = {
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = cmsgbuf,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(cmsgbuf),
|
.msg_controllen = sizeof(control),
|
||||||
};
|
};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
ssize_t buflen, len;
|
ssize_t buflen, len;
|
||||||
|
@ -518,10 +518,7 @@ static int bus_socket_read_auth(sd_bus *b) {
|
|||||||
ssize_t k;
|
ssize_t k;
|
||||||
int r;
|
int r;
|
||||||
void *p;
|
void *p;
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)];
|
|
||||||
} control;
|
|
||||||
bool handle_cmsg = false;
|
bool handle_cmsg = false;
|
||||||
|
|
||||||
assert(b);
|
assert(b);
|
||||||
@ -1169,10 +1166,7 @@ int bus_socket_read_message(sd_bus *bus) {
|
|||||||
size_t need;
|
size_t need;
|
||||||
int r;
|
int r;
|
||||||
void *b;
|
void *b;
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)];
|
|
||||||
} control;
|
|
||||||
bool handle_cmsg = false;
|
bool handle_cmsg = false;
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
@ -361,13 +361,13 @@ int device_monitor_receive_device(sd_device_monitor *m, sd_device **ret) {
|
|||||||
.iov_base = &buf,
|
.iov_base = &buf,
|
||||||
.iov_len = sizeof(buf)
|
.iov_len = sizeof(buf)
|
||||||
};
|
};
|
||||||
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
union sockaddr_union snl;
|
union sockaddr_union snl;
|
||||||
struct msghdr smsg = {
|
struct msghdr smsg = {
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = cred_msg,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(cred_msg),
|
.msg_controllen = sizeof(control),
|
||||||
.msg_name = &snl,
|
.msg_name = &snl,
|
||||||
.msg_namelen = sizeof(snl),
|
.msg_namelen = sizeof(snl),
|
||||||
};
|
};
|
||||||
|
@ -3687,11 +3687,8 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
|||||||
.iov_base = buf,
|
.iov_base = buf,
|
||||||
.iov_len = sizeof(buf)-1,
|
.iov_len = sizeof(buf)-1,
|
||||||
};
|
};
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) +
|
||||||
struct cmsghdr cmsghdr;
|
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)) control;
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
|
|
||||||
CMSG_SPACE(sizeof(int) * NOTIFY_FD_MAX)];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
|
@ -127,10 +127,7 @@ static int send_item(
|
|||||||
const char *name,
|
const char *name,
|
||||||
int fd) {
|
int fd) {
|
||||||
|
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control = {};
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
|
||||||
} control = {};
|
|
||||||
struct iovec iovec;
|
struct iovec iovec;
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
.msg_control = &control,
|
.msg_control = &control,
|
||||||
@ -168,10 +165,7 @@ static int recv_item(
|
|||||||
char **ret_name,
|
char **ret_name,
|
||||||
int *ret_fd) {
|
int *ret_fd) {
|
||||||
|
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
|
||||||
} control = {};
|
|
||||||
char buffer[PATH_MAX+2];
|
char buffer[PATH_MAX+2];
|
||||||
struct iovec iov = IOVEC_INIT(buffer, sizeof(buffer)-1);
|
struct iovec iov = IOVEC_INIT(buffer, sizeof(buffer)-1);
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
|
@ -87,11 +87,8 @@ static int dns_stream_complete(DnsStream *s, int error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int dns_stream_identify(DnsStream *s) {
|
static int dns_stream_identify(DnsStream *s) {
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
|
||||||
struct cmsghdr header; /* For alignment */
|
+ EXTRA_CMSG_SPACE /* kernel appears to require extra space */) control;
|
||||||
uint8_t buffer[CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
|
|
||||||
+ EXTRA_CMSG_SPACE /* kernel appears to require extra space */];
|
|
||||||
} control;
|
|
||||||
struct msghdr mh = {};
|
struct msghdr mh = {};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
socklen_t sl;
|
socklen_t sl;
|
||||||
|
@ -741,12 +741,9 @@ Manager *manager_free(Manager *m) {
|
|||||||
|
|
||||||
int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
||||||
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
|
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
|
||||||
struct cmsghdr header; /* For alignment */
|
+ CMSG_SPACE(int) /* ttl/hoplimit */
|
||||||
uint8_t buffer[CMSG_SPACE(MAXSIZE(struct in_pktinfo, struct in6_pktinfo))
|
+ EXTRA_CMSG_SPACE /* kernel appears to require extra buffer space */) control;
|
||||||
+ CMSG_SPACE(int) /* ttl/hoplimit */
|
|
||||||
+ EXTRA_CMSG_SPACE /* kernel appears to require extra buffer space */];
|
|
||||||
} control;
|
|
||||||
union sockaddr_union sa;
|
union sockaddr_union sa;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
@ -930,10 +927,8 @@ static int manager_ipv4_send(
|
|||||||
uint16_t port,
|
uint16_t port,
|
||||||
const struct in_addr *source,
|
const struct in_addr *source,
|
||||||
DnsPacket *p) {
|
DnsPacket *p) {
|
||||||
union {
|
|
||||||
struct cmsghdr header; /* For alignment */
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct in_pktinfo))) control = {};
|
||||||
uint8_t buffer[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
|
||||||
} control = {};
|
|
||||||
union sockaddr_union sa;
|
union sockaddr_union sa;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
@ -988,10 +983,7 @@ static int manager_ipv6_send(
|
|||||||
const struct in6_addr *source,
|
const struct in6_addr *source,
|
||||||
DnsPacket *p) {
|
DnsPacket *p) {
|
||||||
|
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct in6_pktinfo))) control = {};
|
||||||
struct cmsghdr header; /* For alignment */
|
|
||||||
uint8_t buffer[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
|
||||||
} control = {};
|
|
||||||
union sockaddr_union sa;
|
union sockaddr_union sa;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct msghdr mh = {
|
struct msghdr mh = {
|
||||||
|
@ -859,13 +859,10 @@ int ask_password_agent(
|
|||||||
pollfd[FD_INOTIFY].events = POLLIN;
|
pollfd[FD_INOTIFY].events = POLLIN;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
char passphrase[LINE_MAX+1];
|
char passphrase[LINE_MAX+1];
|
||||||
struct iovec iovec;
|
struct iovec iovec;
|
||||||
struct ucred *ucred;
|
struct ucred *ucred;
|
||||||
union {
|
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
|
||||||
} control;
|
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
int k;
|
int k;
|
||||||
usec_t t;
|
usec_t t;
|
||||||
@ -917,7 +914,6 @@ int ask_password_agent(
|
|||||||
|
|
||||||
iovec = IOVEC_MAKE(passphrase, sizeof(passphrase));
|
iovec = IOVEC_MAKE(passphrase, sizeof(passphrase));
|
||||||
|
|
||||||
zero(control);
|
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
|
@ -407,10 +407,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
|
|||||||
.iov_base = &ntpmsg,
|
.iov_base = &ntpmsg,
|
||||||
.iov_len = sizeof(ntpmsg),
|
.iov_len = sizeof(ntpmsg),
|
||||||
};
|
};
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct timeval))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct timeval))];
|
|
||||||
} control;
|
|
||||||
union sockaddr_union server_addr;
|
union sockaddr_union server_addr;
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
|
@ -189,12 +189,12 @@ static int udev_ctrl_connection_event_handler(sd_event_source *s, int fd, uint32
|
|||||||
_cleanup_(udev_ctrl_disconnect_and_listen_againp) struct udev_ctrl *uctrl = NULL;
|
_cleanup_(udev_ctrl_disconnect_and_listen_againp) struct udev_ctrl *uctrl = NULL;
|
||||||
struct udev_ctrl_msg_wire msg_wire;
|
struct udev_ctrl_msg_wire msg_wire;
|
||||||
struct iovec iov = IOVEC_MAKE(&msg_wire, sizeof(struct udev_ctrl_msg_wire));
|
struct iovec iov = IOVEC_MAKE(&msg_wire, sizeof(struct udev_ctrl_msg_wire));
|
||||||
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
struct msghdr smsg = {
|
struct msghdr smsg = {
|
||||||
.msg_iov = &iov,
|
.msg_iov = &iov,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
.msg_control = cred_msg,
|
.msg_control = &control,
|
||||||
.msg_controllen = sizeof(cred_msg),
|
.msg_controllen = sizeof(control),
|
||||||
};
|
};
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
struct ucred *cred;
|
struct ucred *cred;
|
||||||
|
@ -906,10 +906,7 @@ static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
|||||||
.iov_base = &msg,
|
.iov_base = &msg,
|
||||||
.iov_len = sizeof(msg),
|
.iov_len = sizeof(msg),
|
||||||
};
|
};
|
||||||
union {
|
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||||
struct cmsghdr cmsghdr;
|
|
||||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
|
||||||
} control = {};
|
|
||||||
struct msghdr msghdr = {
|
struct msghdr msghdr = {
|
||||||
.msg_iov = &iovec,
|
.msg_iov = &iovec,
|
||||||
.msg_iovlen = 1,
|
.msg_iovlen = 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user