]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut): enforce that hostonly is set for hostonly_install
authorJo Zzsi <jozzsicsataban@gmail.com>
Sat, 2 Aug 2025 15:34:04 +0000 (11:34 -0400)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 13 Sep 2025 13:47:12 +0000 (09:47 -0400)
Before honoring `-H` command line argument, check if
hostonly is actually set.

Here is an examples where `inst` is called even in generic
mode which would result in picking up files from the host
from the /etc directory.

```
inst_simple -H "/etc/nvme/hostnqn"
```

dracut-init.sh

index b57b41339a3ebf4a7c33e6d4ceacacb6fa29cf7a..d8c52bc10c5336c483e504e3a5f26128fc2b8632 100755 (executable)
@@ -240,7 +240,7 @@ inst_dir() {
 inst() {
     local dstdir="${dstdir:-"$initdir"}"
     local _ret _hostonly_install
-    if [[ $1 == "-H" ]]; then
+    if [[ $1 == "-H" ]] && [[ $hostonly ]]; then
         _hostonly_install="-H"
         shift
     fi
@@ -257,7 +257,7 @@ inst() {
 inst_simple() {
     local dstdir="${dstdir:-"$initdir"}"
     local _ret _hostonly_install
-    if [[ $1 == "-H" ]]; then
+    if [[ $1 == "-H" ]] && [[ $hostonly ]]; then
         _hostonly_install="-H"
         shift
     fi
@@ -278,7 +278,7 @@ inst_simple() {
 
 inst_symlink() {
     local _ret _hostonly_install
-    if [[ $1 == "-H" ]]; then
+    if [[ $1 == "-H" ]] && [[ $hostonly ]]; then
         _hostonly_install="-H"
         shift
     fi
@@ -296,7 +296,7 @@ inst_symlink() {
 inst_multiple() {
     local dstdir="${dstdir:-"$initdir"}"
     local _ret _hostonly_install
-    if [[ $1 == "-H" ]]; then
+    if [[ $1 == "-H" ]] && [[ $hostonly ]]; then
         _hostonly_install="-H"
         shift
     fi