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

bcl installerbot-noreply at redhat.com
Tue Jun 2 00:31:18 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

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
(cherry picked from commit b7f2addc38a666085535a4b078f451ee0f2d8594)

Related: rhbz#1196721
---
 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 fba96c2..1f38b5a 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -88,11 +88,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:


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/7259c9990267a4bc0fca9241d3c94ecd4ef292b7


More information about the anaconda-patches mailing list