nixos/switch-to-configuration: fix installBootLoader escaping

Use a quoted heredoc to inject installBootLoader safely into the script,
and restore the previous invocation of `system` with a single argument so
that shell commands keep working.
This commit is contained in:
Naïm Favier 2022-03-14 02:11:10 +01:00
parent 1073633d89
commit 9bdd2f852c
No known key found for this signature in database
GPG key ID: 49B07322580B7EE2

View file

@ -67,7 +67,10 @@ openlog("nixos", "", LOG_USER);
# Install or update the bootloader.
if ($action eq "switch" || $action eq "boot") {
system('@installBootLoader@', $out) == 0 or exit 1;
chomp(my $installBootLoader = <<'EOFBOOTLOADER');
@installBootLoader@
EOFBOOTLOADER
system("$installBootLoader $out") == 0 or exit 1;
}
# Just in case the new configuration hangs the system, do a sync now.