diff options
author | Adrian Vovk <adrianvovk@gmail.com> | 2024-02-02 21:03:54 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-02-14 09:14:13 +0100 |
commit | 80d07162e7cc87455d7b396b3b74fa5ff0391c89 (patch) | |
tree | f2c4a0aa2a16ebdc0b55ff56db4726c7620bc932 /src/libsystemd | |
parent | homed: Add some missing asserts (diff) | |
download | systemd-80d07162e7cc87455d7b396b3b74fa5ff0391c89.tar.xz systemd-80d07162e7cc87455d7b396b3b74fa5ff0391c89.zip |
format-utils: Expose FORMAT_UID and FORMAT_GID
This pulls this generally useful helper out of sysusers and into the
util lib, and updates the places throughout the codebase where it makes
sense to use it.
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-login/sd-login.c | 5 |
2 files changed, 3 insertions, 8 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 2ad29af105..a25369e930 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -30,6 +30,7 @@ #include "constants.h" #include "errno-util.h" #include "fd-util.h" +#include "format-util.h" #include "glyph-util.h" #include "hexdecoct.h" #include "hostname-util.h" @@ -1672,10 +1673,7 @@ static int user_and_machine_equivalent(const char *user_and_machine) { return true; /* Otherwise, we have to figure out our user id and name, and compare things with that. */ - char buf[DECIMAL_STR_MAX(uid_t)]; - xsprintf(buf, UID_FMT, uid); - - f = startswith(user_and_machine, buf); + f = startswith(user_and_machine, FORMAT_UID(uid)); if (!f) { un = getusername_malloc(); if (!un) diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index c72fccc229..4d91ba96f6 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -579,10 +579,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) if (isempty(content)) return 0; - char t[DECIMAL_STR_MAX(uid_t)]; - xsprintf(t, UID_FMT, uid); - - return string_contains_word(content, NULL, t); + return string_contains_word(content, NULL, FORMAT_UID(uid)); } static int uid_get_array(uid_t uid, const char *variable, char ***array) { |