modules/filesystems: disallow non-empty fstab fields (#22803)
It was possible to pass empty strings / strings with only separator characters; this lead to broken fstab formatting.
This commit is contained in:
parent
cb2499acd0
commit
91d0260feb
@ -5,6 +5,11 @@ with utils;
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
addCheckDesc = desc: elemType: check: types.addCheck elemType check
|
||||||
|
// { description = "${elemType.description} (with check: ${desc})"; };
|
||||||
|
nonEmptyStr = addCheckDesc "non-empty" types.str
|
||||||
|
(x: x != "" && ! (all (c: c == " " || c == "\t") (stringToCharacters x)));
|
||||||
|
|
||||||
fileSystems' = toposort fsBefore (attrValues config.fileSystems);
|
fileSystems' = toposort fsBefore (attrValues config.fileSystems);
|
||||||
|
|
||||||
fileSystems = if fileSystems' ? "result"
|
fileSystems = if fileSystems' ? "result"
|
||||||
@ -26,21 +31,21 @@ let
|
|||||||
|
|
||||||
mountPoint = mkOption {
|
mountPoint = mkOption {
|
||||||
example = "/mnt/usb";
|
example = "/mnt/usb";
|
||||||
type = types.str;
|
type = nonEmptyStr;
|
||||||
description = "Location of the mounted the file system.";
|
description = "Location of the mounted the file system.";
|
||||||
};
|
};
|
||||||
|
|
||||||
device = mkOption {
|
device = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
example = "/dev/sda";
|
example = "/dev/sda";
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr nonEmptyStr;
|
||||||
description = "Location of the device.";
|
description = "Location of the device.";
|
||||||
};
|
};
|
||||||
|
|
||||||
fsType = mkOption {
|
fsType = mkOption {
|
||||||
default = "auto";
|
default = "auto";
|
||||||
example = "ext3";
|
example = "ext3";
|
||||||
type = types.str;
|
type = nonEmptyStr;
|
||||||
description = "Type of the file system.";
|
description = "Type of the file system.";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,7 +53,7 @@ let
|
|||||||
default = [ "defaults" ];
|
default = [ "defaults" ];
|
||||||
example = [ "data=journal" ];
|
example = [ "data=journal" ];
|
||||||
description = "Options used to mount the file system.";
|
description = "Options used to mount the file system.";
|
||||||
type = types.listOf types.str;
|
type = types.listOf nonEmptyStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -67,7 +72,7 @@ let
|
|||||||
label = mkOption {
|
label = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
example = "root-partition";
|
example = "root-partition";
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr nonEmptyStr;
|
||||||
description = "Label of the device (if any).";
|
description = "Label of the device (if any).";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user