mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
homework: use HomeSetup in home_create_luks() too
We use it for all other LUKS operations these days, and for all home_create_xyz() calls for other backends, let's use it for the LUKS backend too.
This commit is contained in:
parent
93a5fe3e65
commit
bc5890c671
@ -1992,6 +1992,7 @@ static int home_truncate(
|
|||||||
|
|
||||||
int home_create_luks(
|
int home_create_luks(
|
||||||
UserRecord *h,
|
UserRecord *h,
|
||||||
|
HomeSetup *setup,
|
||||||
const PasswordCache *cache,
|
const PasswordCache *cache,
|
||||||
char **effective_passwords,
|
char **effective_passwords,
|
||||||
UserRecord **ret_home) {
|
UserRecord **ret_home) {
|
||||||
@ -2004,13 +2005,14 @@ int home_create_luks(
|
|||||||
sd_id128_t partition_uuid, fs_uuid, luks_uuid, disk_uuid;
|
sd_id128_t partition_uuid, fs_uuid, luks_uuid, disk_uuid;
|
||||||
_cleanup_(loop_device_unrefp) LoopDevice *loop = NULL;
|
_cleanup_(loop_device_unrefp) LoopDevice *loop = NULL;
|
||||||
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
|
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
|
||||||
_cleanup_close_ int image_fd = -1, root_fd = -1;
|
_cleanup_close_ int image_fd = -1;
|
||||||
const char *fstype, *ip;
|
const char *fstype, *ip;
|
||||||
struct statfs sfs;
|
struct statfs sfs;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(h);
|
assert(h);
|
||||||
assert(h->storage < 0 || h->storage == USER_LUKS);
|
assert(h->storage < 0 || h->storage == USER_LUKS);
|
||||||
|
assert(setup);
|
||||||
assert(ret_home);
|
assert(ret_home);
|
||||||
|
|
||||||
r = dlopen_cryptsetup();
|
r = dlopen_cryptsetup();
|
||||||
@ -2256,17 +2258,17 @@ int home_create_luks(
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
root_fd = open(subdir, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
setup->root_fd = open(subdir, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||||
if (root_fd < 0) {
|
if (setup->root_fd < 0) {
|
||||||
r = log_error_errno(errno, "Failed to open user directory in mounted image file: %m");
|
r = log_error_errno(errno, "Failed to open user directory in mounted image file: %m");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = home_populate(h, root_fd);
|
r = home_populate(h, setup->root_fd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = home_sync_and_statfs(root_fd, &sfs);
|
r = home_sync_and_statfs(setup->root_fd, &sfs);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -2296,12 +2298,12 @@ int home_create_luks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user_record_luks_offline_discard(h)) {
|
if (user_record_luks_offline_discard(h)) {
|
||||||
r = run_fitrim(root_fd);
|
r = run_fitrim(setup->root_fd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
root_fd = safe_close(root_fd);
|
setup->root_fd = safe_close(setup->root_fd);
|
||||||
|
|
||||||
r = umount_verbose(LOG_ERR, HOME_RUNTIME_WORK_DIR, UMOUNT_NOFOLLOW);
|
r = umount_verbose(LOG_ERR, HOME_RUNTIME_WORK_DIR, UMOUNT_NOFOLLOW);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -2370,7 +2372,7 @@ int home_create_luks(
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
/* Let's close all files before we unmount the file system, to avoid EBUSY */
|
/* Let's close all files before we unmount the file system, to avoid EBUSY */
|
||||||
root_fd = safe_close(root_fd);
|
setup->root_fd = safe_close(setup->root_fd);
|
||||||
|
|
||||||
if (mounted)
|
if (mounted)
|
||||||
(void) umount_verbose(LOG_WARNING, HOME_RUNTIME_WORK_DIR, UMOUNT_NOFOLLOW);
|
(void) umount_verbose(LOG_WARNING, HOME_RUNTIME_WORK_DIR, UMOUNT_NOFOLLOW);
|
||||||
|
@ -13,7 +13,7 @@ int home_trim_luks(UserRecord *h);
|
|||||||
|
|
||||||
int home_store_header_identity_luks(UserRecord *h, HomeSetup *setup, UserRecord *old_home);
|
int home_store_header_identity_luks(UserRecord *h, HomeSetup *setup, UserRecord *old_home);
|
||||||
|
|
||||||
int home_create_luks(UserRecord *h, const PasswordCache *cache, char **effective_passwords, UserRecord **ret_home);
|
int home_create_luks(UserRecord *h, HomeSetup *setup, const PasswordCache *cache, char **effective_passwords, UserRecord **ret_home);
|
||||||
|
|
||||||
int home_get_state_luks(UserRecord *h, HomeSetup *setup);
|
int home_get_state_luks(UserRecord *h, HomeSetup *setup);
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ static int home_create(UserRecord *h, UserRecord **ret_home) {
|
|||||||
switch (user_record_storage(h)) {
|
switch (user_record_storage(h)) {
|
||||||
|
|
||||||
case USER_LUKS:
|
case USER_LUKS:
|
||||||
r = home_create_luks(h, &cache, effective_passwords, &new_home);
|
r = home_create_luks(h, &setup, &cache, effective_passwords, &new_home);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USER_DIRECTORY:
|
case USER_DIRECTORY:
|
||||||
|
Loading…
Reference in New Issue
Block a user