summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rwxr-xr-xanaconda2
-rw-r--r--exception.py3
-rw-r--r--firewall.py8
-rw-r--r--fsset.py56
-rw-r--r--instdata.py6
-rw-r--r--iscsi.py23
-rw-r--r--iutil.py166
-rw-r--r--kickstart.py3
-rw-r--r--lvm.py82
-rw-r--r--packages.py36
-rw-r--r--partedUtils.py3
-rw-r--r--rescue.py2
-rw-r--r--security.py7
-rw-r--r--text.py2
-rw-r--r--textw/timezone_text.py9
-rw-r--r--vnc.py4
17 files changed, 142 insertions, 283 deletions
diff --git a/ChangeLog b/ChangeLog
index ae6dca560..280f05c5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-07-12 Chris Lumens <clumens@redhat.com>
+
+ * iutil.py (execWithCapture, execWithRedirect): Use subprocess
+ instead of our own code.
+ (memInstalled): Remove /proc/e820info cruft.
+ (rmrf): Removed.
+
+ * anaconda, exception.py, firewall.py, fsset.py, instdata.py,
+ iscsi.py, iutil.py, kickstart.py, lvm.py, packages.py, partedUtils.py,
+ rescue.py, security.py, text.py, vnc.py, textw/timezone_text.py:
+ Don't pass the command we're running as the first element of the
+ argument list, as subprocess doesn't want things that way.
+
2006-07-11 David Cantrell <dcantrell@redhat.com>
* anaconda.spec: Bump version.
diff --git a/anaconda b/anaconda
index b44a3df25..311fec316 100755
--- a/anaconda
+++ b/anaconda
@@ -422,7 +422,7 @@ def runVNC(vncpassword, vncconnecthost, vncconnectport, vncStartedCB=None):
if os.access(p, os.R_OK|os.X_OK):
os.environ['PYTHONSTARTUP'] = p
break
- iutil.execWithRedirect("/bin/sh", ["-/bin/sh"], stdout="/dev/console", stderr="/dev/console")
+ iutil.execWithRedirect("/bin/sh", [], stdout="/dev/console", stderr="/dev/console")
else:
addpid(shpid)
os.waitpid(shpid, 0)
diff --git a/exception.py b/exception.py
index 06f095a46..8823b8f6a 100644
--- a/exception.py
+++ b/exception.py
@@ -286,13 +286,12 @@ def copyExceptionToFloppy (anaconda):
os.close(fd)
if rhpl.getArch() != "ia64":
- args = [ 'mkdosfs', '/tmp/floppy' ]
cmd = "/usr/sbin/mkdosfs"
if os.access("/sbin/mkdosfs", os.X_OK):
cmd = "/sbin/mkdosfs"
- iutil.execWithRedirect (cmd, args, stdout = '/dev/tty5',
+ iutil.execWithRedirect (cmd, ["/tmp/floppy"], stdout = '/dev/tty5',
stderr = '/dev/tty5')
try:
diff --git a/firewall.py b/firewall.py
index 24d0508a6..22eb3fd0b 100644
--- a/firewall.py
+++ b/firewall.py
@@ -59,14 +59,12 @@ class Firewall:
return args
def write (self, instPath):
- args = [ "/usr/sbin/lokkit", "--quiet", "--nostart", "-f" ]
-
- args = args + self.getArgList()
+ args = [ "--quiet", "--nostart", "-f" ] + self.getArgList()
try:
if not flags.test:
- iutil.execWithRedirect(args[0], args, root = instPath,
- stdout = None, stderr = None)
+ iutil.execWithRedirect("/usr/sbin/lokkit", args,
+ root=instPath, stdout=None, stderr=None)
else:
log.error("would have run %s", args)
except RuntimeError, msg:
diff --git a/fsset.py b/fsset.py
index 8b8298eb0..a09d1aa1d 100644
--- a/fsset.py
+++ b/fsset.py
@@ -418,7 +418,7 @@ class reiserfsFileSystem(FileSystemType):
os.close(p[1])
rc = iutil.execWithRedirect("/usr/sbin/mkreiserfs",
- ["mkreiserfs", devicePath ],
+ [devicePath],
stdin = p[0],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -431,8 +431,7 @@ class reiserfsFileSystem(FileSystemType):
label = labelFactory.createLabel(entry.mountpoint, self.maxLabelChars,
kslabel = entry.label)
rc = iutil.execWithRedirect("/usr/sbin/reiserfstune",
- ["reiserfstune", "--label", label,
- devicePath],
+ ["--label", label, devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
if rc:
@@ -470,9 +469,9 @@ class xfsFileSystem(FileSystemType):
xfsBytesPerInode = entry.bytesPerInode
rc = iutil.execWithRedirect("/usr/sbin/mkfs.xfs",
- ["mkfs.xfs", "-f", "-l", "internal",
- "-i", "size=" + str(xfsBytesPerInode),
- devicePath ],
+ ["-f", "-l", "internal", "-i",
+ "size=" + str(xfsBytesPerInode),
+ devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -485,8 +484,7 @@ class xfsFileSystem(FileSystemType):
kslabel = entry.label)
db_cmd = "label " + label
rc = iutil.execWithRedirect("/usr/sbin/xfs_db",
- ["xfs_db", "-x", "-c", db_cmd,
- devicePath],
+ ["-x", "-c", db_cmd, devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
if rc:
@@ -525,7 +523,7 @@ class jfsFileSystem(FileSystemType):
label = labelFactory.createLabel(entry.mountpoint, self.maxLabelChars,
kslabel = entry.label)
rc = iutil.execWithRedirect("/usr/sbin/jfs_tune",
- ["jfs_tune", "-L", label, devicePath],
+ ["-L", label, devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
if rc:
@@ -536,8 +534,7 @@ class jfsFileSystem(FileSystemType):
devicePath = entry.device.setupDevice(chroot)
rc = iutil.execWithRedirect("/usr/sbin/mkfs.jfs",
- ["mkfs.jfs", "-q",
- devicePath ],
+ ["-q", devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -566,8 +563,8 @@ class gfs2FileSystem(FileSystemType):
def formatDevice(self, entry, progress, chroot='/'):
devicePath = entry.device.setupDevice(chroot)
rc = iutil.execWithRedirect("/usr/sbin/mkfs.gfs2",
- ["mkfs.gfs2", "-j", "1", "-p",
- "lock_nolock", "-O", devicePath ],
+ ["-j", "1", "-p", "lock_nolock",
+ "-O", devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -592,7 +589,7 @@ class extFileSystem(FileSystemType):
kslabel = entry.label)
rc = iutil.execWithRedirect("/usr/sbin/e2label",
- ["e2label", devicePath, label],
+ [devicePath, label],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
if rc:
@@ -629,9 +626,8 @@ class extFileSystem(FileSystemType):
return
rc = iutil.execWithRedirect("/usr/sbin/tune2fs",
- ["tunefs", "-c0", "-i0", "-Odir_index",
- "-ouser_xattr,acl",
- devicePath],
+ ["-c0", "-i0", "-Odir_index",
+ "-ouser_xattr,acl", devicePath],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -658,7 +654,7 @@ class ext2FileSystem(extFileSystem):
return
rc = iutil.execWithRedirect("/usr/sbin/tune2fs",
- ["tune2fs", "-j", devicePath ],
+ ["-j", devicePath ],
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -809,7 +805,7 @@ class swapFileSystem(FileSystemType):
def formatDevice(self, entry, progress, chroot='/'):
file = entry.device.setupDevice(chroot)
rc = iutil.execWithRedirect ("/usr/sbin/mkswap",
- [ "mkswap", '-v1', file ],
+ ['-v1', file],
stdout = "/dev/tty5",
stderr = "/dev/tty5",
searchPath = 1)
@@ -829,7 +825,7 @@ class swapFileSystem(FileSystemType):
swapLabel = "SWAP-%s" % (devName)
label = labelFactory.createLabel(swapLabel, self.maxLabelChars)
rc = iutil.execWithRedirect ("/usr/sbin/mkswap",
- [ "mkswap", '-v1', "-L", label, file ],
+ ['-v1', "-L", label, file],
stdout = "/dev/tty5",
stderr = "/dev/tty5",
searchPath = 1)
@@ -863,7 +859,7 @@ class FATFileSystem(FileSystemType):
def formatDevice(self, entry, progress, chroot='/'):
devicePath = entry.device.setupDevice(chroot)
devArgs = self.getDeviceArgs(entry.device)
- args = [ "mkdosfs", devicePath ]
+ args = [ devicePath ]
args.extend(devArgs)
rc = iutil.execWithRedirect("/usr/sbin/mkdosfs", args,
@@ -899,7 +895,7 @@ class hfsFileSystem(FileSystemType):
def formatDevice(self, entry, progress, chroot='/'):
devicePath = entry.device.setupDevice(chroot)
devArgs = self.getDeviceArgs(entry.device)
- args = [ "hformat", devicePath ]
+ args = [ devicePath ]
args.extend(devArgs)
rc = iutil.execWithRedirect("/usr/bin/hformat", args,
@@ -970,7 +966,7 @@ class prepbootFileSystem(FileSystemType):
"(%s)" %(devicePath,))
return
- args = [ "sfdisk", "--change-id", disk, "%d" %(part,), "41" ]
+ args = [ "--change-id", disk, "%d" %(part,), "41" ]
if disk.startswith("/tmp/") and not os.access(disk, os.R_OK):
isys.makeDevInode(disk[5:], disk)
@@ -1795,7 +1791,7 @@ MAILADDR root
if isinstance(root.device, LogicalVolumeDevice) or rootlvm1:
# now make sure all of the device nodes exist. *sigh*
rc = iutil.execWithRedirect("lvm",
- ["lvm", "vgmknodes", "-v"],
+ ["vgmknodes", "-v"],
stdout = "/tmp/lvmout",
stderr = "/tmp/lvmout",
searchPath = 1)
@@ -2184,7 +2180,7 @@ class RAIDDevice(Device):
pd.setupDevice(chroot, devPrefix=devPrefix)
if pd.isNetdev(): self.setAsNetdev()
- args = ["/usr/sbin/mdadm", "--create", "/dev/%s" %(self.device,),
+ args = ["--create", "/dev/%s" %(self.device,),
"--run", "--chunk=%s" %(self.chunksize,),
"--level=%s" %(self.level,),
"--raid-devices=%s" %(self.numDisks,)]
@@ -2194,7 +2190,7 @@ class RAIDDevice(Device):
args.extend(map(devify, self.members))
log.info("going to run: %s" %(args,))
- iutil.execWithRedirect (args[0], args,
+ iutil.execWithRedirect ("/usr/sbin/mdadm", args,
stderr="/dev/tty5", stdout="/dev/tty5")
raid.register_raid_device(self.device, self.members[:],
self.level, self.numDisks)
@@ -2249,7 +2245,7 @@ class VolumeGroupDevice(Device):
# there be a PhysicalVolumeDevice(PartitionDevice) ?
lvm.writeForceConf()
rc = iutil.execWithRedirect("lvm",
- ["lvm", "pvcreate", "-ff", "-y",
+ ["pvcreate", "-ff", "-y",
"-v", node],
stdout = "/tmp/lvmout",
stderr = "/tmp/lvmout",
@@ -2267,11 +2263,11 @@ class VolumeGroupDevice(Device):
lvm.writeForceConf()
lvm.vgscan()
- args = [ "lvm", "vgcreate", "-v", "-An",
+ args = [ "vgcreate", "-v", "-An",
"-s", "%sk" %(self.physicalextentsize,),
self.name ]
args.extend(nodes)
- rc = iutil.execWithRedirect(args[0], args,
+ rc = iutil.execWithRedirect("lvm", args,
stdout = "/tmp/lvmout",
stderr = "/tmp/lvmout",
searchPath = 1)
@@ -2313,7 +2309,7 @@ class LogicalVolumeDevice(Device):
if not self.isSetup:
lvm.writeForceConf()
rc = iutil.execWithRedirect("lvm",
- ["lvm", "lvcreate", "-L",
+ ["lvcreate", "-L",
"%dM" % (self.size,),
"-n", self.name, "-An",
self.vgname],
diff --git a/instdata.py b/instdata.py
index aa9afc6f3..e8c167e36 100644
--- a/instdata.py
+++ b/instdata.py
@@ -138,7 +138,7 @@ class InstallData:
self.timezone.write (anaconda.rootPath)
- args = ["/usr/bin/authconfig", "--update", "--nostart"] + self.auth.split()
+ args = ["--update", "--nostart"] + self.auth.split()
try:
if not flags.test:
@@ -162,13 +162,13 @@ class InstallData:
if anaconda.isKickstart:
for svc in self.ksdata.services["disabled"]:
iutil.execWithRedirect("/sbin/chkconfig",
- ["/sbin/chkconfig", svc, "off"],
+ [svc, "off"],
stdout="/dev/tty5", stderr="/dev/tty5",
root="/mnt/sysimage")
for svc in self.ksdata.services["enabled"]:
iutil.execWithRedirect("/sbin/chkconfig",
- ["/sbin/chkconfig", svc, "on"],
+ [svc, "on"],
stdout="/dev/tty5", stderr="/dev/tty5",
root="/mnt/sysimage")
diff --git a/iscsi.py b/iscsi.py
index 84c15b179..5dd3dca91 100644
--- a/iscsi.py
+++ b/iscsi.py
@@ -49,22 +49,22 @@ class iscsi:
#
# Issue the "action" request to recnum.
#
- argv = [ ISCSIADM, "-m", "node" ]
- records = iutil.execWithCapture(argv[0], argv, searchPath = 1)
+ argv = [ "-m", "node" ]
+ records = iutil.execWithCapture(ISCSIADM, argv)
for line in records.split("\n"):
if line:
recnum = line.split()[0][1:-1]
- argv = [ ISCSIADM, "-m", "node", "-r", "%s" % (recnum,),
+ argv = [ "-m", "node", "-r", "%s" % (recnum,),
"%s" % (action,) ]
- iutil.execWithRedirect(argv[0], argv, searchPath = 1,
+ iutil.execWithRedirect(ISCSIADM, argv, searchPath = 1,
stdout = "/dev/tty5",
stderr = "/dev/tty5")
# ... and now we have to make it start automatically
- argv = [ ISCSIADM, "-m", "node", "-r", "%s" %(recnum,),
+ argv = [ "-m", "node", "-r", "%s" %(recnum,),
"-o", "update", "-n", "node.startup",
"-v", "automatic" ]
- iutil.execWithRedirect(argv[0], argv, searchPath = 1,
+ iutil.execWithRedirect(ISCSIADM, argv, searchPath = 1,
stdout = "/dev/tty5",
stderr = "/dev/tty5")
@@ -76,8 +76,8 @@ class iscsi:
self.action("--logout")
# XXX use iscsiadm shutdown when it's available.
- argv = [ "ps", "--no-headers", "-C", "%s" % (ISCSID,) ]
- psout = iutil.execWithCapture(argv[0], argv, searchPath = 1)
+ argv = [ "--no-headers", "-C", "%s" % (ISCSID,) ]
+ psout = iutil.execWithCapture("ps", argv)
for line in psout.split("\n"):
if line:
pid = string.atoi(string.split(line)[0])
@@ -113,12 +113,11 @@ class iscsi:
if not os.path.exists(ISCSID_DB_DIR):
iutil.mkdirChain(ISCSID_DB_DIR)
- argv = [ ISCSID ]
- iutil.execWithRedirect(argv[0], argv, searchPath = 1)
+ iutil.execWithRedirect(ISCSIID, [], searchPath = 1)
- argv = [ ISCSIADM, "-m", "discovery", "-t", "st", "-p",
+ argv = [ "-m", "discovery", "-t", "st", "-p",
"%s:%s" % (self.ipaddr, self.port) ]
- iutil.execWithRedirect(argv[0], argv, searchPath = 1,
+ iutil.execWithRedirect(ISCSIADM, argv, searchPath = 1,
stdout = "/dev/tty5", stderr="/dev/tty5")
self.action("--login")
diff --git a/iutil.py b/iutil.py
index f276cff0b..d9a8fcd79 100644
--- a/iutil.py
+++ b/iutil.py
@@ -13,11 +13,11 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-import types, os, sys, isys, select, string, stat, signal, shutil
+import os, isys, string, stat, shutil
import os.path
import rhpl, rhpl.executil
import warnings
-from rhpl.executil import getfd
+import subprocess
from flags import flags
import logging
@@ -29,121 +29,47 @@ def getArch ():
return rhpl.getArch()
def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
- searchPath = 0, root = '/', newPgrp = 0,
- ignoreTermSigs = 0):
+ searchPath = 0, root = '/'):
+ def chroot ():
+ os.chroot(root)
+
if not searchPath and not os.access (root + command, os.X_OK):
raise RuntimeError, command + " can not be run"
- childpid = os.fork()
- if childpid == 0:
- if (root and root != '/'):
- os.chroot (root)
- os.chdir("/")
-
- if ignoreTermSigs:
- signal.signal(signal.SIGTSTP, signal.SIG_IGN)
- signal.signal(signal.SIGINT, signal.SIG_IGN)
-
- stdin = getfd(stdin)
- if stdout == stderr:
- stdout = getfd(stdout)
- stderr = stdout
- else:
- stdout = getfd(stdout)
- stderr = getfd(stderr)
-
- if stdin != 0:
- os.dup2(stdin, 0)
- os.close(stdin)
- if stdout != 1:
- os.dup2(stdout, 1)
- if stdout != stderr:
- os.close(stdout)
- if stderr != 2:
- os.dup2(stderr, 2)
- os.close(stderr)
-
- try:
- if (searchPath):
- os.execvp(command, argv)
- else:
- os.execv(command, argv)
- except OSError:
- # let the caller deal with the exit code of 1.
- pass
+ if type(stdin) == type("string"):
+ stdin = open(stdin)
+ if type(stdout) == type("string"):
+ stdout = open(stdout, "w")
+ if type(stderr) == type("string"):
+ stderr = open(stderr, "w")
- os._exit(1)
-
- if newPgrp:
- os.setpgid(childpid, childpid)
- oldPgrp = os.tcgetpgrp(0)
- os.tcsetpgrp(0, childpid)
-
- status = -1
try:
- (pid, status) = os.waitpid(childpid, 0)
+ proc = subprocess.Popen([command] + argv, stdin=stdin, stdout=stdout,
+ stderr=stderr, preexec_fn=chroot)
+ ret = proc.wait()
except OSError, (errno, msg):
- print __name__, "waitpid:", msg
-
- if newPgrp:
- os.tcsetpgrp(0, oldPgrp)
-
- return status
-
-def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0,
- stderr = 2, catchfd = 1, closefd = -1):
-
- if not searchPath and not os.access (root + command, os.X_OK):
- raise RuntimeError, command + " can not be run"
-
- (read, write) = os.pipe()
-
- childpid = os.fork()
- if (not childpid):
- if (root and root != '/'): os.chroot (root)
- os.dup2(write, catchfd)
- os.close(write)
- os.close(read)
-
- if closefd != -1:
- os.close(closefd)
-
- if stdin:
- os.dup2(stdin, 0)
- os.close(stdin)
-
- if stderr == sys.stdout:
- stderr = sys.stdout.fileno()
- else:
- stderr = getfd(stderr)
-
- if stderr != 2:
- os.dup2(stderr, 2)
- os.close(stderr)
-
- if (searchPath):
- os.execvp(command, argv)
- else:
- os.execv(command, argv)
+ raise RuntimeError, "Error running " + command + ": " + msg
- os._exit(1)
+ return ret
- os.close(write)
+def execWithCapture(command, argv, stdin = 0, stderr = 2, root='/'):
+ def chroot():
+ os.chroot(root)
- rc = ""
- s = "1"
- while (s):
- select.select([read], [], [])
- s = os.read(read, 1000)
- rc = rc + s
-
- os.close(read)
+ if type(stdin) == type("string"):
+ stdin = open(stdin)
+ if type(stderr) == type("string"):
+ stderr = open(stderr, "w")
try:
- os.waitpid(childpid, 0)
+ pipe = subprocess.Popen([command] + argv, stdin=stdin,
+ stdout=subprocess.PIPE,
+ stderr=stderr, preexec_fn=chroot)
except OSError, (errno, msg):
- print __name__, "waitpid:", msg
+ raise RuntimeError, "Error running " + command + ": " + msg
+ rc = pipe.stdout.read()
+ pipe.wait()
return rc
def copyFile(source, to):
@@ -184,24 +110,15 @@ def memAvailable():
# this is in kilobytes
def memInstalled():
- if not os.access('/proc/e820info', os.R_OK):
- f = open("/proc/meminfo", "r")
- lines = f.readlines()
- f.close()
+ f = open("/proc/meminfo", "r")
+ lines = f.readlines()
+ f.close()
- for l in lines:
- if l.startswith("MemTotal:"):
- fields = string.split(l)
- mem = fields[1]
- break
- else:
- f = open("/proc/e820info", "r")
- lines = f.readlines()
- mem = 0
- for line in lines:
- fields = string.split(line)
- if fields[3] == "(usable)":
- mem = mem + (string.atol(fields[0], 16) / 1024)
+ for l in lines:
+ if l.startswith("MemTotal:"):
+ fields = string.split(l)
+ mem = fields[1]
+ break
return int(mem)
@@ -238,11 +155,6 @@ def mkdirChain(dir):
log.error("could not create directory %s: %s" % (dir, msg))
pass
-def rmrf (path):
- warnings.warn("iutil.rmrf is deprecated. Use shutil.rmtree instead.",
- DeprecationWarning, stacklevel=2)
- shutil.rmtree(path)
-
def swapAmount():
f = open("/proc/meminfo", "r")
lines = f.readlines()
@@ -306,8 +218,6 @@ def makeCharDeviceNodes():
# make the device nodes for all of the drives on the system
def makeDriveDeviceNodes():
- import raid
-
hardDrives = isys.hardDriveDict()
for drive in hardDrives.keys():
if drive.startswith("mapper"):
diff --git a/kickstart.py b/kickstart.py
index 1e5c913df..ebad8424a 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -59,8 +59,7 @@ class AnacondaKSScript(Script):
else:
messages = "/dev/tty3"
- rc = iutil.execWithRedirect(self.interp, [self.interp,
- "/tmp/%s" % os.path.basename(path)],
+ rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)],
stdin = messages, stdout = messages, stderr = messages,
root = scriptRoot)
diff --git a/lvm.py b/lvm.py
index 165c5c459..db901995b 100644
--- a/lvm.py
+++ b/lvm.py
@@ -61,10 +61,8 @@ def vgscan():
if flags.test or lvmDevicePresent == 0:
return
- rc = iutil.execWithRedirect("lvm",
- ["lvm", "vgscan", "-v"],
- stdout = output,
- stderr = output,
+ rc = iutil.execWithRedirect("lvm", ["vgscan", "-v"],
+ stdout = output, stderr = output,
searchPath = 1)
if rc:
log.error("running vgscan failed: %s" %(rc,))
@@ -79,25 +77,21 @@ def vgactivate(volgroup = None):
if flags.test or lvmDevicePresent == 0:
return
- args = ["lvm", "vgchange", "-ay"]
+ args = ["vgchange", "-ay"]
if volgroup:
args.append(volgroup)
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
log.error("running vgchange failed: %s" %(rc,))
# lvmDevicePresent = 0
# now make the device nodes
- args = ["lvm", "vgmknodes"]
+ args = ["vgmknodes"]
if volgroup:
args.append(volgroup)
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
log.error("running vgmknodes failed: %s" %(rc,))
# lvmDevicePresent = 0
@@ -111,13 +105,11 @@ def vgdeactivate(volgroup = None):
if flags.test or lvmDevicePresent == 0:
return
- args = ["lvm", "vgchange", "-an"]
+ args = ["vgchange", "-an"]
if volgroup:
args.append(volgroup)
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
log.error("running vgchange failed: %s" %(rc,))
# lvmDevicePresent = 0
@@ -133,14 +125,12 @@ def lvremove(lvname, vgname):
if flags.test or lvmDevicePresent == 0:
return
- args = ["lvm", "lvremove", "-f"]
+ args = ["lvremove", "-f"]
dev = "/dev/%s/%s" %(vgname, lvname)
args.append(dev)
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
raise SystemError, "lvremove failed"
@@ -168,37 +158,31 @@ def vgremove(vgname):
except:
pass
- args = ["lvm", "vgremove", vgname]
+ args = ["vgremove", vgname]
log.info(string.join(args, ' '))
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
raise SystemError, "vgremove failed"
# now iterate all the PVs we've just freed up, so we reclaim the metadata
# space. This is an LVM bug, AFAICS.
for pvname in pvs:
- args = ["lvm", "pvremove", "-ff", pvname]
+ args = ["pvremove", "-ff", pvname]
log.info(string.join(args, ' '))
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
raise SystemError, "pvremove failed"
- args = ["lvm", "pvcreate", "-ff", "-y", "-v", pvname]
+ args = ["pvcreate", "-ff", "-y", "-v", pvname]
log.info(string.join(args, ' '))
- rc = iutil.execWithRedirect(args[0], args,
- stdout = output,
- stderr = output,
- searchPath = 1)
+ rc = iutil.execWithRedirect("lvm", args, stdout = output,
+ stderr = output, searchPath = 1)
if rc:
raise SystemError, "pvcreate failed for %s" % (pvname,)
@@ -210,12 +194,11 @@ def lvlist():
lvs = []
# field names for "options" are in LVM2.2.01.01/lib/report/columns.h
- args = ["lvm", "lvdisplay", "-C", "--noheadings", "--units", "b",
+ args = ["lvdisplay", "-C", "--noheadings", "--units", "b",
"--nosuffix", "--separator", ":", "--options",
"vg_name,lv_name,lv_size,origin"
]
- lvscanout = iutil.execWithCapture(args[0], args, searchPath = 1,
- stderr = "/dev/tty6")
+ lvscanout = iutil.execWithCapture("lvm", args, stderr = "/dev/tty6")
for line in lvscanout.split("\n"):
try:
(vg, lv, size, origin) = line.strip().split(':')
@@ -239,12 +222,11 @@ def pvlist():
return []
pvs = []
- args = ["lvm", "pvdisplay", "-C", "--noheadings", "--units", "b",
+ args = ["pvdisplay", "-C", "--noheadings", "--units", "b",
"--nosuffix", "--separator", ":", "--options",
"pv_name,vg_name,dev_size"
]
- scanout = iutil.execWithCapture(args[0], args, searchPath = 1,
- stderr = "/dev/tty6")
+ scanout = iutil.execWithCapture("lvm", args, stderr = "/dev/tty6")
for line in scanout.split("\n"):
try:
(dev, vg, size) = line.strip().split(':')
@@ -262,12 +244,11 @@ def vglist():
return []
vgs = []
- args = ["lvm", "vgdisplay", "-C", "--noheadings", "--units", "b",
+ args = ["vgdisplay", "-C", "--noheadings", "--units", "b",
"--nosuffix", "--separator", ":", "--options",
"vg_name,vg_size,vg_extent_size"
]
- scanout = iutil.execWithCapture(args[0], args, searchPath = 1,
- stderr = "/dev/tty6")
+ scanout = iutil.execWithCapture("lvm", args, stderr = "/dev/tty6")
for line in scanout.split("\n"):
try:
(vg, size, pesize) = line.strip().split(':')
@@ -286,9 +267,8 @@ def partialvgs():
return []
vgs = []
- args = ["lvm", "vgdisplay", "-C", "-P", "--noheadings", "--units", "b"]
- scanout = iutil.execWithCapture(args[0], args, searchPath = 1,
- stderr = "/dev/tty6")
+ args = ["vgdisplay", "-C", "-P", "--noheadings", "--units", "b"]
+ scanout = iutil.execWithCapture("lvm", args, stderr = "/dev/tty6")
for line in scanout.split("\n"):
try:
(vg, numpv, numlv, numsn, attr, size, free) = line.strip()[:-1].split()
diff --git a/packages.py b/packages.py
index d8469c600..c76247c92 100644
--- a/packages.py
+++ b/packages.py
@@ -166,14 +166,14 @@ def setupTimezone(anaconda):
if rhpl.getArch() == "s390":
return
- args = [ "/usr/sbin/hwclock", "--hctosys" ]
+ args = [ "--hctosys" ]
if anaconda.id.timezone.utc:
args.append("-u")
elif anaconda.id.timezone.arc:
args.append("-a")
try:
- iutil.execWithRedirect(args[0], args, stdin = None,
+ iutil.execWithRedirect("/usr/sbin/hwclock", args, stdin = None,
stdout = "/dev/tty5", stderr = "/dev/tty5")
except RuntimeError:
log.error("Failed to set clock")
@@ -232,41 +232,11 @@ def setFileCons(anaconda):
return
-# XXX: large hack lies here
-def migrateMouseConfig(instPath, instLog):
- if not os.access (instPath + "/usr/sbin/fix-mouse-psaux", os.X_OK):
- return
-
- argv = [ "/usr/sbin/fix-mouse-psaux" ]
-
- logfile = os.open (instLog, os.O_APPEND)
- iutil.execWithRedirect(argv[0], argv, root = instPath,
- stdout = logfile, stderr = logfile)
- os.close(logfile)
-
-
-def migrateXinetd(instPath, instLog):
- if not os.access (instPath + "/usr/sbin/inetdconvert", os.X_OK):
- return
-
- if not os.access (instPath + "/etc/inetd.conf.rpmsave", os.R_OK):
- return
-
- argv = [ "/usr/sbin/inetdconvert", "--convertremaining",
- "--inetdfile", "/etc/inetd.conf.rpmsave" ]
-
- logfile = os.open (instLog, os.O_APPEND)
- iutil.execWithRedirect(argv[0], argv, root = instPath,
- stdout = logfile, stderr = logfile)
- os.close(logfile)
-
-
#Recreate initrd for use when driver disks add modules
def recreateInitrd (kernelTag, instRoot):
log.info("recreating initrd for %s" % (kernelTag,))
iutil.execWithRedirect("/sbin/new-kernel-pkg",
- [ "/sbin/new-kernel-pkg", "--mkinitrd",
- "--depmod", "--install", kernelTag ],
+ [ "--mkinitrd", "--depmod", "--install", kernelTag ],
stdout = None, stderr = None,
searchPath = 1, root = instRoot)
diff --git a/partedUtils.py b/partedUtils.py
index b7b40d875..764c901a4 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -812,8 +812,7 @@ class DiskSet:
# FIXME: this belongs in parted itself, but let's do a hack...
if iutil.isMactel() and disk.type.name == "gpt" and \
os.path.exists("/usr/sbin/gptsync"):
- iutil.execWithRedirect("/usr/sbin/gptsync",
- ["gptsync", disk.dev.path],
+ iutil.execWithRedirect("/usr/sbin/gptsync", [disk.dev.path],
stdout="/dev/tty5", stderr="/dev/tty5")
del disk
self.refreshDevices()
diff --git a/rescue.py b/rescue.py
index a0c5cccfe..841d2056b 100644
--- a/rescue.py
+++ b/rescue.py
@@ -176,7 +176,7 @@ def runShell(screen, msg=""):
print
if os.path.exists("/bin/sh"):
- iutil.execWithRedirect("/bin/sh", ["-/bin/sh"], stdout="/dev/console", stderr="/dev/console")
+ iutil.execWithRedirect("/bin/sh", [], stdout="/dev/console", stderr="/dev/console")
else:
print "Unable to find /bin/sh to execute! Not starting shell"
time.sleep(5)
diff --git a/security.py b/security.py
index fce2b06ed..f11798d77 100644
--- a/security.py
+++ b/security.py
@@ -50,7 +50,7 @@ class Security:
f.write("selinux --%s\n" %(selinux_states[self.selinux],))
def write(self, instPath):
- args = [ "/usr/sbin/lokkit", "--quiet", "--nostart" ]
+ args = [ "--quiet", "--nostart" ]
if not selinux_states.has_key(self.selinux):
log.error("unknown selinux state: %s" %(self.selinux,))
@@ -60,8 +60,9 @@ class Security:
try:
if not flags.test:
- iutil.execWithRedirect(args[0], args, root = instPath,
- stdout = None, stderr = None)
+ iutil.execWithRedirect("/usr/sbin/lokkit", args,
+ root = instPath, stdout = None,
+ stderr = None)
else:
log.info("would have run %s" %(args,))
except RuntimeError, msg:
diff --git a/text.py b/text.py
index b302a800f..f16618f2e 100644
--- a/text.py
+++ b/text.py
@@ -552,7 +552,7 @@ def spawnShell(screen):
screen.suspend()
print "\n\nType <exit> to return to the install program.\n"
if os.path.exists("/bin/sh"):
- iutil.execWithRedirect("/bin/sh", ["-/bin/sh"])
+ iutil.execWithRedirect("/bin/sh", [])
else:
print "Unable to find /bin/sh to execute! Not starting shell"
time.sleep(5)
diff --git a/textw/timezone_text.py b/textw/timezone_text.py
index 37a368d0a..e9aa9f7d2 100644
--- a/textw/timezone_text.py
+++ b/textw/timezone_text.py
@@ -36,16 +36,11 @@ class TimezoneWindow:
return zoneList
def updateSysClock(self):
- if os.access("/sbin/hwclock", os.X_OK):
- args = [ "/sbin/hwclock" ]
- else:
- args = [ "/usr/sbin/hwclock" ]
-
- args.append("--hctosys")
+ args = ["--hctosys"]
if self.c.selected():
args.append("--utc")
- iutil.execWithRedirect(args[0], args)
+ iutil.execWithRedirect("hwclock", args, searchPath=1)
self.g.setTimer(500)
self.updateClock()
diff --git a/vnc.py b/vnc.py
index b099bceb7..d4d55146a 100644
--- a/vnc.py
+++ b/vnc.py
@@ -282,10 +282,10 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
if vncconnectport != "":
hostarg = hostarg + ":" + vncconnectport
- argv = ["/usr/bin/vncconfig", "-display", ":1", "-connect", hostarg]
+ argv = ["-display", ":1", "-connect", hostarg]
ntries = 0
while 1:
- output = iutil.execWithCapture(argv[0], argv, catchfd=2)
+ output = iutil.execWithCapture("/usr/bin/vncconfig", argv)
if output == "":
stdoutLog.info(_("Connected!"))