installer: Fix mapper name generation for encrypted installation.
authorSascha Wildner <saw@online.de>
Sun, 13 Aug 2017 09:54:42 +0000 (11:54 +0200)
committerSascha Wildner <saw@online.de>
Sun, 13 Aug 2017 09:54:42 +0000 (11:54 +0200)
fn_mapper_name() is supposed to take the mountpoint name, not the
device name.

This actually broke the install in environments where no /dev/serno/...
device was available and both root and /build were selected for
encrypting because the device name would never contain a '/' and so
the mapper name 'root' was returned for both.

usr.sbin/installer/dfuibe_installer/fn_configure.c
usr.sbin/installer/dfuibe_installer/fn_install.c
usr.sbin/installer/dfuibe_installer/fn_subpart_hammer.c
usr.sbin/installer/dfuibe_installer/fn_subpart_ufs.c

index 84189e5..d2d96c4 100644 (file)
@@ -1403,14 +1403,14 @@ mount_target_system(struct i_fn_args *a)
                            a->os_root, cmd_name(a, "AWK"),
                            fsname,
                            a->os_root, cmd_name(a, "AWK"),
-                           fn_mapper_name(subpartition_get_device_name(d_subpart), -1)
+                           fn_mapper_name(subpartition_get_mountpoint(d_subpart), -1)
                            );
                        command_add(cmds,
                            "%s%s %s %s%s",
                            a->os_root,
                             (use_hammer ? cmd_name(a, "MOUNT_HAMMER") :
                                           cmd_name(a, "MOUNT")),
-                           fn_mapper_name(subpartition_get_device_name(d_subpart), 1),
+                           fn_mapper_name(subpartition_get_mountpoint(d_subpart), 1),
                            a->os_root, a->cfg_root);
                } else {
                        command_add(cmds,
@@ -1469,7 +1469,7 @@ mount_target_system(struct i_fn_args *a)
                        if (strcmp(name, "swap") == 0)
                                continue;
                        /* encrypted root already mounted */
-                       if (strcmp(name, fn_mapper_name(subpartition_get_device_name(d_subpart), -1)) == 0)
+                       if (strcmp(name, fn_mapper_name(subpartition_get_mountpoint(d_subpart), -1)) == 0)
                                continue;
 
                        if ((word = strtok(NULL, " \t")) == NULL)
index dc10c3f..a8e1a69 100644 (file)
@@ -240,14 +240,14 @@ fn_install_os(struct i_fn_args *a)
                                command_add(cmds, "%s%s /dev/%s %smnt%s",
                                    a->os_root, cmd_name(a, "MOUNT_HAMMER"),
                                    (subpartition_is_encrypted(sp) ?
-                                    fn_mapper_name(subpartition_get_device_name(sp), 0) : subpartition_get_device_name(sp)),
+                                    fn_mapper_name(subpartition_get_mountpoint(sp), 0) : subpartition_get_device_name(sp)),
                                    a->os_root,
                                    subpartition_get_mountpoint(sp));
                        } else {
                                command_add(cmds, "%s%s /dev/%s %smnt%s",
                                    a->os_root, cmd_name(a, "MOUNT"),
                                    subpartition_is_encrypted(sp) ?
-                                    fn_mapper_name(subpartition_get_device_name(sp), 0) : subpartition_get_device_name(sp),
+                                    fn_mapper_name(subpartition_get_mountpoint(sp), 0) : subpartition_get_device_name(sp),
                                    a->os_root,
                                    subpartition_get_mountpoint(sp));
                        }
