mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-18 06:03:42 +03:00
Merge pull request #1160 from dvdhrm/bus-user
sd-bus: derive uid from cgroup if possible
This commit is contained in:
commit
718909ec33
@ -1241,6 +1241,8 @@ fail:
|
||||
|
||||
int bus_set_address_user(sd_bus *b) {
|
||||
const char *e;
|
||||
uid_t uid;
|
||||
int r;
|
||||
|
||||
assert(b);
|
||||
|
||||
@ -1248,6 +1250,10 @@ int bus_set_address_user(sd_bus *b) {
|
||||
if (e)
|
||||
return sd_bus_set_address(b, e);
|
||||
|
||||
r = cg_pid_get_owner_uid(0, &uid);
|
||||
if (r < 0)
|
||||
uid = getuid();
|
||||
|
||||
e = secure_getenv("XDG_RUNTIME_DIR");
|
||||
if (e) {
|
||||
_cleanup_free_ char *ee = NULL;
|
||||
@ -1256,9 +1262,9 @@ int bus_set_address_user(sd_bus *b) {
|
||||
if (!ee)
|
||||
return -ENOMEM;
|
||||
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, getuid(), ee);
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, uid, ee);
|
||||
} else
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
|
||||
(void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, uid);
|
||||
|
||||
if (!b->address)
|
||||
return -ENOMEM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user