/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-***/
#include <endian.h>
#include <poll.h>
#include "missing.h"
#include "path-util.h"
#include "process-util.h"
+#include "rlimit-util.h"
#include "selinux-util.h"
#include "signal-util.h"
#include "stdio-util.h"
size -= i->iov_len;
- i->iov_base = NULL;
- i->iov_len = 0;
+ *i = IOVEC_MAKE(NULL, 0);
(*idx)++;
}
assert(p);
assert(sz > 0);
- m->iovec[m->n_iovec].iov_base = (void*) p;
- m->iovec[m->n_iovec].iov_len = sz;
- m->n_iovec++;
+ m->iovec[m->n_iovec++] = IOVEC_MAKE((void*) p, sz);
return 0;
}
}
static bool line_begins(const char *s, size_t m, const char *word) {
- size_t l;
-
- l = strlen(word);
- if (m < l)
- return false;
-
- if (memcmp(s, word, l) != 0)
- return false;
+ const char *p;
- return m == l || (m > l && s[l] == ' ');
+ p = memory_startswith(s, m, word);
+ return p && (p == (s + m) || *p == ' ');
}
static int verify_anonymous_token(sd_bus *b, const char *p, size_t l) {
b->rbuffer = p;
- iov.iov_base = (uint8_t*) b->rbuffer + b->rbuffer_size;
- iov.iov_len = n - b->rbuffer_size;
+ iov = IOVEC_MAKE((uint8_t *)b->rbuffer + b->rbuffer_size, n - b->rbuffer_size);
if (b->prefer_readv)
k = readv(b->input_fd, &iov, 1);
mh.msg_control = &control;
mh.msg_controllen = sizeof(control);
- k = recvmsg(b->input_fd, &mh, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC);
+ k = recvmsg(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k < 0 && errno == ENOTSOCK) {
b->prefer_readv = true;
k = readv(b->input_fd, &iov, 1);
else
auth_suffix = "\r\nBEGIN\r\n";
- b->auth_iovec[0].iov_base = (void*) auth_prefix;
- b->auth_iovec[0].iov_len = 1 + strlen(auth_prefix + 1);
- b->auth_iovec[1].iov_base = (void*) b->auth_buffer;
- b->auth_iovec[1].iov_len = l * 2;
- b->auth_iovec[2].iov_base = (void*) auth_suffix;
- b->auth_iovec[2].iov_len = strlen(auth_suffix);
+ b->auth_iovec[0] = IOVEC_MAKE((void*) auth_prefix, 1 + strlen(auth_prefix + 1));
+ b->auth_iovec[1] = IOVEC_MAKE(b->auth_buffer, l * 2);
+ b->auth_iovec[2] = IOVEC_MAKE_STRING(auth_suffix);
return bus_socket_write_auth(b);
}
if (rearrange_stdio(s[1], s[1], STDERR_FILENO) < 0)
_exit(EXIT_FAILURE);
+ (void) rlimit_nofile_safe();
+
if (b->exec_argv)
execvp(b->exec_path, b->exec_argv);
else {
return r;
n = m->n_iovec * sizeof(struct iovec);
- iov = alloca(n);
+ iov = newa(struct iovec, n);
memcpy_safe(iov, m->iovec, n);
j = 0;
bus->rbuffer = b;
- iov.iov_base = (uint8_t*) bus->rbuffer + bus->rbuffer_size;
- iov.iov_len = need - bus->rbuffer_size;
+ iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
if (bus->prefer_readv)
k = readv(bus->input_fd, &iov, 1);
mh.msg_control = &control;
mh.msg_controllen = sizeof(control);
- k = recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC);
+ k = recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k < 0 && errno == ENOTSOCK) {
bus->prefer_readv = true;
k = readv(bus->input_fd, &iov, 1);