mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
commit
81183d9b99
@ -35,16 +35,14 @@ static bool arg_inetd = false;
|
|||||||
|
|
||||||
static int add_epoll(int epoll_fd, int fd) {
|
static int add_epoll(int epoll_fd, int fd) {
|
||||||
struct epoll_event ev = {
|
struct epoll_event ev = {
|
||||||
.events = EPOLLIN
|
.events = EPOLLIN,
|
||||||
|
.data.fd = fd,
|
||||||
};
|
};
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(epoll_fd >= 0);
|
assert(epoll_fd >= 0);
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
|
|
||||||
ev.data.fd = fd;
|
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0)
|
||||||
r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev);
|
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
|
return log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -188,14 +186,13 @@ static int exec_process(const char* name, char **argv, char **env, int start_fd,
|
|||||||
|
|
||||||
r = rearrange_stdio(start_fd, start_fd, STDERR_FILENO); /* invalidates start_fd on success + error */
|
r = rearrange_stdio(start_fd, start_fd, STDERR_FILENO); /* invalidates start_fd on success + error */
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(errno, "Failed to move fd to stdin+stdout: %m");
|
return log_error_errno(r, "Failed to move fd to stdin+stdout: %m");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (start_fd != SD_LISTEN_FDS_START) {
|
if (start_fd != SD_LISTEN_FDS_START) {
|
||||||
assert(n_fds == 1);
|
assert(n_fds == 1);
|
||||||
|
|
||||||
r = dup2(start_fd, SD_LISTEN_FDS_START);
|
if (dup2(start_fd, SD_LISTEN_FDS_START) < 0)
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(errno, "Failed to dup connection: %m");
|
return log_error_errno(errno, "Failed to dup connection: %m");
|
||||||
|
|
||||||
safe_close(start_fd);
|
safe_close(start_fd);
|
||||||
@ -312,10 +309,7 @@ static int install_chld_handler(void) {
|
|||||||
.sa_handler = sigchld_hdl,
|
.sa_handler = sigchld_hdl,
|
||||||
};
|
};
|
||||||
|
|
||||||
int r;
|
if (sigaction(SIGCHLD, &act, 0) < 0)
|
||||||
|
|
||||||
r = sigaction(SIGCHLD, &act, 0);
|
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
|
return log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -490,8 +484,7 @@ int main(int argc, char **argv, char **envp) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
struct epoll_event event;
|
struct epoll_event event;
|
||||||
|
|
||||||
r = epoll_wait(epoll_fd, &event, 1, -1);
|
if (epoll_wait(epoll_fd, &event, 1, -1) < 0) {
|
||||||
if (r < 0) {
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -82,10 +82,9 @@ bool use_audit(void) {
|
|||||||
fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
|
fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
cached_use = !IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT, EPERM);
|
cached_use = !IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT, EPERM);
|
||||||
if (errno == EPERM)
|
if (!cached_use)
|
||||||
log_debug_errno(errno, "Audit access prohibited, won't talk to audit");
|
log_debug_errno(errno, "Won't talk to audit: %m");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cached_use = true;
|
cached_use = true;
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
|
|||||||
if (prctl(PR_SET_KEEPCAPS, 1) < 0)
|
if (prctl(PR_SET_KEEPCAPS, 1) < 0)
|
||||||
return log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
|
return log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
|
||||||
|
|
||||||
r = setresuid(uid, uid, uid);
|
if (setresuid(uid, uid, uid) < 0)
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(errno, "Failed to change user ID: %m");
|
return log_error_errno(errno, "Failed to change user ID: %m");
|
||||||
|
|
||||||
if (prctl(PR_SET_KEEPCAPS, 0) < 0)
|
if (prctl(PR_SET_KEEPCAPS, 0) < 0)
|
||||||
|
@ -686,9 +686,8 @@ int log_internalv_realm(
|
|||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]))
|
if (_likely_(LOG_PRI(level) > log_max_level[realm]))
|
||||||
return -error;
|
return -error;
|
||||||
|
|
||||||
/* Make sure that %m maps to the specified error */
|
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||||
if (error != 0)
|
errno = error;
|
||||||
errno = error;
|
|
||||||
|
|
||||||
(void) vsnprintf(buffer, sizeof buffer, format, ap);
|
(void) vsnprintf(buffer, sizeof buffer, format, ap);
|
||||||
|
|
||||||
|
@ -428,8 +428,7 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f
|
|||||||
|
|
||||||
(void) fsync_directory_of_file(fd_to);
|
(void) fsync_directory_of_file(fd_to);
|
||||||
|
|
||||||
r = renameat(AT_FDCWD, t, AT_FDCWD, to);
|
if (renameat(AT_FDCWD, t, AT_FDCWD, to) < 0) {
|
||||||
if (r < 0) {
|
|
||||||
(void) unlink_noerrno(t);
|
(void) unlink_noerrno(t);
|
||||||
return log_error_errno(errno, "Failed to rename \"%s\" to \"%s\": %m", t, to);
|
return log_error_errno(errno, "Failed to rename \"%s\" to \"%s\": %m", t, to);
|
||||||
}
|
}
|
||||||
|
@ -691,13 +691,14 @@ int bpf_firewall_supported(void) {
|
|||||||
1,
|
1,
|
||||||
BPF_F_NO_PREALLOC);
|
BPF_F_NO_PREALLOC);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
log_debug_errno(r, "Can't allocate BPF LPM TRIE map, BPF firewalling is not supported: %m");
|
log_debug_errno(fd, "Can't allocate BPF LPM TRIE map, BPF firewalling is not supported: %m");
|
||||||
return supported = BPF_FIREWALL_UNSUPPORTED;
|
return supported = BPF_FIREWALL_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
|
|
||||||
if (bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &program) < 0) {
|
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &program);
|
||||||
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Can't allocate CGROUP SKB BPF program, BPF firewalling is not supported: %m");
|
log_debug_errno(r, "Can't allocate CGROUP SKB BPF program, BPF firewalling is not supported: %m");
|
||||||
return supported = BPF_FIREWALL_UNSUPPORTED;
|
return supported = BPF_FIREWALL_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
@ -728,8 +729,7 @@ int bpf_firewall_supported(void) {
|
|||||||
.attach_bpf_fd = -1,
|
.attach_bpf_fd = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
r = bpf(BPF_PROG_ATTACH, &attr, sizeof(attr));
|
if (bpf(BPF_PROG_ATTACH, &attr, sizeof(attr)) < 0) {
|
||||||
if (r < 0) {
|
|
||||||
if (errno != EBADF) {
|
if (errno != EBADF) {
|
||||||
log_debug_errno(errno, "Didn't get EBADF from BPF_PROG_ATTACH, BPF firewalling is not supported: %m");
|
log_debug_errno(errno, "Didn't get EBADF from BPF_PROG_ATTACH, BPF firewalling is not supported: %m");
|
||||||
return supported = BPF_FIREWALL_UNSUPPORTED;
|
return supported = BPF_FIREWALL_UNSUPPORTED;
|
||||||
@ -753,8 +753,7 @@ int bpf_firewall_supported(void) {
|
|||||||
.attach_flags = BPF_F_ALLOW_MULTI,
|
.attach_flags = BPF_F_ALLOW_MULTI,
|
||||||
};
|
};
|
||||||
|
|
||||||
r = bpf(BPF_PROG_ATTACH, &attr, sizeof(attr));
|
if (bpf(BPF_PROG_ATTACH, &attr, sizeof(attr)) < 0) {
|
||||||
if (r < 0) {
|
|
||||||
if (errno == EBADF) {
|
if (errno == EBADF) {
|
||||||
log_debug_errno(errno, "Got EBADF when using BPF_F_ALLOW_MULTI, which indicates it is supported. Yay!");
|
log_debug_errno(errno, "Got EBADF when using BPF_F_ALLOW_MULTI, which indicates it is supported. Yay!");
|
||||||
return supported = BPF_FIREWALL_SUPPORTED_WITH_MULTI;
|
return supported = BPF_FIREWALL_SUPPORTED_WITH_MULTI;
|
||||||
|
@ -308,13 +308,11 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
|
|||||||
|
|
||||||
static int lookup_block_device(const char *p, dev_t *dev) {
|
static int lookup_block_device(const char *p, dev_t *dev) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(p);
|
assert(p);
|
||||||
assert(dev);
|
assert(dev);
|
||||||
|
|
||||||
r = stat(p, &st);
|
if (stat(p, &st) < 0)
|
||||||
if (r < 0)
|
|
||||||
return log_warning_errno(errno, "Couldn't stat device %s: %m", p);
|
return log_warning_errno(errno, "Couldn't stat device %s: %m", p);
|
||||||
|
|
||||||
if (S_ISBLK(st.st_mode))
|
if (S_ISBLK(st.st_mode))
|
||||||
|
@ -782,8 +782,8 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|||||||
if (revents != EPOLLIN) {
|
if (revents != EPOLLIN) {
|
||||||
static RATELIMIT_DEFINE(limit, 10*USEC_PER_SEC, 5);
|
static RATELIMIT_DEFINE(limit, 10*USEC_PER_SEC, 5);
|
||||||
|
|
||||||
if (!ratelimit_test(&limit))
|
if (ratelimit_test(&limit))
|
||||||
log_error_errno(errno, "Failed to get udev event: %m");
|
log_warning("Failed to get udev event");
|
||||||
if (!(revents & EPOLLIN))
|
if (!(revents & EPOLLIN))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -402,15 +402,15 @@ static int neighbor_compare_func(const void *a, const void *b) {
|
|||||||
|
|
||||||
static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||||
sd_lldp *lldp = userdata;
|
sd_lldp *lldp = userdata;
|
||||||
int r, q;
|
int r;
|
||||||
|
|
||||||
r = lldp_make_space(lldp, 0);
|
r = lldp_make_space(lldp, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_lldp_errno(r, "Failed to make space: %m");
|
return log_lldp_errno(r, "Failed to make space: %m");
|
||||||
|
|
||||||
q = lldp_start_timer(lldp, NULL);
|
r = lldp_start_timer(lldp, NULL);
|
||||||
if (q < 0)
|
if (r < 0)
|
||||||
return log_lldp_errno(q, "Failed to restart timer: %m");
|
return log_lldp_errno(r, "Failed to restart timer: %m");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1971,8 +1971,6 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_ar
|
|||||||
if (q < 0 && r == 0)
|
if (q < 0 && r == 0)
|
||||||
r = q;
|
r = q;
|
||||||
|
|
||||||
errno = 0; /* Reset errno explicitly, so that log_debug_errno() will properly print 'Success'
|
|
||||||
* for q == 0, instead of whatever is set in errno */
|
|
||||||
log_debug_errno(q, "Got result %s/%m for job %s", strna(d->result), strna(d->name));
|
log_debug_errno(q, "Got result %s/%m for job %s", strna(d->result), strna(d->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user