There's absolutely no need for execWithRedirect() and friends to care about $PATH. What they should do is log a warning when somebody manually specifies a full path, because that's bad behavior. --- anaconda | 3 +-- baseudev.py | 4 ++-- iutil.py | 13 +++++++++---- livecd.py | 3 +-- packages.py | 5 ++--- storage/devicelibs/crypto.py | 6 ++---- storage/devicelibs/swap.py | 6 ++---- storage/fcoe.py | 21 +++++++-------------- storage/formats/fs.py | 10 +++------- textw/timezone_text.py | 2 +- yuminstall.py | 1 - 11 files changed, 30 insertions(+), 44 deletions(-) diff --git a/anaconda b/anaconda index 858db9f..44f6def 100755 --- a/anaconda +++ b/anaconda @@ -401,8 +401,7 @@ def createSshKey(algorithm, keyfile): so = "/tmp/ssh-keygen-%s-stdout.log" % (algorithm,) se = "/tmp/ssh-keygen-%s-stderr.log" % (algorithm,) - iutil.execWithRedirect('ssh-keygen', argv, stdout=so, stderr=se, - searchPath=1) + iutil.execWithRedirect('ssh-keygen', argv, stdout=so, stderr=se) def fork_orphan(): """Forks an orphan. diff --git a/baseudev.py b/baseudev.py index 63cda36..3d9ee45 100644 --- a/baseudev.py +++ b/baseudev.py @@ -82,11 +82,11 @@ def udev_settle(): # lots of disks, or with slow disks argv = ["settle", "--timeout=300"] - iutil.execWithRedirect("udevadm", argv, stderr="/dev/null", searchPath=1) + iutil.execWithRedirect("udevadm", argv, stderr="/dev/null") def udev_trigger(subsystem=None, action="add"): argv = ["trigger", "--action=%s" % action] if subsystem: argv.append("--subsystem-match=%s" % subsystem) - iutil.execWithRedirect("udevadm", argv, stderr="/dev/null", searchPath=1) + iutil.execWithRedirect("udevadm", argv, stderr="/dev/null") diff --git a/iutil.py b/iutil.py index ea55aec..a568ff7 100644 --- a/iutil.py +++ b/iutil.py @@ -68,16 +68,15 @@ class tee(threading.Thread): # @param stdin The file descriptor to read stdin from. # @param stdout The file descriptor to redirect stdout to. # @param stderr The file descriptor to redirect stderr to. -# @param searchPath Should command be searched for in $PATH? # @param root The directory to chroot to before running command. # @return The return code of command. def execWithRedirect(command, argv, stdin = None, stdout = None, - stderr = None, searchPath = 0, root = '/'): + stderr = None, root = '/'): def chroot (): os.chroot(root) - if not searchPath and not os.access (command, os.X_OK): - raise RuntimeError, command + " can not be run" + if command.startswith('/'): + log.warning("'%s' specified as full path" % (command,)) stdinclose = stdoutclose = stderrclose = lambda : None @@ -182,6 +181,9 @@ def execWithCapture(command, argv, stdin = None, stderr = None, root='/'): stdinclose() stderrclose() + if command.startswith('/'): + log.warning("'%s' specified as full path" % (command,)) + stdinclose = stderrclose = lambda : None rc = "" argv = list(argv) @@ -247,6 +249,9 @@ def execWithCallback(command, argv, stdin = None, stdout = None, stdoutclose() stderrclose() + if command.startswith('/'): + log.warning("'%s' specified as full path" % (command,)) + stdinclose = stdoutclose = stderrclose = lambda : None argv = list(argv) diff --git a/livecd.py b/livecd.py index c3449f5..47f049c 100644 --- a/livecd.py +++ b/livecd.py @@ -245,8 +245,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend): "random", rootDevice.path], stdout="/dev/tty5", - stderr="/dev/tty5", - searchPath = 1) + stderr="/dev/tty5") # and now set the uuid in the storage layer rootDevice.updateSysfsPath() iutil.notify_kernel("/sys%s" %rootDevice.sysfsPath) diff --git a/packages.py b/packages.py index ce304f7..3d30635 100644 --- a/packages.py +++ b/packages.py @@ -92,8 +92,7 @@ def turnOnFilesystems(anaconda): # turn off any swaps that we didn't turn on # needed for live installs iutil.execWithRedirect("swapoff", ["-a"], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") anaconda.id.storage.devicetree.teardownAll() upgrade_migrate = False @@ -321,7 +320,7 @@ def recreateInitrd (kernelTag, instRoot): iutil.execWithRedirect("/sbin/new-kernel-pkg", [ "--mkinitrd", "--dracut", "--depmod", "--install", kernelTag ], stdout = "/dev/null", stderr = "/dev/null", - searchPath = 1, root = instRoot) + root = instRoot) def betaNagScreen(anaconda): publicBetas = { "Red Hat Linux": "Red Hat Linux Public Beta", diff --git a/storage/devicelibs/crypto.py b/storage/devicelibs/crypto.py index 5e7a824..136435d 100644 --- a/storage/devicelibs/crypto.py +++ b/storage/devicelibs/crypto.py @@ -147,8 +147,7 @@ def luks_add_key(device, rc = iutil.execWithRedirect("cryptsetup", params, stdin = p[0], stdout = "/dev/tty5", - stderr = "/dev/tty5", - searchPath = 1) + stderr = "/dev/tty5") os.close(p[0]) if rc: @@ -185,8 +184,7 @@ def luks_remove_key(device, rc = iutil.execWithRedirect("cryptsetup", params, stdin = p[0], stdout = "/dev/tty5", - stderr = "/dev/tty5", - searchPath = 1) + stderr = "/dev/tty5") os.close(p[0]) if rc: diff --git a/storage/devicelibs/swap.py b/storage/devicelibs/swap.py index d83c730..d037d80 100644 --- a/storage/devicelibs/swap.py +++ b/storage/devicelibs/swap.py @@ -86,8 +86,7 @@ def swapon(device, priority=None): rc = iutil.execWithRedirect("swapon", argv, stderr = "/dev/tty5", - stdout = "/dev/tty5", - searchPath=1) + stdout = "/dev/tty5") if rc: raise SwapError("swapon failed for '%s'" % device) @@ -95,8 +94,7 @@ def swapon(device, priority=None): def swapoff(device): rc = iutil.execWithRedirect("swapoff", [device], stderr = "/dev/tty5", - stdout = "/dev/tty5", - searchPath=1) + stdout = "/dev/tty5") if rc: raise SwapError("swapoff failed for '%s'" % device) diff --git a/storage/fcoe.py b/storage/fcoe.py index 0d48957..cd52bc8 100644 --- a/storage/fcoe.py +++ b/storage/fcoe.py @@ -34,8 +34,7 @@ def has_fcoe(): global _fcoe_module_loaded if not _fcoe_module_loaded: iutil.execWithRedirect("modprobe", [ "fcoe" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") _fcoe_module_loaded = True return os.access("/sys/module/fcoe", os.X_OK) @@ -71,8 +70,7 @@ class fcoe(object): # I have no clue how long we need to wait, this ought to do the trick time.sleep(10) iutil.execWithRedirect("udevadm", [ "settle" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") if intf: w.pop() @@ -106,8 +104,7 @@ class fcoe(object): return iutil.execWithRedirect("lldpad", [ "-d" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") self.lldpadStarted = True def _startFcoemon(self): @@ -115,8 +112,7 @@ class fcoe(object): return iutil.execWithRedirect("fcoemon", [ ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") self.fcoemonStarted = True def addSan(self, nic, dcb=False, intf=None): @@ -126,18 +122,15 @@ class fcoe(object): log.info("Activating FCoE SAN attached to %s, dcb: %s" % (nic, dcb)) iutil.execWithRedirect("ip", [ "link", "set", nic, "up" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") if dcb: self._startLldpad() iutil.execWithRedirect("dcbtool", [ "sc", nic, "dcb", "on" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") iutil.execWithRedirect("dcbtool", [ "sc", nic, "app:fcoe", "e:1", "a:1", "w:1" ], - stdout = "/dev/tty5", stderr="/dev/tty5", - searchPath = 1) + stdout = "/dev/tty5", stderr="/dev/tty5") self._startFcoemon() else: f = open("/sys/module/fcoe/parameters/create", "w") diff --git a/storage/formats/fs.py b/storage/formats/fs.py index 41538c0..2fe9e80 100644 --- a/storage/formats/fs.py +++ b/storage/formats/fs.py @@ -399,8 +399,7 @@ class FS(DeviceFormat): rc = iutil.execWithRedirect(self.migratefsProg, argv, stdout = "/dev/tty5", - stderr = "/dev/tty5", - searchPath = 1) + stderr = "/dev/tty5") except Exception as e: raise FSMigrateError("filesystem migration failed: %s" % e, self.device) @@ -550,8 +549,7 @@ class FS(DeviceFormat): for module in self._modules: try: rc = iutil.execWithRedirect("modprobe", [module], - stdout="/dev/tty5", stderr="/dev/tty5", - searchPath=1) + stdout="/dev/tty5", stderr="/dev/tty5") except Exception as e: log.error("Could not load kernel module %s: %s" % (module, e)) self._supported = False @@ -672,8 +670,7 @@ class FS(DeviceFormat): argv = self._getLabelArgs(label) rc = iutil.execWithRedirect(self.labelfsProg, argv, - stderr="/dev/tty5", - searchPath=1) + stderr="/dev/tty5") if rc: raise FSError("label failed") @@ -920,7 +917,6 @@ class Ext2FS(FS): rc = iutil.execWithRedirect("tune2fs", ["-c0", "-i0", "-ouser_xattr,acl", self.device], - searchPath = True, stdout = "/dev/tty5", stderr = "/dev/tty5") except Exception as e: diff --git a/textw/timezone_text.py b/textw/timezone_text.py index 6245ed5..a69328d 100644 --- a/textw/timezone_text.py +++ b/textw/timezone_text.py @@ -46,7 +46,7 @@ class TimezoneWindow: if self.c.selected(): args.append("--utc") - iutil.execWithRedirect("hwclock", args, searchPath=1) + iutil.execWithRedirect("hwclock", args) self.g.setTimer(500) self.updateClock() diff --git a/yuminstall.py b/yuminstall.py index 70a2d69..2fa3538 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -1728,7 +1728,6 @@ debuglevel=10 try: iutil.execWithRedirect("yum", ["clean", "all"], stdout="/dev/tty5", stderr="/dev/tty5", - searchPath = 1, root = anaconda.rootPath) except: pass -- 1.7.0.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list