[master/rhel7] Handle spaces in inst.repo, kickstart nfs, and url commands (#1109933)

Brian C. Lane bcl at redhat.com
Thu Aug 21 18:30:32 UTC 2014


NFS paths and http urls may have spaces in them. When passed on the
cmdline they should be escaped and when in a kickstart the string should
be quoted.

This changes the anaconda dracut code so that kickstart nfs with spaces
is written using \x20 when output by parse-kickstart and the \x20 is
converted back to a space before mounting the nfs root. For http urls it
converts the spaces to %20 which can be passed through to curl without
any further conversion.

The reason for the conversion is that dracut loops over cmdline args
split by spaces, so they cannot be present in the cmdline or from the
output of parse-kickstart whis is parsed as if it were on the cmdline.

This also depends on a dracut change: mount_nfs needs to quote the
arguments passed to it and when it passes them on to nfs_to_vars.

Resolves: rhbz#1109933
---
 dracut/anaconda-netroot.sh | 7 ++++++-
 dracut/parse-kickstart     | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dracut/anaconda-netroot.sh b/dracut/anaconda-netroot.sh
index 6217953..0a9face 100755
--- a/dracut/anaconda-netroot.sh
+++ b/dracut/anaconda-netroot.sh
@@ -27,9 +27,14 @@ case $repo in
         . /lib/nfs-lib.sh
         info "anaconda mounting NFS repo at $repo"
         str_starts "$repo" "nfsiso:" && repo=nfs:${repo#nfsiso:}
+
+        # Replace hex space with a real one. All uses of repo need to be quoted
+        # after this point.
+        repo=${repo//\\x20/ }
+
         # HACK: work around some Mysterious NFS4 Badness (#811242 and friends)
         # by defaulting to nfsvers=3 when no version is requested
-        nfs_to_var $repo $netif
+        nfs_to_var "$repo" $netif
         if [ "$nfs" != "nfs4" ] && ! strstr "$options" "vers="; then
             repo="nfs:$options,nfsvers=3:$server:$path"
         fi
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index 72076ef..36c6c98 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -74,11 +74,16 @@ class NFS(commands.nfs.FC6_NFS):
         else:
             method="nfs:%s:%s" % (self.server, self.dir)
 
+        # Spaces on the cmdline need to be \x20
+        method = method.replace(" ", "\\x20")
         return "inst.repo=%s" % method
 
 class URL(commands.url.F18_Url):
     def dracut_args(self, args, lineno, obj):
-        args = ["inst.repo=%s" % self.url]
+        # Spaces in the url need to be %20
+        method = self.url.replace(" ", "%20")
+        args = ["inst.repo=%s" % method]
+
         if self.noverifyssl:
             args.append("rd.noverifyssl")
         if self.proxy:
-- 
1.9.3



More information about the anaconda-patches mailing list