Skip to content

Commit

Permalink
webui: Show error when mounting /boot/efi to a non-EFI partition
Browse files Browse the repository at this point in the history
Resolves: rhbz#2234967
Related: rhbz#2231339
  • Loading branch information
vojtechtrefny committed Aug 30, 2023
1 parent 310b635 commit 2f029a3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ui/webui/src/components/storage/MountPointMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ const isReformatValid = (deviceData, request, requests) => {
});
};

const isDeviceMountPointInvalid = (deviceData, request) => {
const device = request["device-spec"];

if (!device || !request["mount-point"]) {
return [false, ""];
}

// /boot/efi must be on EFI System Partition
if (request["mount-point"] === "/boot/efi") {
if (deviceData[device].formatData.type.v !== "efi") {
return [true, _("/boot/efi must be on a EFI System Partition device")];
}
}

return [false, ""];
};

const getLockedLUKSDevices = (requests, deviceData) => {
const devs = requests?.map(r => r["device-spec"]) || [];

Expand Down Expand Up @@ -233,6 +250,7 @@ const DeviceColumnSelect = ({ deviceData, devices, idPrefix, lockedLUKSDevices,
const DeviceColumn = ({ deviceData, devices, idPrefix, handleRequestChange, lockedLUKSDevices, request, requests }) => {
const device = request["device-spec"];
const duplicatedDevice = isDuplicateRequestField(requests, "device-spec", device);
const [deviceInvalid, errorMessage] = isDeviceMountPointInvalid(deviceData, request);

return (
<Flex direction={{ default: "column" }} spaceItems={{ default: "spaceItemsNone" }}>
Expand All @@ -250,6 +268,12 @@ const DeviceColumn = ({ deviceData, devices, idPrefix, handleRequestChange, lock
{_("Duplicate device.")}
</HelperTextItem>
</HelperText>}
{deviceInvalid &&
<HelperText>
<HelperTextItem variant="error" hasIcon>
{errorMessage}
</HelperTextItem>
</HelperText>}
</Flex>
);
};
Expand Down

0 comments on commit 2f029a3

Please sign in to comment.