diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-10-18 13:59:29 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-10-18 22:45:19 +0200 |
commit | a74e2e447fde027b74ca9768a0c27d3408b95dac (patch) | |
tree | 8f13745e8c2a520f7ee31224d9307709982bdcad /src/home/homework.c | |
parent | homework: unify code that opens the backing image file in open_image_file() (diff) | |
download | systemd-a74e2e447fde027b74ca9768a0c27d3408b95dac.tar.xz systemd-a74e2e447fde027b74ca9768a0c27d3408b95dac.zip |
homework: move allocation/destruction into outer/generic scope
Previously in most cases we'd allocate the HomeSetup context object
in generic code in homework.c. But for some cases we allocated them
instead inside the specific code in homework-{cifs,directory,luks}.c
Let's clean that up, and systematically allocate it in the outer
"entrypoint" calls in homework.c instead of the inner ones.
This doesn't change much in behaviour (i.e. it just means when something
fails we'll now clean it up one stack frame further up). But it will
allow is to more easily work with the context objects, since we'll have
them around in all stack frames.
Diffstat (limited to '')
-rw-r--r-- | src/home/homework.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/home/homework.c b/src/home/homework.c index 01286220cb..78ca979fae 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -759,8 +759,9 @@ int home_refresh( } static int home_activate(UserRecord *h, UserRecord **ret_home) { - _cleanup_(password_cache_free) PasswordCache cache = {}; + _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT; _cleanup_(user_record_unrefp) UserRecord *new_home = NULL; + _cleanup_(password_cache_free) PasswordCache cache = {}; int r; assert(h); @@ -791,7 +792,7 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) { switch (user_record_storage(h)) { case USER_LUKS: - r = home_activate_luks(h, &cache, &new_home); + r = home_activate_luks(h, &setup, &cache, &new_home); if (r < 0) return r; @@ -800,14 +801,14 @@ static int home_activate(UserRecord *h, UserRecord **ret_home) { case USER_SUBVOLUME: case USER_DIRECTORY: case USER_FSCRYPT: - r = home_activate_directory(h, &cache, &new_home); + r = home_activate_directory(h, &setup, &cache, &new_home); if (r < 0) return r; break; case USER_CIFS: - r = home_activate_cifs(h, &cache, &new_home); + r = home_activate_cifs(h, &setup, &cache, &new_home); if (r < 0) return r; @@ -1163,6 +1164,7 @@ static int determine_default_storage(UserStorage *ret) { static int home_create(UserRecord *h, UserRecord **ret_home) { _cleanup_(strv_free_erasep) char **effective_passwords = NULL; + _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT; _cleanup_(user_record_unrefp) UserRecord *new_home = NULL; _cleanup_(password_cache_free) PasswordCache cache = {}; UserStorage new_storage = _USER_STORAGE_INVALID; @@ -1238,7 +1240,7 @@ static int home_create(UserRecord *h, UserRecord **ret_home) { break; case USER_CIFS: - r = home_create_cifs(h, &new_home); + r = home_create_cifs(h, &setup, &new_home); break; default: |