homework: make sync of identies when resizing homes optional
This is preparation for resizing automatically at login and logout.
This commit is contained in:
+19
-13
@@ -2802,9 +2802,11 @@ int home_resize_luks(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_load_embedded_identity(h, setup->root_fd, header_home, USER_RECONCILE_REQUIRE_NEWER_OR_EQUAL, cache, &embedded_home, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES)) {
|
||||
r = home_load_embedded_identity(h, setup->root_fd, header_home, USER_RECONCILE_REQUIRE_NEWER_OR_EQUAL, cache, &embedded_home, &new_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
log_info("offset = %" PRIu64 ", size = %" PRIu64 ", image = %" PRIu64, setup->partition_offset, setup->partition_size, old_image_size);
|
||||
|
||||
@@ -2910,9 +2912,11 @@ int home_resize_luks(
|
||||
|
||||
log_info("LUKS device growing completed.");
|
||||
} else {
|
||||
r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES)) {
|
||||
r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (S_ISREG(st.st_mode)) {
|
||||
if (user_record_luks_discard(h))
|
||||
@@ -2979,19 +2983,21 @@ int home_resize_luks(
|
||||
|
||||
if (S_ISBLK(st.st_mode) && ioctl(image_fd, BLKRRPART, 0) < 0)
|
||||
log_debug_errno(errno, "BLKRRPART failed on block device, ignoring: %m");
|
||||
} else {
|
||||
} else if (!FLAGS_SET(flags, HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES)) {
|
||||
r = home_store_embedded_identity(new_home, setup->root_fd, h->uid, embedded_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = home_store_header_identity_luks(new_home, setup, header_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (!FLAGS_SET(flags, HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES)) {
|
||||
r = home_store_header_identity_luks(new_home, setup, header_home);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = home_extend_embedded_identity(new_home, h, setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = home_extend_embedded_identity(new_home, h, setup);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (user_record_luks_discard(h))
|
||||
(void) run_fitrim(setup->root_fd);
|
||||
|
||||
+5
-2
@@ -53,10 +53,13 @@ typedef struct HomeSetup {
|
||||
|
||||
/* Various flags for the operation of setting up a home directory */
|
||||
typedef enum HomeSetupFlags {
|
||||
HOME_SETUP_ALREADY_ACTIVATED = 1 << 0, /* Open an already activated home, rather than activate it afresh */
|
||||
HOME_SETUP_ALREADY_ACTIVATED = 1 << 0, /* Open an already activated home, rather than activate it afresh */
|
||||
|
||||
/* CIFS backend: */
|
||||
HOME_SETUP_CIFS_MKDIR = 1 << 1, /* Create CIFS subdir when missing */
|
||||
HOME_SETUP_CIFS_MKDIR = 1 << 1, /* Create CIFS subdir when missing */
|
||||
|
||||
/* Applies only for resize operations */
|
||||
HOME_SETUP_RESIZE_DONT_SYNC_IDENTITIES = 1 << 2, /* Don't sync identity records into home and LUKS header */
|
||||
} HomeSetupFlags;
|
||||
|
||||
int home_setup_done(HomeSetup *setup);
|
||||
|
||||
Reference in New Issue
Block a user