summaryrefslogtreecommitdiffstats
path: root/src/login
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:18:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:18:14 +0000
commit67c5de60daa85b91fa68be4157e248fa31e75316 (patch)
tree7d567f3360f705ac21600343ef7f7cea645a9222 /src/login
parentAdding upstream version 256.1. (diff)
downloadsystemd-06a0a2fdeaf41892705cfec541146336e3c21087.tar.xz
systemd-06a0a2fdeaf41892705cfec541146336e3c21087.zip
Adding upstream version 256.2.upstream/256.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/login')
-rw-r--r--src/login/user-runtime-dir.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/login/user-runtime-dir.c b/src/login/user-runtime-dir.c
index 575f8eb..b242f83 100644
--- a/src/login/user-runtime-dir.c
+++ b/src/login/user-runtime-dir.c
@@ -25,27 +25,38 @@
#include "strv.h"
#include "user-util.h"
-static int acquire_runtime_dir_properties(uint64_t *size, uint64_t *inodes) {
+static int acquire_runtime_dir_properties(uint64_t *ret_size, uint64_t *ret_inodes) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
+ uint64_t size, inodes;
int r;
+ assert(ret_size);
+ assert(ret_inodes);
+
r = sd_bus_default_system(&bus);
if (r < 0)
return log_error_errno(r, "Failed to connect to system bus: %m");
- r = bus_get_property_trivial(bus, bus_login_mgr, "RuntimeDirectorySize", &error, 't', size);
+ r = bus_get_property_trivial(bus, bus_login_mgr, "RuntimeDirectorySize", &error, 't', &size);
if (r < 0) {
log_warning_errno(r, "Failed to acquire runtime directory size, ignoring: %s", bus_error_message(&error, r));
- *size = physical_memory_scale(10U, 100U); /* 10% */
+ sd_bus_error_free(&error);
+
+ size = physical_memory_scale(10U, 100U); /* 10% */
}
- r = bus_get_property_trivial(bus, bus_login_mgr, "RuntimeDirectoryInodesMax", &error, 't', inodes);
+ r = bus_get_property_trivial(bus, bus_login_mgr, "RuntimeDirectoryInodesMax", &error, 't', &inodes);
if (r < 0) {
log_warning_errno(r, "Failed to acquire number of inodes for runtime directory, ignoring: %s", bus_error_message(&error, r));
- *inodes = DIV_ROUND_UP(*size, 4096);
+ sd_bus_error_free(&error);
+
+ inodes = DIV_ROUND_UP(size, 4096);
}
+ *ret_size = size;
+ *ret_inodes = inodes;
+
return 0;
}
@@ -70,7 +81,7 @@ static int user_mkdir_runtime_path(
if (path_is_mount_point(runtime_path) > 0)
log_debug("%s is already a mount point", runtime_path);
else {
- char options[sizeof("mode=0700,uid=,gid=,size=,nr_inodes=,smackfsroot=*")
+ char options[STRLEN("mode=0700,uid=,gid=,size=,nr_inodes=,smackfsroot=*")
+ DECIMAL_STR_MAX(uid_t)
+ DECIMAL_STR_MAX(gid_t)
+ DECIMAL_STR_MAX(uint64_t)
@@ -140,7 +151,7 @@ static int user_remove_runtime_path(const char *runtime_path) {
}
static int do_mount(const char *user) {
- char runtime_path[sizeof("/run/user") + DECIMAL_STR_MAX(uid_t)];
+ char runtime_path[STRLEN("/run/user/") + DECIMAL_STR_MAX(uid_t)];
uint64_t runtime_dir_size, runtime_dir_inodes;
uid_t uid;
gid_t gid;
@@ -165,7 +176,7 @@ static int do_mount(const char *user) {
}
static int do_umount(const char *user) {
- char runtime_path[sizeof("/run/user") + DECIMAL_STR_MAX(uid_t)];
+ char runtime_path[STRLEN("/run/user/") + DECIMAL_STR_MAX(uid_t)];
uid_t uid;
int r;