@@ -293,7 +293,7 @@ fn_install_os(struct i_fn_args *a)
                        if (subpartition_is_encrypted(sp)) {
                                command_add(cmds, "%s%s /dev/%s %smnt%s",
                                    a->os_root, cmd_name(a, "MOUNT"),
-                                   fn_mapper_name(subpartition_get_device_name(sp), 0),
+                                   fn_mapper_name(subpartition_get_mountpoint(sp), 0),
                                    a->os_root,
                                    subpartition_get_mountpoint(sp));
                        } else {
@@ -613,7 +613,7 @@ fn_install_os(struct i_fn_args *a)
                                            a->os_root, cmd_name(a, "ECHO"),
                                            fsname,
                                            subpartition_get_device_name(sp),
-                                           fn_mapper_name(subpartition_get_device_name(sp), -1),
+                                           fn_mapper_name(subpartition_get_mountpoint(sp), -1),
                                            a->os_root);
                                } else {
                                        command_add(cmds,
@@ -633,12 +633,12 @@ fn_install_os(struct i_fn_args *a)
                        } else if (subpartition_is_encrypted(sp)) {
                                command_add(cmds, "%s%s '%s\t/dev/%s\tnone\tnone' >>%smnt/etc/crypttab",
                                    a->os_root, cmd_name(a, "ECHO"),
-                                   fn_mapper_name(subpartition_get_device_name(sp), -1),
+                                   fn_mapper_name(subpartition_get_mountpoint(sp), -1),
                                    subpartition_get_device_name(sp),
                                    a->os_root);
                                command_add(cmds, "%s%s '/dev/%s\t\t%s\t\t%s\trw\t\t2\t2' >>%smnt/etc/fstab",
                                    a->os_root, cmd_name(a, "ECHO"),
-                                   fn_mapper_name(subpartition_get_device_name(sp), 0),
+                                   fn_mapper_name(subpartition_get_mountpoint(sp), 0),
                                    subpartition_get_mountpoint(sp),
                                    fsname,
                                    a->os_root);
index 80b4df9..8eb7c09 100644 (file)
@@ -255,14 +255,14 @@ create_subpartitions(struct i_fn_args *a)
                                    "%s%s -d /tmp/t1 luksOpen /dev/%s %s",
                                    a->os_root, cmd_name(a, "CRYPTSETUP"),
                                    subpartition_get_device_name(sp),
-                                   fn_mapper_name(subpartition_get_device_name(sp), -1));
+                                   fn_mapper_name(subpartition_get_mountpoint(sp), -1));
                        }
                        ham_name = construct_lname(subpartition_get_mountpoint(sp));
                        command_add(cmds, "%s%s -f -L %s /dev/%s",
                            a->os_root, cmd_name(a, "NEWFS_HAMMER"),
                            ham_name,
                            subpartition_is_encrypted(sp) ?
-                           fn_mapper_name(subpartition_get_device_name(sp), 0) : subpartition_get_device_name(sp));
+                           fn_mapper_name(subpartition_get_mountpoint(sp), 0) : subpartition_get_device_name(sp));
                        free(ham_name);
                }
        }
index ad68b30..0cf1f76 100644 (file)
@@ -233,13 +233,13 @@ create_subpartitions(struct i_fn_args *a)
                            "%s%s -d /tmp/t1 luksOpen /dev/%s %s",
                            a->os_root, cmd_name(a, "CRYPTSETUP"),
                            subpartition_get_device_name(sp),
-                           fn_mapper_name(subpartition_get_device_name(sp), -1));
+                           fn_mapper_name(subpartition_get_mountpoint(sp), -1));
                        command_add(cmds, "%s%s%s -b %ld -f %ld /dev/mapper/%s",
                            a->os_root, cmd_name(a, "NEWFS"),
                            subpartition_is_softupdated(sp) ? " -U" : "",
                            subpartition_get_bsize(sp),
                            subpartition_get_fsize(sp),
-                           fn_mapper_name(subpartition_get_device_name(sp), -1));
+                           fn_mapper_name(subpartition_get_mountpoint(sp), -1));
                } else {
                        command_add(cmds, "%s%s%s -b %ld -f %ld /dev/%s",
                            a->os_root, cmd_name(a, "NEWFS"),