int home_activate_cifs(
UserRecord *h,
+ HomeSetup *setup,
PasswordCache *cache,
UserRecord **ret_home) {
- _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT;
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
const char *hdo, *hd;
int r;
assert(h);
assert(user_record_storage(h) == USER_CIFS);
+ assert(setup);
assert(ret_home);
if (!h->cifs_service)
assert_se(hdo = user_record_home_directory(h));
hd = strdupa_safe(hdo); /* copy the string out, since it might change later in the home record object */
- r = home_setup_cifs(h, 0, &setup);
+ r = home_setup_cifs(h, 0, setup);
if (r < 0)
return r;
- r = home_refresh(h, &setup, NULL, cache, NULL, &new_home);
+ r = home_refresh(h, setup, NULL, cache, NULL, &new_home);
if (r < 0)
return r;
- setup.root_fd = safe_close(setup.root_fd);
+ setup->root_fd = safe_close(setup->root_fd);
r = home_move_mount(NULL, hd);
if (r < 0)
return r;
- setup.undo_mount = false;
+ setup->undo_mount = false;
log_info("Everything completed.");
return 1;
}
-int home_create_cifs(UserRecord *h, UserRecord **ret_home) {
- _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT;
+int home_create_cifs(UserRecord *h, HomeSetup *setup, UserRecord **ret_home) {
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL;
_cleanup_(closedirp) DIR *d = NULL;
_cleanup_close_ int copy = -1;
assert(h);
assert(user_record_storage(h) == USER_CIFS);
+ assert(setup);
assert(ret_home);
if (!h->cifs_service)
return log_error_errno(errno, "Unable to detect whether /sbin/mount.cifs exists: %m");
}
- r = home_setup_cifs(h, 0, &setup);
+ r = home_setup_cifs(h, 0, setup);
if (r < 0)
return r;
- copy = fcntl(setup.root_fd, F_DUPFD_CLOEXEC, 3);
+ copy = fcntl(setup->root_fd, F_DUPFD_CLOEXEC, 3);
if (copy < 0)
return -errno;
if (errno != 0)
return log_error_errno(errno, "Failed to detect if CIFS directory is empty: %m");
- r = home_populate(h, setup.root_fd);
+ r = home_populate(h, setup->root_fd);
if (r < 0)
return r;
- r = home_sync_and_statfs(setup.root_fd, NULL);
+ r = home_sync_and_statfs(setup->root_fd, NULL);
if (r < 0)
return r;
int home_setup_cifs(UserRecord *h, HomeSetupFlags flags, HomeSetup *setup);
-int home_activate_cifs(UserRecord *h, PasswordCache *cache, UserRecord **ret_home);
+int home_activate_cifs(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
-int home_create_cifs(UserRecord *h, UserRecord **ret_home);
+int home_create_cifs(UserRecord *h, HomeSetup *setup, UserRecord **ret_home);
int home_activate_directory(
UserRecord *h,
+ HomeSetup *setup,
PasswordCache *cache,
UserRecord **ret_home) {
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL, *header_home = NULL;
- _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT;
const char *hdo, *hd, *ipo, *ip;
int r;
assert(h);
assert(IN_SET(user_record_storage(h), USER_DIRECTORY, USER_SUBVOLUME, USER_FSCRYPT));
+ assert(setup);
assert(ret_home);
assert_se(ipo = user_record_image_path(h));
assert_se(hdo = user_record_home_directory(h));
hd = strdupa_safe(hdo);
- r = home_setup(h, 0, cache, &setup, &header_home);
+ r = home_setup(h, 0, cache, setup, &header_home);
if (r < 0)
return r;
- r = home_refresh(h, &setup, header_home, cache, NULL, &new_home);
+ r = home_refresh(h, setup, header_home, cache, NULL, &new_home);
if (r < 0)
return r;
- setup.root_fd = safe_close(setup.root_fd);
+ setup->root_fd = safe_close(setup->root_fd);
/* Create mount point to mount over if necessary */
if (!path_equal(ip, hd))
#include "user-record.h"
int home_setup_directory(UserRecord *h, HomeSetup *setup);
-int home_activate_directory(UserRecord *h, PasswordCache *cache, UserRecord **ret_home);
+int home_activate_directory(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
int home_create_directory_or_subvolume(UserRecord *h, UserRecord **ret_home);
int home_resize_directory(UserRecord *h, HomeSetupFlags flags, PasswordCache *cache, HomeSetup *setup, UserRecord **ret_home);
int home_activate_luks(
UserRecord *h,
+ HomeSetup *setup,
PasswordCache *cache,
UserRecord **ret_home) {
_cleanup_(user_record_unrefp) UserRecord *new_home = NULL, *luks_home_record = NULL;
- _cleanup_(home_setup_done) HomeSetup setup = HOME_SETUP_INIT;
uint64_t host_size, encrypted_size;
const char *hdo, *hd;
struct statfs sfs;
assert(h);
assert(user_record_storage(h) == USER_LUKS);
+ assert(setup);
assert(ret_home);
r = dlopen_cryptsetup();
assert_se(hdo = user_record_home_directory(h));
hd = strdupa_safe(hdo); /* copy the string out, since it might change later in the home record object */
- r = home_get_state_luks(h, &setup);
+ r = home_get_state_luks(h, setup);
if (r < 0)
return r;
if (r > 0)
- return log_error_errno(SYNTHETIC_ERRNO(EEXIST), "Device mapper device %s already exists, refusing.", setup.dm_node);
+ return log_error_errno(SYNTHETIC_ERRNO(EEXIST), "Device mapper device %s already exists, refusing.", setup->dm_node);
r = home_setup_luks(
h,
0,
NULL,
cache,
- &setup,
+ setup,
&luks_home_record);
if (r < 0)
return r;
- r = block_get_size_by_fd(setup.loop->fd, &host_size);
+ r = block_get_size_by_fd(setup->loop->fd, &host_size);
if (r < 0)
return log_error_errno(r, "Failed to get loopback block device size: %m");
- r = block_get_size_by_path(setup.dm_node, &encrypted_size);
+ r = block_get_size_by_path(setup->dm_node, &encrypted_size);
if (r < 0)
return log_error_errno(r, "Failed to get LUKS block device size: %m");
r = home_refresh(
h,
- &setup,
+ setup,
luks_home_record,
cache,
&sfs,
if (r < 0)
return r;
- r = home_extend_embedded_identity(new_home, h, &setup);
+ r = home_extend_embedded_identity(new_home, h, setup);
if (r < 0)
return r;
- setup.root_fd = safe_close(setup.root_fd);
+ setup->root_fd = safe_close(setup->root_fd);
r = home_move_mount(user_record_user_name_and_realm(h), hd);
if (r < 0)
return r;
- setup.undo_mount = false;
- setup.do_offline_fitrim = false;
+ setup->undo_mount = false;
+ setup->do_offline_fitrim = false;
- loop_device_relinquish(setup.loop);
+ loop_device_relinquish(setup->loop);
- r = sym_crypt_deactivate_by_name(NULL, setup.dm_name, CRYPT_DEACTIVATE_DEFERRED);
+ r = sym_crypt_deactivate_by_name(NULL, setup->dm_name, CRYPT_DEACTIVATE_DEFERRED);
if (r < 0)
log_warning_errno(r, "Failed to relinquish DM device, ignoring: %m");
- setup.undo_dm = false;
- setup.do_offline_fallocate = false;
- setup.do_mark_clean = false;
+ setup->undo_dm = false;
+ setup->do_offline_fallocate = false;
+ setup->do_mark_clean = false;
log_info("Everything completed.");
int home_setup_luks(UserRecord *h, HomeSetupFlags flags, const char *force_image_path, PasswordCache *cache, HomeSetup *setup, UserRecord **ret_luks_home);
-int home_activate_luks(UserRecord *h, PasswordCache *cache, UserRecord **ret_home);
+int home_activate_luks(UserRecord *h, HomeSetup *setup, PasswordCache *cache, UserRecord **ret_home);
int home_deactivate_luks(UserRecord *h);
int home_trim_luks(UserRecord *h);
}
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);
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;
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;
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;
break;
case USER_CIFS:
- r = home_create_cifs(h, &new_home);
+ r = home_create_cifs(h, &setup, &new_home);
break;
default: