summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/acl-util.c13
-rw-r--r--src/shared/acl-util.h2
-rw-r--r--src/shared/bus-util.c23
-rw-r--r--src/shared/logs-show.c4
-rw-r--r--src/shared/watchdog.c9
5 files changed, 31 insertions, 20 deletions
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index 466f9aa601..bd8c988751 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -223,7 +223,7 @@ int acl_search_groups(const char *path, char ***ret_groups) {
return ret;
}
-int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) {
+int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) {
_cleanup_free_ char **a = NULL, **d = NULL; /* strings are not be freed */
_cleanup_strv_free_ char **split;
char **entry;
@@ -232,7 +232,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask)
split = strv_split(text, ",");
if (!split)
- return log_oom();
+ return -ENOMEM;
STRV_FOREACH(entry, split) {
char *p;
@@ -245,9 +245,9 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask)
r = strv_push(&d, p);
else
r = strv_push(&a, *entry);
+ if (r < 0)
+ return r;
}
- if (r < 0)
- return r;
if (!strv_isempty(a)) {
_cleanup_free_ char *join;
@@ -258,7 +258,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask)
a_acl = acl_from_text(join);
if (!a_acl)
- return -EINVAL;
+ return -errno;
if (want_mask) {
r = calc_acl_mask_if_needed(&a_acl);
@@ -276,7 +276,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask)
d_acl = acl_from_text(join);
if (!d_acl)
- return -EINVAL;
+ return -errno;
if (want_mask) {
r = calc_acl_mask_if_needed(&d_acl);
@@ -288,6 +288,7 @@ int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask)
*acl_access = a_acl;
*acl_default = d_acl;
a_acl = d_acl = NULL;
+
return 0;
}
diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h
index c8bcc266d0..cf612e8722 100644
--- a/src/shared/acl-util.h
+++ b/src/shared/acl-util.h
@@ -33,7 +33,7 @@ int acl_find_uid(acl_t acl, uid_t uid, acl_entry_t *entry);
int calc_acl_mask_if_needed(acl_t *acl_p);
int add_base_acls_if_needed(acl_t *acl_p, const char *path);
int acl_search_groups(const char* path, char ***ret_groups);
-int parse_acl(char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
+int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask);
int acls_for_file(const char *path, acl_type_t type, acl_t new, acl_t *acl);
/* acl_free takes multiple argument types.
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 8fcc289957..11350dad71 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -545,7 +545,6 @@ int bus_open_system_systemd(sd_bus **_bus) {
* directly to the system instance, instead of going via the
* bus */
-#ifdef ENABLE_KDBUS
r = sd_bus_new(&bus);
if (r < 0)
return r;
@@ -564,7 +563,6 @@ int bus_open_system_systemd(sd_bus **_bus) {
}
bus = sd_bus_unref(bus);
-#endif
r = sd_bus_new(&bus);
if (r < 0)
@@ -598,7 +596,6 @@ int bus_open_user_systemd(sd_bus **_bus) {
assert(_bus);
-#ifdef ENABLE_KDBUS
r = sd_bus_new(&bus);
if (r < 0)
return r;
@@ -616,7 +613,6 @@ int bus_open_user_systemd(sd_bus **_bus) {
}
bus = sd_bus_unref(bus);
-#endif
e = secure_getenv("XDG_RUNTIME_DIR");
if (!e)
@@ -2034,15 +2030,22 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
bool is_kdbus_wanted(void) {
_cleanup_free_ char *value = NULL;
+#ifdef ENABLE_KDBUS
+ const bool configured = true;
+#else
+ const bool configured = false;
+#endif
+
int r;
- if (get_proc_cmdline_key("kdbus", NULL) <= 0) {
- r = get_proc_cmdline_key("kdbus=", &value);
- if (r <= 0 || parse_boolean(value) != 1)
- return false;
- }
+ if (get_proc_cmdline_key("kdbus", NULL) > 0)
+ return true;
+
+ r = get_proc_cmdline_key("kdbus=", &value);
+ if (r <= 0)
+ return configured;
- return true;
+ return parse_boolean(value) == 1;
}
bool is_kdbus_available(void) {
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index ac5eb16f62..068da465d9 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -274,8 +274,10 @@ static int output_short(
if (r < 0)
return log_error_errno(r, "Failed to get journal fields: %m");
- if (!message)
+ if (!message) {
+ log_debug("Skipping message without MESSAGE= field.");
return 0;
+ }
if (!(flags & OUTPUT_SHOW_ALL))
strip_tab_ansi(&message, &message_len);
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
index 2fe4eb81cf..9d39beb340 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -60,8 +60,13 @@ static int update_timeout(void) {
flags = WDIOS_ENABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0)
- return log_warning_errno(errno, "Failed to enable hardware watchdog: %m");
+ if (r < 0) {
+ /* ENOTTY means the watchdog is always enabled so we're fine */
+ log_full(errno == ENOTTY ? LOG_DEBUG : LOG_WARNING,
+ "Failed to enable hardware watchdog: %m");
+ if (errno != ENOTTY)
+ return -errno;
+ }
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
if (r < 0)