Search for iscsid in the $PATH, not in a hardcoded list of places (#645523).
While I'm at it, add a method that searches the $PATH and get rid of the
various other places we were doing this.
---
pyanaconda/iutil.py | 8 ++++++++
pyanaconda/storage/devicelibs/lvm.py | 14 +++-----------
pyanaconda/storage/formats/fs.py | 8 ++------
pyanaconda/storage/iscsi.py | 13 ++++---------
4 files changed, 17 insertions(+), 26 deletions(-)
return open(attribute, "r").read().strip()
+
+def find_program_in_path(prog):
+ for d in os.environ["PATH"].split(":"):
+ full = "%s/%s" % (d, prog)
+ if os.access(full, os.X_OK):
+ return full
+
+ return None
diff --git a/pyanaconda/storage/devicelibs/lvm.py b/pyanaconda/storage/devicelibs/lvm.py
index d0ff1bf..79615e8 100644
--- a/pyanaconda/storage/devicelibs/lvm.py
+++ b/pyanaconda/storage/devicelibs/lvm.py
@@ -37,20 +37,12 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
MAX_LV_SLOTS = 256
def has_lvm():
- has_lvm = False
- for path in os.environ["PATH"].split(":"):
- if os.access("%s/lvm" % path, os.X_OK):
- has_lvm = True
- break
-
- if has_lvm:
- has_lvm = False
+ if iutil.find_program_in_path("lvm"):
for line in open("/proc/devices").readlines():
if "device-mapper" in line.split():
- has_lvm = True
- break
+ return True
- return has_lvm
+ return False
# Start config_args handling code
#
diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index d9e3ee4..dca7f1a 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -734,8 +734,7 @@ class FS(DeviceFormat):
if not prog:
continue
- if not filter(lambda d: os.access("%s/%s" % (d, prog), os.X_OK),
- os.environ["PATH"].split(":")):
+ if not iutil.find_program_in_path(prog):
return False
return True
@@ -804,10 +803,7 @@ class FS(DeviceFormat):
def _isMigratable(self):
""" Can filesystems of this type be migrated? """
return bool(self._migratable and self.migratefsProg and
- filter(lambda d: os.access("%s/%s"
- % (d, self.migratefsProg,),
- os.X_OK),
- os.environ["PATH"].split(":")) and
+ iutil.find_program_in_path(self.migratefsProg) is not None and
self.migrationTarget)