diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-11-27 17:08:17 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-02-14 15:03:23 +0100 |
commit | 508d344e0e95667c27df2ffbf23a928d97a07bb1 (patch) | |
tree | 0fbaa3b79258f7ed9716f321f995f73f592facbb /src/home/homed-home-bus.c | |
parent | user-record-show: show if fallback data is used (diff) | |
download | systemd-508d344e0e95667c27df2ffbf23a928d97a07bb1.tar.xz systemd-508d344e0e95667c27df2ffbf23a928d97a07bb1.zip |
homed: add bus call that allows referencing a home without activating it
This is useful for allowing users to login without the ability to unlock
their home dir. Usecase is ssh: ssh might grant access without giving
us the chance to unlock the home dir for the user (because it doesn't
allow us asking questions during authentication), hence with this call
we can pin the home dir, but not activate it and then allow the
activation to be delayed until later.
Diffstat (limited to 'src/home/homed-home-bus.c')
-rw-r--r-- | src/home/homed-home-bus.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/home/homed-home-bus.c b/src/home/homed-home-bus.c index 30f5735443..5977ff2a47 100644 --- a/src/home/homed-home-bus.c +++ b/src/home/homed-home-bus.c @@ -620,30 +620,38 @@ int bus_home_method_ref( _cleanup_close_ int fd = -EBADF; Home *h = ASSERT_PTR(userdata); - HomeState state; int please_suspend, r; + bool unrestricted; assert(message); + /* In unrestricted mode we'll add a reference to the home even if it's not active */ + unrestricted = strstr(sd_bus_message_get_member(message), "Unrestricted"); + r = sd_bus_message_read(message, "b", &please_suspend); if (r < 0) return r; - state = home_get_state(h); - switch (state) { - case HOME_ABSENT: - return sd_bus_error_setf(error, BUS_ERROR_HOME_ABSENT, "Home %s is currently missing or not plugged in.", h->user_name); - case HOME_UNFIXATED: - case HOME_INACTIVE: - case HOME_DIRTY: - return sd_bus_error_setf(error, BUS_ERROR_HOME_NOT_ACTIVE, "Home %s not active.", h->user_name); - case HOME_LOCKED: - return sd_bus_error_setf(error, BUS_ERROR_HOME_LOCKED, "Home %s is currently locked.", h->user_name); - default: - if (HOME_STATE_IS_ACTIVE(state)) - break; + if (!unrestricted) { + HomeState state; - return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "An operation on home %s is currently being executed.", h->user_name); + state = home_get_state(h); + + switch (state) { + case HOME_ABSENT: + return sd_bus_error_setf(error, BUS_ERROR_HOME_ABSENT, "Home %s is currently missing or not plugged in.", h->user_name); + case HOME_UNFIXATED: + case HOME_INACTIVE: + case HOME_DIRTY: + return sd_bus_error_setf(error, BUS_ERROR_HOME_NOT_ACTIVE, "Home %s not active.", h->user_name); + case HOME_LOCKED: + return sd_bus_error_setf(error, BUS_ERROR_HOME_LOCKED, "Home %s is currently locked.", h->user_name); + default: + if (HOME_STATE_IS_ACTIVE(state)) + break; + + return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "An operation on home %s is currently being executed.", h->user_name); + } } fd = home_create_fifo(h, please_suspend ? HOME_FIFO_PLEASE_SUSPEND : HOME_FIFO_DONT_SUSPEND); @@ -865,6 +873,11 @@ const sd_bus_vtable home_vtable[] = { SD_BUS_RESULT("h", send_fd), bus_home_method_ref, 0), + SD_BUS_METHOD_WITH_ARGS("RefUnrestricted", + SD_BUS_ARGS("b", please_suspend), + SD_BUS_RESULT("h", send_fd), + bus_home_method_ref, + 0), SD_BUS_METHOD("Release", NULL, NULL, bus_home_method_release, 0), SD_BUS_METHOD_WITH_ARGS("InhibitSuspend", SD_BUS_NO_ARGS, |