summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/basic/btrfs-util.c43
-rw-r--r--src/basic/btrfs-util.h1
-rw-r--r--src/basic/copy.c2
-rw-r--r--src/basic/signal-util.c6
-rw-r--r--src/basic/signal-util.h2
-rw-r--r--src/basic/util.c41
-rw-r--r--src/basic/util.h6
-rw-r--r--src/console/consoled-manager.c2
-rw-r--r--src/core/execute.c8
-rw-r--r--src/import/export-raw.c2
-rw-r--r--src/import/export-tar.c2
-rw-r--r--src/import/export.c12
-rw-r--r--src/import/import-raw.c4
-rw-r--r--src/import/import-tar.c2
-rw-r--r--src/import/import.c12
-rw-r--r--src/import/importd.c2
-rw-r--r--src/import/pull-dkr.c2
-rw-r--r--src/import/pull-raw.c6
-rw-r--r--src/import/pull-tar.c2
-rw-r--r--src/import/pull.c18
-rw-r--r--src/journal-remote/journal-remote.c5
-rw-r--r--src/journal-remote/journal-upload.c5
-rw-r--r--src/journal/coredump.c4
-rw-r--r--src/journal/journald-server.c5
-rw-r--r--src/libsystemd-terminal/evcat.c2
-rw-r--r--src/libsystemd-terminal/modeset.c2
-rw-r--r--src/libsystemd-terminal/subterm.c2
-rw-r--r--src/libsystemd/sd-bus/bus-message.c6
-rw-r--r--src/libsystemd/sd-event/test-event.c13
-rw-r--r--src/locale/localectl.c35
-rw-r--r--src/login/loginctl.c105
-rw-r--r--src/login/logind-button.c2
-rw-r--r--src/login/logind-core.c2
-rw-r--r--src/login/logind-dbus.c21
-rw-r--r--src/login/logind-inhibit.c2
-rw-r--r--src/login/logind-seat.c2
-rw-r--r--src/login/logind-session-dbus.c2
-rw-r--r--src/login/logind-user-dbus.c2
-rw-r--r--src/login/logind-user.c5
-rw-r--r--src/login/logind.c9
-rw-r--r--src/machine/machinectl.c52
-rw-r--r--src/machine/machined.c2
-rw-r--r--src/network/networkd-address.c2
-rw-r--r--src/network/networkd-wait-online.c2
-rw-r--r--src/network/networkd.c2
-rw-r--r--src/nspawn/nspawn.c23
-rw-r--r--src/resolve/resolved.c2
-rw-r--r--src/run/run.c9
-rw-r--r--src/shared/ask-password-api.c6
-rw-r--r--src/shared/firewall-util.c (renamed from src/shared/fw-util.c)2
-rw-r--r--src/shared/firewall-util.h (renamed from src/shared/fw-util.h)0
-rw-r--r--src/shared/machine-pool.c2
-rw-r--r--src/systemctl/systemctl.c25
-rw-r--r--src/test/test-firewall-util.c (renamed from src/test/test-fw-util.c)2
-rw-r--r--src/test/test-netlink-manual.c2
-rw-r--r--src/test/test-pty.c2
-rw-r--r--src/test/test-udev.c2
-rw-r--r--src/test/test-util.c37
-rw-r--r--src/timedate/timedatectl.c17
-rw-r--r--src/timesync/timesyncd.c2
-rw-r--r--src/tmpfiles/tmpfiles.c2
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c6
-rw-r--r--src/udev/udev-event.c25
-rw-r--r--src/udev/udev-rules.c4
-rw-r--r--src/udev/udev.h1
-rw-r--r--src/udev/udevd.c2
66 files changed, 390 insertions, 249 deletions
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c
index 49528dbf01..074deeccda 100644
--- a/src/basic/btrfs-util.c
+++ b/src/basic/btrfs-util.c
@@ -352,6 +352,19 @@ int btrfs_subvol_get_id_fd(int fd, uint64_t *ret) {
return 0;
}
+int btrfs_subvol_get_id(int fd, const char *subvol, uint64_t *ret) {
+ _cleanup_close_ int subvol_fd = -1;
+
+ assert(fd >= 0);
+ assert(ret);
+
+ subvol_fd = openat(fd, subvol, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
+ if (subvol_fd < 0)
+ return -errno;
+
+ return btrfs_subvol_get_id_fd(subvol_fd, ret);
+}
+
static bool btrfs_ioctl_search_args_inc(struct btrfs_ioctl_search_args *args) {
assert(args);
@@ -937,7 +950,7 @@ int btrfs_subvol_remove_fd(int fd, const char *subvolume, bool recursive) {
return subvol_remove_children(fd, subvolume, 0, recursive);
}
-static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolume, uint64_t subvol_id, BtrfsSnapshotFlags flags) {
+static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolume, uint64_t old_subvol_id, BtrfsSnapshotFlags flags) {
struct btrfs_ioctl_search_args args = {
.key.tree_id = BTRFS_ROOT_TREE_OBJECTID,
@@ -956,8 +969,9 @@ static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolum
.flags = flags & BTRFS_SNAPSHOT_READ_ONLY ? BTRFS_SUBVOL_RDONLY : 0,
.fd = old_fd,
};
- int r;
_cleanup_close_ int subvolume_fd = -1;
+ uint64_t new_subvol_id;
+ int r;
assert(old_fd >= 0);
assert(new_fd >= 0);
@@ -972,13 +986,17 @@ static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolum
if (!(flags & BTRFS_SNAPSHOT_RECURSIVE))
return 0;
- if (subvol_id == 0) {
- r = btrfs_subvol_get_id_fd(old_fd, &subvol_id);
+ if (old_subvol_id == 0) {
+ r = btrfs_subvol_get_id_fd(old_fd, &old_subvol_id);
if (r < 0)
return r;
}
- args.key.min_offset = args.key.max_offset = subvol_id;
+ r = btrfs_subvol_get_id(new_fd, vol_args.name, &new_subvol_id);
+ if (r < 0)
+ return r;
+
+ args.key.min_offset = args.key.max_offset = old_subvol_id;
while (btrfs_ioctl_search_args_compare(&args) <= 0) {
const struct btrfs_ioctl_search_header *sh;
@@ -1001,17 +1019,24 @@ static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolum
if (sh->type != BTRFS_ROOT_BACKREF_KEY)
continue;
- if (sh->offset != subvol_id)
+
+ /* Avoid finding the source subvolume a second
+ * time */
+ if (sh->offset != old_subvol_id)
continue;
- ref = BTRFS_IOCTL_SEARCH_HEADER_BODY(sh);
+ /* Avoid running into loops if the new
+ * subvolume is below the old one. */
+ if (sh->objectid == new_subvol_id)
+ continue;
+ ref = BTRFS_IOCTL_SEARCH_HEADER_BODY(sh);
p = strndup((char*) ref + sizeof(struct btrfs_root_ref), le64toh(ref->name_len));
if (!p)
return -ENOMEM;
zero(ino_args);
- ino_args.treeid = subvol_id;
+ ino_args.treeid = old_subvol_id;
ino_args.objectid = htole64(ref->dirid);
if (ioctl(old_fd, BTRFS_IOC_INO_LOOKUP, &ino_args) < 0)
@@ -1056,7 +1081,7 @@ static int subvol_snapshot_children(int old_fd, int new_fd, const char *subvolum
}
/* When btrfs clones the subvolumes, child
- * subvolumes appear as directories. Remove
+ * subvolumes appear as empty directories. Remove
* them, so that we can create a new snapshot
* in their place */
if (unlinkat(new_child_fd, p, AT_REMOVEDIR) < 0) {
diff --git a/src/basic/btrfs-util.h b/src/basic/btrfs-util.h
index a7eb895c93..8632c3638c 100644
--- a/src/basic/btrfs-util.h
+++ b/src/basic/btrfs-util.h
@@ -61,6 +61,7 @@ int btrfs_subvol_snapshot(const char *old_path, const char *new_path, BtrfsSnaps
int btrfs_subvol_set_read_only_fd(int fd, bool b);
int btrfs_subvol_set_read_only(const char *path, bool b);
int btrfs_subvol_get_read_only_fd(int fd);
+int btrfs_subvol_get_id(int fd, const char *subvolume, uint64_t *ret);
int btrfs_subvol_get_id_fd(int fd, uint64_t *ret);
int btrfs_subvol_get_info_fd(int fd, BtrfsSubvolInfo *info);
int btrfs_subvol_get_quota_fd(int fd, BtrfsQuotaInfo *quota);
diff --git a/src/basic/copy.c b/src/basic/copy.c
index 1282cb88be..230e7e4d3f 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -396,7 +396,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
assert(from);
assert(to);
- r = tempfn_random(to, &t);
+ r = tempfn_random(to, NULL, &t);
if (r < 0)
return r;
diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c
index 84cf42b285..90abe8af81 100644
--- a/src/basic/signal-util.c
+++ b/src/basic/signal-util.c
@@ -159,7 +159,7 @@ int sigset_add_many(sigset_t *ss, ...) {
return r;
}
-int sigprocmask_many(int how, ...) {
+int sigprocmask_many(int how, sigset_t *old, ...) {
va_list ap;
sigset_t ss;
int r;
@@ -167,14 +167,14 @@ int sigprocmask_many(int how, ...) {
if (sigemptyset(&ss) < 0)
return -errno;
- va_start(ap, how);
+ va_start(ap, old);
r = sigset_add_many_ap(&ss, ap);
va_end(ap);
if (r < 0)
return r;
- if (sigprocmask(how, &ss, NULL) < 0)
+ if (sigprocmask(how, &ss, old) < 0)
return -errno;
return 0;
diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h
index 9dc8a28726..5e6eb50b07 100644
--- a/src/basic/signal-util.h
+++ b/src/basic/signal-util.h
@@ -33,7 +33,7 @@ int default_signals(int sig, ...);
int sigaction_many(const struct sigaction *sa, ...);
int sigset_add_many(sigset_t *ss, ...);
-int sigprocmask_many(int how, ...);
+int sigprocmask_many(int how, sigset_t *old, ...);
const char *signal_to_string(int i) _const_;
int signal_from_string(const char *s) _pure_;
diff --git a/src/basic/util.c b/src/basic/util.c
index 6f6906f877..b7c70af541 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -2521,7 +2521,7 @@ int fopen_temporary(const char *path, FILE **_f, char **_temp_path) {
assert(_f);
assert(_temp_path);
- r = tempfn_xxxxxx(path, &t);
+ r = tempfn_xxxxxx(path, NULL, &t);
if (r < 0)
return r;
@@ -2551,7 +2551,7 @@ int symlink_atomic(const char *from, const char *to) {
assert(from);
assert(to);
- r = tempfn_random(to, &t);
+ r = tempfn_random(to, NULL, &t);
if (r < 0)
return r;
@@ -2594,7 +2594,7 @@ int mknod_atomic(const char *path, mode_t mode, dev_t dev) {
assert(path);
- r = tempfn_random(path, &t);
+ r = tempfn_random(path, NULL, &t);
if (r < 0)
return r;
@@ -2615,7 +2615,7 @@ int mkfifo_atomic(const char *path, mode_t mode) {
assert(path);
- r = tempfn_random(path, &t);
+ r = tempfn_random(path, NULL, &t);
if (r < 0)
return r;
@@ -4969,7 +4969,7 @@ int fflush_and_check(FILE *f) {
return 0;
}
-int tempfn_xxxxxx(const char *p, char **ret) {
+int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
const char *fn;
char *t;
@@ -4981,24 +4981,27 @@ int tempfn_xxxxxx(const char *p, char **ret) {
* /foo/bar/waldo
*
* Into this:
- * /foo/bar/.#waldoXXXXXX
+ * /foo/bar/.#<extra>waldoXXXXXX
*/
fn = basename(p);
if (!filename_is_valid(fn))
return -EINVAL;
- t = new(char, strlen(p) + 2 + 6 + 1);
+ if (extra == NULL)
+ extra = "";
+
+ t = new(char, strlen(p) + 2 + strlen(extra) + 6 + 1);
if (!t)
return -ENOMEM;
- strcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), fn), "XXXXXX");
+ strcpy(stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn), "XXXXXX");
*ret = path_kill_slashes(t);
return 0;
}
-int tempfn_random(const char *p, char **ret) {
+int tempfn_random(const char *p, const char *extra, char **ret) {
const char *fn;
char *t, *x;
uint64_t u;
@@ -5012,18 +5015,21 @@ int tempfn_random(const char *p, char **ret) {
* /foo/bar/waldo
*
* Into this:
- * /foo/bar/.#waldobaa2a261115984a9
+ * /foo/bar/.#<extra>waldobaa2a261115984a9
*/
fn = basename(p);
if (!filename_is_valid(fn))
return -EINVAL;
- t = new(char, strlen(p) + 2 + 16 + 1);
+ if (!extra)
+ extra = "";
+
+ t = new(char, strlen(p) + 2 + strlen(extra) + 16 + 1);
if (!t)
return -ENOMEM;
- x = stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), fn);
+ x = stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn);
u = random_u64();
for (i = 0; i < 16; i++) {
@@ -5037,7 +5043,7 @@ int tempfn_random(const char *p, char **ret) {
return 0;
}
-int tempfn_random_child(const char *p, char **ret) {
+int tempfn_random_child(const char *p, const char *extra, char **ret) {
char *t, *x;
uint64_t u;
unsigned i;
@@ -5048,14 +5054,17 @@ int tempfn_random_child(const char *p, char **ret) {
/* Turns this:
* /foo/bar/waldo
* Into this:
- * /foo/bar/waldo/.#3c2b6219aa75d7d0
+ * /foo/bar/waldo/.#<extra>3c2b6219aa75d7d0
*/
- t = new(char, strlen(p) + 3 + 16 + 1);
+ if (!extra)
+ extra = "";
+
+ t = new(char, strlen(p) + 3 + strlen(extra) + 16 + 1);
if (!t)
return -ENOMEM;
- x = stpcpy(stpcpy(t, p), "/.#");
+ x = stpcpy(stpcpy(stpcpy(t, p), "/.#"), extra);
u = random_u64();
for (i = 0; i < 16; i++) {
diff --git a/src/basic/util.h b/src/basic/util.h
index 467ae234a0..7aca46d777 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -828,9 +828,9 @@ int bind_remount_recursive(const char *prefix, bool ro);
int fflush_and_check(FILE *f);
-int tempfn_xxxxxx(const char *p, char **ret);
-int tempfn_random(const char *p, char **ret);
-int tempfn_random_child(const char *p, char **ret);
+int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
+int tempfn_random(const char *p, const char *extra, char **ret);
+int tempfn_random_child(const char *p, const char *extra, char **ret);
int take_password_lock(const char *root);
diff --git a/src/console/consoled-manager.c b/src/console/consoled-manager.c
index e560dcf524..20424eb267 100644
--- a/src/console/consoled-manager.c
+++ b/src/console/consoled-manager.c
@@ -51,7 +51,7 @@ int manager_new(Manager **out) {
if (r < 0)
return r;
- r = sigprocmask_many(SIG_BLOCK, SIGTERM, SIGQUIT, SIGINT, SIGWINCH, SIGCHLD, -1);
+ r = sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGQUIT, SIGINT, SIGWINCH, SIGCHLD, -1);
if (r < 0)
return r;
diff --git a/src/core/execute.c b/src/core/execute.c
index f13c6936e0..444865da86 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -824,10 +824,7 @@ static int setup_pam(
/* Block SIGTERM, so that we know that it won't get lost in
* the child */
- if (sigemptyset(&ss) < 0 ||
- sigaddset(&ss, SIGTERM) < 0 ||
- sigprocmask(SIG_BLOCK, &ss, &old_ss) < 0)
- goto fail;
+ assert_se(sigprocmask_many(SIG_BLOCK, &old_ss, SIGTERM, -1) >= 0);
parent_pid = getpid();
@@ -903,8 +900,7 @@ static int setup_pam(
handle = NULL;
/* Unblock SIGTERM again in the parent */
- if (sigprocmask(SIG_SETMASK, &old_ss, NULL) < 0)
- goto fail;
+ assert_se(sigprocmask(SIG_SETMASK, &old_ss, NULL) >= 0);
/* We close the log explicitly here, since the PAM modules
* might have opened it, but we don't want this fd around. */
diff --git a/src/import/export-raw.c b/src/import/export-raw.c
index 4b6d8dac32..8f9c9bbc80 100644
--- a/src/import/export-raw.c
+++ b/src/import/export-raw.c
@@ -265,7 +265,7 @@ static int reflink_snapshot(int fd, const char *path) {
if (new_fd < 0) {
_cleanup_free_ char *t = NULL;
- r = tempfn_random(path, &t);
+ r = tempfn_random(path, NULL, &t);
if (r < 0)
return r;
diff --git a/src/import/export-tar.c b/src/import/export-tar.c
index d31295745f..5adc748c50 100644
--- a/src/import/export-tar.c
+++ b/src/import/export-tar.c
@@ -290,7 +290,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
free(e->temp_path);
e->temp_path = NULL;
- r = tempfn_random(path, &e->temp_path);
+ r = tempfn_random(path, NULL, &e->temp_path);
if (r < 0)
return r;
diff --git a/src/import/export.c b/src/import/export.c
index e563bee96e..ec7dbe210a 100644
--- a/src/import/export.c
+++ b/src/import/export.c
@@ -118,9 +118,9 @@ static int export_tar(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = tar_export_new(&export, event, on_tar_finished, event);
if (r < 0)
@@ -197,9 +197,9 @@ static int export_raw(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = raw_export_new(&export, event, on_raw_finished, event);
if (r < 0)
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index 97e1254f09..43cd413042 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -180,7 +180,7 @@ static int raw_import_maybe_convert_qcow2(RawImport *i) {
return 0;
/* This is a QCOW2 image, let's convert it */
- r = tempfn_random(i->final_path, &t);
+ r = tempfn_random(i->final_path, NULL, &t);
if (r < 0)
return log_oom();
@@ -267,7 +267,7 @@ static int raw_import_open_disk(RawImport *i) {
if (!i->final_path)
return log_oom();
- r = tempfn_random(i->final_path, &i->temp_path);
+ r = tempfn_random(i->final_path, NULL, &i->temp_path);
if (r < 0)
return log_oom();
diff --git a/src/import/import-tar.c b/src/import/import-tar.c
index 12701bfcef..2bf0b0680c 100644
--- a/src/import/import-tar.c
+++ b/src/import/import-tar.c
@@ -223,7 +223,7 @@ static int tar_import_fork_tar(TarImport *i) {
if (!i->final_path)
return log_oom();
- r = tempfn_random(i->final_path, &i->temp_path);
+ r = tempfn_random(i->final_path, NULL, &i->temp_path);
if (r < 0)
return log_oom();
diff --git a/src/import/import.c b/src/import/import.c
index 3091ed1c45..b7772390e9 100644
--- a/src/import/import.c
+++ b/src/import/import.c
@@ -116,9 +116,9 @@ static int import_tar(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = tar_import_new(&import, event, arg_image_root, on_tar_finished, event);
if (r < 0)
@@ -211,9 +211,9 @@ static int import_raw(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = raw_import_new(&import, event, arg_image_root, on_raw_finished, event);
if (r < 0)
diff --git a/src/import/importd.c b/src/import/importd.c
index 05a619ac0c..03aede6016 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -1301,7 +1301,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
r = manager_new(&m);
if (r < 0) {
diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c
index d7476dc340..78e3184c42 100644
--- a/src/import/pull-dkr.c
+++ b/src/import/pull-dkr.c
@@ -520,7 +520,7 @@ static int dkr_pull_job_on_open_disk(PullJob *j) {
assert(!i->temp_path);
assert(i->tar_pid <= 0);
- r = tempfn_random(i->final_path, &i->temp_path);
+ r = tempfn_random(i->final_path, NULL, &i->temp_path);
if (r < 0)
return log_oom();
diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c
index b65bb0c034..5bfaf012c0 100644
--- a/src/import/pull-raw.c
+++ b/src/import/pull-raw.c
@@ -208,7 +208,7 @@ static int raw_pull_maybe_convert_qcow2(RawPull *i) {
return 0;
/* This is a QCOW2 image, let's convert it */
- r = tempfn_random(i->final_path, &t);
+ r = tempfn_random(i->final_path, NULL, &t);
if (r < 0)
return log_oom();
@@ -280,7 +280,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
if (i->force_local)
(void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME);
- r = tempfn_random(p, &tp);
+ r = tempfn_random(p, NULL, &tp);
if (r < 0)
return log_oom();
@@ -424,7 +424,7 @@ static int raw_pull_job_on_open_disk(PullJob *j) {
if (r < 0)
return log_oom();
- r = tempfn_random(i->final_path, &i->temp_path);
+ r = tempfn_random(i->final_path, NULL, &i->temp_path);
if (r < 0)
return log_oom();
diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c
index 27a9af804d..a6605d248f 100644
--- a/src/import/pull-tar.c
+++ b/src/import/pull-tar.c
@@ -324,7 +324,7 @@ static int tar_pull_job_on_open_disk(PullJob *j) {
if (r < 0)
return log_oom();
- r = tempfn_random(i->final_path, &i->temp_path);
+ r = tempfn_random(i->final_path, NULL, &i->temp_path);
if (r < 0)
return log_oom();
diff --git a/src/import/pull.c b/src/import/pull.c
index 03fe3dcaf4..ca33d2f3fa 100644
--- a/src/import/pull.c
+++ b/src/import/pull.c
@@ -109,9 +109,9 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = tar_pull_new(&pull, event, arg_image_root, on_tar_finished, event);
if (r < 0)
@@ -195,9 +195,9 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = raw_pull_new(&pull, event, arg_image_root, on_raw_finished, event);
if (r < 0)
@@ -303,9 +303,9 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
- sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
- sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, interrupt_signal_handler, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, interrupt_signal_handler, NULL);
r = dkr_pull_new(&pull, event, arg_dkr_index_url, arg_image_root, on_dkr_finished, event);
if (r < 0)
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index ae332d826f..1baedf6367 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -788,14 +788,11 @@ static int dispatch_http_event(sd_event_source *event,
**********************************************************************/
static int setup_signals(RemoteServer *s) {
- sigset_t mask;
int r;
assert(s);
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ assert_se(sigprocmask_many(SIG_SETMASK, NULL, SIGINT, SIGTERM, -1) >= 0);
r = sd_event_add_signal(s->events, &s->sigterm_event, SIGTERM, NULL, s);
if (r < 0)
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index ddb1ef0396..5d23639ee8 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -396,14 +396,11 @@ static int dispatch_sigterm(sd_event_source *event,
}
static int setup_signals(Uploader *u) {
- sigset_t mask;
int r;
assert(u);
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ assert_se(sigprocmask_many(SIG_SETMASK, NULL, SIGINT, SIGTERM, -1) >= 0);
r = sd_event_add_signal(u->events, &u->sigterm_event, SIGTERM, dispatch_sigterm, u);
if (r < 0)
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 1c747aa2b4..62483a2a05 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -301,7 +301,7 @@ static int save_external_coredump(
if (r < 0)
return log_error_errno(r, "Failed to determine coredump file name: %m");
- r = tempfn_random(fn, &tmp);
+ r = tempfn_random(fn, NULL, &tmp);
if (r < 0)
return log_error_errno(r, "Failed to determine temporary file name: %m");
@@ -347,7 +347,7 @@ static int save_external_coredump(
goto uncompressed;
}
- r = tempfn_random(fn_compressed, &tmp_compressed);
+ r = tempfn_random(fn_compressed, NULL, &tmp_compressed);
if (r < 0) {
log_error_errno(r, "Failed to determine temporary file name for %s: %m", fn_compressed);
goto uncompressed;
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index d0d670f36e..f7402984af 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1264,14 +1264,11 @@ static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *
}
static int setup_signals(Server *s) {
- sigset_t mask;
int r;
assert(s);
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ assert(sigprocmask_many(SIG_SETMASK, NULL, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1) >= 0);
r = sd_event_add_signal(s->event, &s->sigusr1_event_source, SIGUSR1, dispatch_sigusr1, s);
if (r < 0)
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index bfa166c489..2aeefc2e16 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -154,7 +154,7 @@ static int evcat_new(Evcat **out) {
if (r < 0)
return r;
- r = sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
+ r = sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1);
if (r < 0)
return r;
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
index f3a60e1fb0..790a244772 100644
--- a/src/libsystemd-terminal/modeset.c
+++ b/src/libsystemd-terminal/modeset.c
@@ -170,7 +170,7 @@ static int modeset_new(Modeset **out) {
if (r < 0)
return r;
- r = sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
+ r = sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1);
if (r < 0)
return r;
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
index d10e2f549f..5f12540111 100644
--- a/src/libsystemd-terminal/subterm.c
+++ b/src/libsystemd-terminal/subterm.c
@@ -856,7 +856,7 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
goto error;
}
- r = sigprocmask_many(SIG_BLOCK, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
+ r = sigprocmask_many(SIG_BLOCK, NULL, SIGINT, SIGQUIT, SIGTERM, SIGWINCH, SIGCHLD, -1);
if (r < 0) {
log_error_errno(r, "error: sigprocmask_many() (%d): %m", r);
goto error;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index c38b2a5fa5..983e2f62cd 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -803,7 +803,7 @@ _public_ int sd_bus_message_new_method_errorf(
const char *format,
...) {
- _cleanup_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
va_list ap;
assert_return(name, -EINVAL);
@@ -822,7 +822,7 @@ _public_ int sd_bus_message_new_method_errno(
int error,
const sd_bus_error *p) {
- _cleanup_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
+ _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
if (sd_bus_error_is_set(p))
return sd_bus_message_new_method_error(call, m, p);
@@ -839,7 +839,7 @@ _public_ int sd_bus_message_new_method_errnof(
const char *format,
...) {
- _cleanup_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
+ _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
va_list ap;
va_start(ap, format);
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index 94e98e0077..408e1679a2 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -79,7 +79,6 @@ static int child_handler(sd_event_source *s, const siginfo_t *si, void *userdata
static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
sd_event_source *p = NULL;
- sigset_t ss;
pid_t pid;
assert_se(s);
@@ -89,9 +88,7 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
assert_se(userdata == INT_TO_PTR('e'));
- assert_se(sigemptyset(&ss) >= 0);
- assert_se(sigaddset(&ss, SIGCHLD) >= 0);
- assert_se(sigprocmask(SIG_BLOCK, &ss, NULL) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
pid = fork();
assert_se(pid >= 0);
@@ -109,7 +106,6 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
static int defer_handler(sd_event_source *s, void *userdata) {
sd_event_source *p = NULL;
- sigset_t ss;
assert_se(s);
@@ -117,9 +113,8 @@ static int defer_handler(sd_event_source *s, void *userdata) {
assert_se(userdata == INT_TO_PTR('d'));
- assert_se(sigemptyset(&ss) >= 0);
- assert_se(sigaddset(&ss, SIGUSR1) >= 0);
- assert_se(sigprocmask(SIG_BLOCK, &ss, NULL) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGUSR1, -1) >= 0);
+
assert_se(sd_event_add_signal(sd_event_source_get_event(s), &p, SIGUSR1, signal_handler, INT_TO_PTR('e')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
raise(SIGUSR1);
@@ -209,7 +204,7 @@ int main(int argc, char *argv[]) {
assert_se(sd_event_source_set_prepare(z, prepare_handler) >= 0);
/* Test for floating event sources */
- assert_se(sigprocmask_many(SIG_BLOCK, SIGRTMIN+1, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGRTMIN+1, -1) >= 0);
assert_se(sd_event_add_signal(e, NULL, SIGRTMIN+1, NULL, NULL) >= 0);
assert_se(write(a[1], &ch, 1) >= 0);
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 8c60339e3e..601839d5dc 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -69,14 +69,27 @@ static void polkit_agent_open_if_enabled(void) {
typedef struct StatusInfo {
char **locale;
- const char *vconsole_keymap;
- const char *vconsole_keymap_toggle;
- const char *x11_layout;
- const char *x11_model;
- const char *x11_variant;
- const char *x11_options;
+ char *vconsole_keymap;
+ char *vconsole_keymap_toggle;
+ char *x11_layout;
+ char *x11_model;
+ char *x11_variant;
+ char *x11_options;
} StatusInfo;
+static void status_info_clear(StatusInfo *info) {
+ if (info) {
+ strv_free(info->locale);
+ free(info->vconsole_keymap);
+ free(info->vconsole_keymap_toggle);
+ free(info->x11_layout);
+ free(info->x11_model);
+ free(info->x11_variant);
+ free(info->x11_options);
+ zero(*info);
+ }
+}
+
static void print_overridden_variables(void) {
int r;
char *variables[_VARIABLE_LC_MAX] = {};
@@ -150,7 +163,7 @@ static void print_status_info(StatusInfo *i) {
}
static int show_status(sd_bus *bus, char **args, unsigned n) {
- StatusInfo info = {};
+ _cleanup_(status_info_clear) StatusInfo info = {};
static const struct bus_properties_map map[] = {
{ "VConsoleKeymap", "s", NULL, offsetof(StatusInfo, vconsole_keymap) },
{ "VConsoleKeymap", "s", NULL, offsetof(StatusInfo, vconsole_keymap) },
@@ -171,16 +184,12 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
"/org/freedesktop/locale1",
map,
&info);
- if (r < 0) {
- log_error_errno(r, "Could not get properties: %m");
- goto fail;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not get properties: %m");
print_overridden_variables();
print_status_info(&info);
-fail:
- strv_free(info.locale);
return r;
}
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 02d240c704..06208bc4b3 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -277,42 +277,81 @@ static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit
}
typedef struct SessionStatusInfo {
- const char *id;
+ char *id;
uid_t uid;
- const char *name;
+ char *name;
struct dual_timestamp timestamp;
unsigned int vtnr;
- const char *seat;
- const char *tty;
- const char *display;
+ char *seat;
+ char *tty;
+ char *display;
bool remote;
- const char *remote_host;
- const char *remote_user;
- const char *service;
+ char *remote_host;
+ char *remote_user;
+ char *service;
pid_t leader;
- const char *type;
- const char *class;
- const char *state;
- const char *scope;
- const char *desktop;
+ char *type;
+ char *class;
+ char *state;
+ char *scope;
+ char *desktop;
} SessionStatusInfo;
typedef struct UserStatusInfo {
uid_t uid;
- const char *name;
+ char *name;
struct dual_timestamp timestamp;
- const char *state;
+ char *state;
char **sessions;
- const char *display;
- const char *slice;
+ char *display;
+ char *slice;
} UserStatusInfo;
typedef struct SeatStatusInfo {
- const char *id;
- const char *active_session;
+ char *id;
+ char *active_session;
char **sessions;
} SeatStatusInfo;
+static void session_status_info_clear(SessionStatusInfo *info) {
+ if (info) {
+ free(info->id);
+ free(info->name);
+ free(info->seat);
+ free(info->tty);
+ free(info->display);
+ free(info->remote_host);
+ free(info->remote_user);
+ free(info->service);
+ free(info->type);
+ free(info->class);
+ free(info->state);
+ free(info->scope);
+ free(info->desktop);
+ zero(*info);
+ }
+}
+
+static void user_status_info_clear(UserStatusInfo *info) {
+ if (info) {
+ free(info->name);
+ free(info->state);
+ strv_free(info->sessions);
+ free(info->display);
+ free(info->slice);
+ zero(*info);
+ }
+}
+
+static void seat_status_info_clear(SeatStatusInfo *info) {
+ if (info) {
+ free(info->id);
+ free(info->active_session);
+ strv_free(info->sessions);
+ zero(*info);
+ }
+}
+
static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
const char *contents;
int r;
@@ -404,7 +443,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
- SessionStatusInfo i = {};
+ _cleanup_(session_status_info_clear) SessionStatusInfo i = {};
int r;
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
@@ -532,14 +571,12 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line)
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
- UserStatusInfo i = {};
+ _cleanup_(user_status_info_clear) UserStatusInfo i = {};
int r;
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
- if (r < 0) {
- log_error_errno(r, "Could not get properties: %m");
- goto finish;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not get properties: %m");
if (*new_line)
printf("\n");
@@ -594,10 +631,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line)
NULL);
}
-finish:
- strv_free(i.sessions);
-
- return r;
+ return 0;
}
static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line) {
@@ -609,14 +643,12 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
{}
};
- SeatStatusInfo i = {};
+ _cleanup_(seat_status_info_clear) SeatStatusInfo i = {};
int r;
r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i);
- if (r < 0) {
- log_error_errno(r, "Could not get properties: %m");
- goto finish;
- }
+ if (r < 0)
+ return log_error_errno(r, "Could not get properties: %m");
if (*new_line)
printf("\n");
@@ -653,10 +685,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
show_sysfs(i.id, "\t\t ", c);
}
-finish:
- strv_free(i.sessions);
-
- return r;
+ return 0;
}
static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 610adc513e..8079d0b5aa 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -70,7 +70,7 @@ void button_free(Button *b) {
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
- close(b->fd);
+ (void) close(b->fd);
}
free(b->name);
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 440c32aa2c..f9e6ddfb3f 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -360,7 +360,7 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **user) {
int manager_get_idle_hint(Manager *m, dual_timestamp *t) {
Session *s;
bool idle_hint;
- dual_timestamp ts = { 0, 0 };
+ dual_timestamp ts = DUAL_TIMESTAMP_NULL;
Iterator i;
assert(m);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index b272401e5b..e6f9ec7845 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -158,7 +158,7 @@ static int property_get_idle_since_hint(
sd_bus_error *error) {
Manager *m = userdata;
- dual_timestamp t;
+ dual_timestamp t = DUAL_TIMESTAMP_NULL;
assert(bus);
assert(reply);
@@ -243,6 +243,24 @@ static int property_get_scheduled_shutdown(
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_handle_action, handle_action, HandleAction);
+static int property_get_docked(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ Manager *m = userdata;
+
+ assert(bus);
+ assert(reply);
+ assert(m);
+
+ return sd_bus_message_append(reply, "b", manager_is_docked_or_multiple_displays(m));
+}
+
static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
@@ -2406,6 +2424,7 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("PreparingForShutdown", "b", property_get_preparing, 0, 0),
SD_BUS_PROPERTY("PreparingForSleep", "b", property_get_preparing, 0, 0),
SD_BUS_PROPERTY("ScheduledShutdown", "(st)", property_get_scheduled_shutdown, 0, 0),
+ SD_BUS_PROPERTY("Docked", "b", property_get_docked, 0, 0),
SD_BUS_METHOD("GetSession", "s", "o", method_get_session, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("GetSessionByPID", "u", "o", method_get_session_by_pid, SD_BUS_VTABLE_UNPRIVILEGED),
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index 68304a1610..855c85402c 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -371,7 +371,7 @@ bool manager_is_inhibited(
Inhibitor *i;
Iterator j;
- struct dual_timestamp ts = { 0, 0 };
+ struct dual_timestamp ts = DUAL_TIMESTAMP_NULL;
bool inhibited = false;
assert(m);
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 11d24ce5b4..3c30eeaa95 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -599,7 +599,7 @@ bool seat_can_graphical(Seat *s) {
int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
Session *session;
bool idle_hint = true;
- dual_timestamp ts = { 0, 0 };
+ dual_timestamp ts = DUAL_TIMESTAMP_NULL;
assert(s);
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index debaa31a29..563153e2d9 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -163,7 +163,7 @@ static int property_get_idle_since_hint(
sd_bus_error *error) {
Session *s = userdata;
- dual_timestamp t;
+ dual_timestamp t = DUAL_TIMESTAMP_NULL;
uint64_t u;
int r;
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 8a710cef13..0f72d70b10 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -138,7 +138,7 @@ static int property_get_idle_since_hint(
sd_bus_error *error) {
User *u = userdata;
- dual_timestamp t;
+ dual_timestamp t = DUAL_TIMESTAMP_NULL;
uint64_t k;
assert(bus);
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index c0b473930d..6720899def 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -619,7 +619,7 @@ int user_finalize(User *u) {
int user_get_idle_hint(User *u, dual_timestamp *t) {
Session *s;
bool idle_hint = true;
- dual_timestamp ts = { 0, 0 };
+ dual_timestamp ts = DUAL_TIMESTAMP_NULL;
assert(u);
@@ -763,6 +763,9 @@ static int elect_display_compare(Session *s1, Session *s2) {
* is preferred.
*
* s1 or s2 may be NULL. */
+ if (!s1 && !s2)
+ return 0;
+
if ((s1 == NULL) != (s2 == NULL))
return (s1 == NULL) - (s2 == NULL);
diff --git a/src/login/logind.c b/src/login/logind.c
index 00f8dbdab2..01f7cd9ee0 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -787,13 +787,8 @@ static int manager_connect_console(Manager *m) {
return -EINVAL;
}
- r = ignore_signals(SIGRTMIN + 1, -1);
- if (r < 0)
- return log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m");
-
- r = sigprocmask_many(SIG_BLOCK, SIGRTMIN, -1);
- if (r < 0)
- return log_error_errno(r, "Cannot block SIGRTMIN: %m");
+ assert_se(ignore_signals(SIGRTMIN + 1, -1) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGRTMIN, -1) >= 0);
r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m);
if (r < 0)
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index c86c36c2de..7938aa4dbe 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -500,6 +500,18 @@ typedef struct MachineStatusInfo {
unsigned n_netif;
} MachineStatusInfo;
+static void machine_status_info_clear(MachineStatusInfo *info) {
+ if (info) {
+ free(info->name);
+ free(info->class);
+ free(info->service);
+ free(info->unit);
+ free(info->root_directory);
+ free(info->netif);
+ zero(*info);
+ }
+}
+
static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
@@ -636,7 +648,7 @@ static int show_machine_info(const char *verb, sd_bus *bus, const char *path, bo
{}
};
- MachineStatusInfo info = {};
+ _cleanup_(machine_status_info_clear) MachineStatusInfo info = {};
int r;
assert(verb);
@@ -658,13 +670,6 @@ static int show_machine_info(const char *verb, sd_bus *bus, const char *path, bo
print_machine_status_info(bus, &info);
- free(info.name);
- free(info.class);
- free(info.service);
- free(info.unit);
- free(info.root_directory);
- free(info.netif);
-
return r;
}
@@ -753,6 +758,15 @@ typedef struct ImageStatusInfo {
uint64_t limit_exclusive;
} ImageStatusInfo;
+static void image_status_info_clear(ImageStatusInfo *info) {
+ if (info) {
+ free(info->name);
+ free(info->path);
+ free(info->type);
+ zero(*info);
+ }
+}
+
static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
char ts_relative[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char ts_absolute[FORMAT_TIMESTAMP_MAX], *s2;
@@ -823,7 +837,7 @@ static int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
{}
};
- ImageStatusInfo info = {};
+ _cleanup_(image_status_info_clear) ImageStatusInfo info = {};
int r;
assert(bus);
@@ -844,10 +858,6 @@ static int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
print_image_status_info(bus, &info);
- free(info.name);
- free(info.path);
- free(info.type);
-
return r;
}
@@ -857,6 +867,15 @@ typedef struct PoolStatusInfo {
uint64_t limit;
} PoolStatusInfo;
+static void pool_status_info_clear(PoolStatusInfo *info) {
+ if (info) {
+ free(info->path);
+ zero(*info);
+ info->usage = -1;
+ info->limit = -1;
+ }
+}
+
static void print_pool_status_info(sd_bus *bus, PoolStatusInfo *i) {
char bs[FORMAT_BYTES_MAX], *s;
@@ -881,7 +900,7 @@ static int show_pool_info(sd_bus *bus) {
{}
};
- PoolStatusInfo info = {
+ _cleanup_(pool_status_info_clear) PoolStatusInfo info = {
.usage = (uint64_t) -1,
.limit = (uint64_t) -1,
};
@@ -899,7 +918,6 @@ static int show_pool_info(sd_bus *bus) {
print_pool_status_info(bus, &info);
- free(info.path);
return 0;
}
@@ -1201,7 +1219,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
if (r < 0)
return bus_log_parse_error(r);
- sigprocmask_many(SIG_BLOCK, SIGWINCH, SIGTERM, SIGINT, -1);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGWINCH, SIGTERM, SIGINT, -1) >= 0);
log_info("Connected to machine %s. Press ^] three times within 1s to exit session.", argv[1]);
@@ -1612,7 +1630,7 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
if (r < 0)
return bus_log_parse_error(r);
- sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
if (!arg_quiet)
log_info("Enqueued transfer job %u. Press C-c to continue download in background.", id);
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 754c770040..9bfe2add54 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -322,7 +322,7 @@ int main(int argc, char *argv[]) {
* check stays in. */
mkdir_label("/run/systemd/machines", 0755);
- assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
m = manager_new();
if (!m) {
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 944da3f5b8..172ca43a7d 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -24,7 +24,7 @@
#include "utf8.h"
#include "util.h"
#include "conf-parser.h"
-#include "fw-util.h"
+#include "firewall-util.h"
#include "networkd.h"
#include "networkd-link.h"
diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c
index 6a96f1de55..32c31fdf3d 100644
--- a/src/network/networkd-wait-online.c
+++ b/src/network/networkd-wait-online.c
@@ -129,7 +129,7 @@ int main(int argc, char *argv[]) {
if (arg_quiet)
log_set_max_level(LOG_WARNING);
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
r = manager_new(&m, arg_interfaces, arg_ignore, arg_timeout);
if (r < 0) {
diff --git a/src/network/networkd.c b/src/network/networkd.c
index 41ec7cf904..9fe8a5fa15 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto out;
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
r = manager_new(&m);
if (r < 0) {
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 3f0b3d9182..eea994d0b3 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -90,7 +90,7 @@
#include "machine-image.h"
#include "list.h"
#include "in-addr-util.h"
-#include "fw-util.h"
+#include "firewall-util.h"
#include "local-addresses.h"
#include "formats-util.h"
#include "process-util.h"
@@ -350,7 +350,7 @@ static int custom_mounts_prepare(void) {
if (m->read_only)
continue;
- r = tempfn_random(m->source, &m->work_dir);
+ r = tempfn_random(m->source, NULL, &m->work_dir);
if (r < 0)
return log_error_errno(r, "Failed to generate work directory from %s: %m", m->source);
}
@@ -3002,8 +3002,15 @@ static int setup_seccomp(void) {
}
r = seccomp_load(seccomp);
- if (r < 0)
+ if (r == -EINVAL) {
+ log_debug_errno(r, "Kernel is probably not configured with CONFIG_SECCOMP. Disabling seccomp audit filter: %m");
+ r = 0;
+ goto finish;
+ }
+ if (r < 0) {
log_error_errno(r, "Failed to install seccomp audit filter: %m");
+ goto finish;
+ }
finish:
seccomp_release(seccomp);
@@ -4458,7 +4465,7 @@ int main(int argc, char *argv[]) {
int r, n_fd_passed, loop_nr = -1;
char veth_name[IFNAMSIZ];
bool secondary = false, remove_subvol = false;
- sigset_t mask, mask_chld;
+ sigset_t mask_chld;
pid_t pid = 0;
int ret = EXIT_SUCCESS;
union in_addr_union exposed = {};
@@ -4515,9 +4522,9 @@ int main(int argc, char *argv[]) {
goto finish;
}
if (r > 0)
- r = tempfn_random_child(arg_directory, &np);
+ r = tempfn_random_child(arg_directory, "machine.", &np);
else
- r = tempfn_random(arg_directory, &np);
+ r = tempfn_random(arg_directory, "machine.", &np);
if (r < 0) {
log_error_errno(r, "Failed to generate name for snapshot: %m");
goto finish;
@@ -4657,9 +4664,7 @@ int main(int argc, char *argv[]) {
log_info("Spawning container %s on %s.\nPress ^] three times within 1s to kill container.",
arg_machine, arg_image ?: arg_directory);
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, -1);
- assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, -1) >= 0);
assert_se(sigemptyset(&mask_chld) == 0);
assert_se(sigaddset(&mask_chld, SIGCHLD) == 0);
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index e283d8a749..0af5545f8e 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
r = manager_new(&m);
if (r < 0) {
diff --git a/src/run/run.c b/src/run/run.c
index f18f77b55a..99d960a664 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -789,19 +789,16 @@ static int start_transient_service(
if (master >= 0) {
_cleanup_(pty_forward_freep) PTYForward *forward = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
- sigset_t mask;
char last_char = 0;
r = sd_event_default(&event);
if (r < 0)
return log_error_errno(r, "Failed to get event loop: %m");
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGWINCH, SIGTERM, SIGINT, -1);
- assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGWINCH, SIGTERM, SIGINT, -1) >= 0);
- sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
- sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
+ (void) sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
if (!arg_quiet)
log_info("Running as unit %s.\nPress ^] three times within 1s to disconnect TTY.", service);
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index ef3788be68..3941605cec 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -323,9 +323,9 @@ int ask_password_agent(
assert(_passphrases);
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0);
+ assert_se(sigemptyset(&mask) >= 0);
+ assert_se(sigset_add_many(&mask, SIGINT, SIGTERM, -1) >= 0);
+ assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) >= 0);
mkdir_p_label("/run/systemd/ask-password", 0755);
diff --git a/src/shared/fw-util.c b/src/shared/firewall-util.c
index 6b3599d90d..effc6e8e70 100644
--- a/src/shared/fw-util.c
+++ b/src/shared/firewall-util.c
@@ -28,7 +28,7 @@
#include <libiptc/libiptc.h>
#include "util.h"
-#include "fw-util.h"
+#include "firewall-util.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(struct xtc_handle*, iptc_free);
diff --git a/src/shared/fw-util.h b/src/shared/firewall-util.h
index 93152e3978..93152e3978 100644
--- a/src/shared/fw-util.h
+++ b/src/shared/firewall-util.h
diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c
index 8c64908b1a..8af78f47d5 100644
--- a/src/shared/machine-pool.c
+++ b/src/shared/machine-pool.c
@@ -75,7 +75,7 @@ static int setup_machine_raw(uint64_t size, sd_bus_error *error) {
if (errno != ENOENT)
return sd_bus_error_set_errnof(error, errno, "Failed to open /var/lib/machines.raw: %m");
- r = tempfn_xxxxxx("/var/lib/machines.raw", &tmp);
+ r = tempfn_xxxxxx("/var/lib/machines.raw", NULL, &tmp);
if (r < 0)
return r;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 5075e4e176..23fc946fbf 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1183,7 +1183,7 @@ static int list_timers(sd_bus *bus, char **args) {
for (u = unit_infos; u < unit_infos + n; u++) {
_cleanup_strv_free_ char **triggered = NULL;
- dual_timestamp next = {};
+ dual_timestamp next = DUAL_TIMESTAMP_NULL;
usec_t m, last = 0;
if (!endswith(u->id, ".timer"))
@@ -1678,17 +1678,23 @@ static const struct bus_properties_map machine_info_property_map[] = {
{}
};
+static void machine_info_clear(struct machine_info *info) {
+ if (info) {
+ free(info->name);
+ free(info->state);
+ free(info->control_group);
+ zero(*info);
+ }
+}
+
static void free_machines_list(struct machine_info *machine_infos, int n) {
int i;
if (!machine_infos)
return;
- for (i = 0; i < n; i++) {
- free(machine_infos[i].name);
- free(machine_infos[i].state);
- free(machine_infos[i].control_group);
- }
+ for (i = 0; i < n; i++)
+ machine_info_clear(&machine_infos[i]);
free(machine_infos);
}
@@ -4402,7 +4408,7 @@ static int show_all(
static int show_system_status(sd_bus *bus) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], since2[FORMAT_TIMESTAMP_MAX];
_cleanup_free_ char *hn = NULL;
- struct machine_info mi = {};
+ _cleanup_(machine_info_clear) struct machine_info mi = {};
const char *on, *off;
int r;
@@ -4449,9 +4455,6 @@ static int show_system_status(sd_bus *bus) {
show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false, get_output_flags());
}
- free(mi.state);
- free(mi.control_group);
-
return 0;
}
@@ -5684,7 +5687,7 @@ static int create_edit_temp_file(const char *new_path, const char *original_path
assert(original_path);
assert(ret_tmp_fn);
- r = tempfn_random(new_path, &t);
+ r = tempfn_random(new_path, NULL, &t);
if (r < 0)
return log_error_errno(r, "Failed to determine temporary filename for \"%s\": %m", new_path);
diff --git a/src/test/test-fw-util.c b/src/test/test-firewall-util.c
index ab891aa0c4..d636e427c4 100644
--- a/src/test/test-fw-util.c
+++ b/src/test/test-firewall-util.c
@@ -20,7 +20,7 @@
***/
#include "log.h"
-#include "fw-util.h"
+#include "firewall-util.h"
#define MAKE_IN_ADDR_UNION(a,b,c,d) (union in_addr_union) { .in.s_addr = htobe32((uint32_t) (a) << 24 | (uint32_t) (b) << 16 | (uint32_t) (c) << 8 | (uint32_t) (d))}
diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c
index 1498432971..2879d7450f 100644
--- a/src/test/test-netlink-manual.c
+++ b/src/test/test-netlink-manual.c
@@ -127,7 +127,7 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1);
- assert_se((m = sd_netlink_message_unref(n)) == NULL);
+ assert_se((n = sd_netlink_message_unref(n)) == NULL);
return EXIT_SUCCESS;
}
diff --git a/src/test/test-pty.c b/src/test/test-pty.c
index f8807c9150..3f97a64ccd 100644
--- a/src/test/test-pty.c
+++ b/src/test/test-pty.c
@@ -129,7 +129,7 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
- assert_se(sigprocmask_many(SIG_BLOCK, SIGCHLD, -1) >= 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
/* Oh, there're ugly races in the TTY layer regarding HUP vs IN. Turns
* out they appear only 10% of the time. I fixed all of them and
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index d1fe953071..2b765a3e90 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]) {
event = udev_event_new(dev);
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) >= 0);
/* do what devtmpfs usually provides us */
if (udev_device_get_devnode(dev) != NULL) {
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 9d5516a18d..ed8db45115 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1507,6 +1507,42 @@ static void test_parse_mode(void) {
assert_se(parse_mode("0", &m) >= 0 && m == 0);
}
+static void test_tempfn(void) {
+ char *ret = NULL, *p;
+
+ assert_se(tempfn_xxxxxx("/foo/bar/waldo", NULL, &ret) >= 0);
+ assert_se(streq_ptr(ret, "/foo/bar/.#waldoXXXXXX"));
+ free(ret);
+
+ assert_se(tempfn_xxxxxx("/foo/bar/waldo", "[miau]", &ret) >= 0);
+ assert_se(streq_ptr(ret, "/foo/bar/.#[miau]waldoXXXXXX"));
+ free(ret);
+
+ assert_se(tempfn_random("/foo/bar/waldo", NULL, &ret) >= 0);
+ assert_se(p = startswith(ret, "/foo/bar/.#waldo"));
+ assert_se(strlen(p) == 16);
+ assert_se(in_charset(p, "0123456789abcdef"));
+ free(ret);
+
+ assert_se(tempfn_random("/foo/bar/waldo", "[wuff]", &ret) >= 0);
+ assert_se(p = startswith(ret, "/foo/bar/.#[wuff]waldo"));
+ assert_se(strlen(p) == 16);
+ assert_se(in_charset(p, "0123456789abcdef"));
+ free(ret);
+
+ assert_se(tempfn_random_child("/foo/bar/waldo", NULL, &ret) >= 0);
+ assert_se(p = startswith(ret, "/foo/bar/waldo/.#"));
+ assert_se(strlen(p) == 16);
+ assert_se(in_charset(p, "0123456789abcdef"));
+ free(ret);
+
+ assert_se(tempfn_random_child("/foo/bar/waldo", "[kikiriki]", &ret) >= 0);
+ assert_se(p = startswith(ret, "/foo/bar/waldo/.#[kikiriki]"));
+ assert_se(strlen(p) == 16);
+ assert_se(in_charset(p, "0123456789abcdef"));
+ free(ret);
+}
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
@@ -1582,6 +1618,7 @@ int main(int argc, char *argv[]) {
test_sparse_write();
test_shell_maybe_quote();
test_parse_mode();
+ test_tempfn();
return 0;
}
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 61b6e765c7..195d5f3892 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -73,6 +73,13 @@ typedef struct StatusInfo {
bool ntp_synced;
} StatusInfo;
+static void status_info_clear(StatusInfo *info) {
+ if (info) {
+ free(info->timezone);
+ zero(*info);
+ }
+}
+
static void print_status_info(const StatusInfo *i) {
char a[FORMAT_TIMESTAMP_MAX];
struct tm tm;
@@ -155,7 +162,7 @@ static void print_status_info(const StatusInfo *i) {
}
static int show_status(sd_bus *bus, char **args, unsigned n) {
- StatusInfo info = {};
+ _cleanup_(status_info_clear) StatusInfo info = {};
static const struct bus_properties_map map[] = {
{ "Timezone", "s", NULL, offsetof(StatusInfo, timezone) },
{ "LocalRTC", "b", NULL, offsetof(StatusInfo, rtc_local) },
@@ -175,15 +182,11 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
"/org/freedesktop/timedate1",
map,
&info);
- if (r < 0) {
- log_error_errno(r, "Failed to query server: %m");
- goto fail;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to query server: %m");
print_status_info(&info);
-fail:
- free(info.timezone);
return r;
}
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index d69129ee03..b030206948 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -117,7 +117,7 @@ int main(int argc, char *argv[]) {
if (setrlimit(RLIMIT_NPROC, &RLIMIT_MAKE_CONST(2)) < 0)
log_warning_errno(errno, "Failed to lower RLIMIT_NPROC to 2: %m");
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
r = manager_new(&m);
if (r < 0) {
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index f7dad8491e..027a5c2ca8 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1465,7 +1465,7 @@ static int remove_item_instance(Item *i, const char *instance) {
/* FIXME: we probably should use dir_cleanup() here
* instead of rm_rf() so that 'x' is honoured. */
log_debug("rm -rf \"%s\"", instance);
- r = rm_rf(instance, (i->type == RECURSIVE_REMOVE_PATH ? REMOVE_ROOT : 0) | REMOVE_PHYSICAL);
+ r = rm_rf(instance, (i->type == RECURSIVE_REMOVE_PATH ? REMOVE_ROOT|REMOVE_SUBVOLUME : 0) | REMOVE_PHYSICAL);
if (r < 0 && r != -ENOENT)
return log_error_errno(r, "rm_rf(%s): %m", instance);
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 97251ef0aa..73b19d8e89 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -485,9 +485,9 @@ static int watch_passwords(void) {
if (inotify_add_watch(notify, "/run/systemd/ask-password", IN_CLOSE_WRITE|IN_MOVED_TO) < 0)
return -errno;
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
+ assert_se(sigemptyset(&mask) >= 0);
+ assert_se(sigset_add_many(&mask, SIGINT, SIGTERM, -1) >= 0);
+ assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) >= 0);
signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
if (signal_fd < 0)
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 7e16922c70..5516a792eb 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -42,6 +42,7 @@ typedef struct Spawn {
pid_t pid;
usec_t timeout_warn;
usec_t timeout;
+ bool accept_failure;
} Spawn;
struct udev_event *udev_event_new(struct udev_device *dev) {
@@ -583,23 +584,24 @@ static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userd
switch (si->si_code) {
case CLD_EXITED:
- if (si->si_status != 0)
- log_warning("process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
- else {
- log_debug("process '%s' succeeded.", spawn->cmd);
+ if (si->si_status == 0) {
+ log_debug("Process '%s' succeeded.", spawn->cmd);
sd_event_exit(sd_event_source_get_event(s), 0);
return 1;
- }
+ } else if (spawn->accept_failure)
+ log_debug("Process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
+ else
+ log_warning("Process '%s' failed with exit code %i.", spawn->cmd, si->si_status);
break;
case CLD_KILLED:
case CLD_DUMPED:
- log_warning("process '%s' terminated by signal %s.", spawn->cmd, signal_to_string(si->si_status));
+ log_warning("Process '%s' terminated by signal %s.", spawn->cmd, signal_to_string(si->si_status));
break;
default:
- log_error("process '%s' failed due to unknown reason.", spawn->cmd);
+ log_error("Process '%s' failed due to unknown reason.", spawn->cmd);
}
sd_event_exit(sd_event_source_get_event(s), -EIO);
@@ -610,10 +612,12 @@ static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userd
static int spawn_wait(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
- const char *cmd, pid_t pid) {
+ const char *cmd, pid_t pid,
+ bool accept_failure) {
Spawn spawn = {
.cmd = cmd,
.pid = pid,
+ .accept_failure = accept_failure,
};
_cleanup_event_unref_ sd_event *e = NULL;
int r, ret;
@@ -698,6 +702,7 @@ out:
int udev_event_spawn(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
+ bool accept_failure,
const char *cmd, char **envp,
char *result, size_t ressize) {
int outpipe[2] = {-1, -1};
@@ -773,7 +778,7 @@ int udev_event_spawn(struct udev_event *event,
outpipe[READ_END], errpipe[READ_END],
result, ressize);
- err = spawn_wait(event, timeout_usec, timeout_warn_usec, cmd, pid);
+ err = spawn_wait(event, timeout_usec, timeout_warn_usec, cmd, pid, accept_failure);
}
out:
@@ -930,7 +935,7 @@ void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_
udev_event_apply_format(event, cmd, program, sizeof(program));
envp = udev_device_get_properties_envp(event->dev);
- udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, NULL, 0);
+ udev_event_spawn(event, timeout_usec, timeout_warn_usec, false, program, envp, NULL, 0);
}
}
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 7be9a2311a..8ebc061eb1 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -641,7 +641,7 @@ static int import_program_into_properties(struct udev_event *event,
int err;
envp = udev_device_get_properties_envp(dev);
- err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, result, sizeof(result));
+ err = udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result));
if (err < 0)
return err;
@@ -2131,7 +2131,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
rules_str(rules, rule->rule.filename_off),
rule->rule.filename_line);
- if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, program, envp, result, sizeof(result)) < 0) {
+ if (udev_event_spawn(event, timeout_usec, timeout_warn_usec, true, program, envp, result, sizeof(result)) < 0) {
if (cur->key.op != OP_NOMATCH)
goto nomatch;
} else {
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 59751b4c90..3dca72e499 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -84,6 +84,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
int udev_event_spawn(struct udev_event *event,
usec_t timeout_usec,
usec_t timeout_warn_usec,
+ bool accept_failure,
const char *cmd, char **envp,
char *result, size_t ressize);
void udev_event_execute_rules(struct udev_event *event,
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 2b1dbb8bf1..d3797bb5e6 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1547,7 +1547,7 @@ static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent, const char *cg
udev_watch_restore(manager->udev);
/* block and listen to all signals on signalfd */
- assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) == 0);
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) >= 0);
r = sd_event_default(&manager->event);
if (r < 0)