diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-09-18 19:37:05 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-09-18 22:35:36 +0200 |
commit | f9d525ae558105bf7fd77ad76e4fdb135bb9f634 (patch) | |
tree | a053132b43fd32b75b16a8f539e2dd7ea253aaab /src/home/homed-home.c | |
parent | homed: make sure our worker processes finish before we exit (diff) | |
download | systemd-f9d525ae558105bf7fd77ad76e4fdb135bb9f634.tar.xz systemd-f9d525ae558105bf7fd77ad76e4fdb135bb9f634.zip |
homed: make clean that --storage=directory --image-path=/dev/some-block-device is not supported
The directory backend needs a file system path, and not a raw block
device. That's only supported for the LUKS2 backend.
Let's make this clearer in the man page and also generate a better error
message if attempted anyway.
Fixes: #17068
Diffstat (limited to 'src/home/homed-home.c')
-rw-r--r-- | src/home/homed-home.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/home/homed-home.c b/src/home/homed-home.c index 5504173545..e4757c724a 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -1280,15 +1280,22 @@ int home_create(Home *h, UserRecord *secret, sd_bus_error *error) { assert(h); switch (home_get_state(h)) { - case HOME_INACTIVE: + case HOME_INACTIVE: { + int t; + if (h->record->storage < 0) break; /* if no storage is defined we don't know what precisely to look for, hence * HOME_INACTIVE is OK in that case too. */ - if (IN_SET(user_record_test_image_path(h->record), USER_TEST_MAYBE, USER_TEST_UNDEFINED)) + t = user_record_test_image_path(h->record); + if (IN_SET(t, USER_TEST_MAYBE, USER_TEST_UNDEFINED)) break; /* And if the image path test isn't conclusive, let's also go on */ - _fallthrough_; + if (IN_SET(t, -EBADFD, -ENOTDIR)) + return sd_bus_error_setf(error, BUS_ERROR_HOME_EXISTS, "Selected home image of user %s already exists or has wrong inode type.", h->user_name); + + return sd_bus_error_setf(error, BUS_ERROR_HOME_EXISTS, "Selected home image of user %s already exists.", h->user_name); + } case HOME_UNFIXATED: case HOME_DIRTY: return sd_bus_error_setf(error, BUS_ERROR_HOME_EXISTS, "Home of user %s already exists.", h->user_name); |