imgcreate/creator.py | 6 ++++--
imgcreate/kickstart.py | 36 +++++++++++++++++++++++-------------
tools/livecd-creator | 11 +++++++++++
3 files changed, 38 insertions(+), 15 deletions(-)
New commits:
commit 93cfdfd84be5170532ca2cc103b1ea76c86aba62
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Dec 4 15:03:08 2012 -0800
silence the selinux umount error
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 0e5ed6b..64cd188 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -474,8 +474,10 @@ class ImageCreator(object):
return
# if the system was running selinux clean up our lies
- arglist = ["/bin/umount", self._instroot + self.__selinux_mountpoint + "/load"]
- subprocess.call(arglist, close_fds = True)
+ path = self._instroot + self.__selinux_mountpoint + "/load"
+ if os.path.exists(path):
+ arglist = ["/bin/umount", path]
+ subprocess.call(arglist, close_fds = True)
def mount(self, base_on = None, cachedir = None):
"""Setup the target filesystem in preparation for an install.
commit 6c8585f724ee1fa624ff3fd1e51791303a400934
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Dec 4 13:33:50 2012 -0800
use systemd instead of inittab for startx
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py
index e3d4697..809b694 100644
--- a/imgcreate/kickstart.py
+++ b/imgcreate/kickstart.py
@@ -236,19 +236,23 @@ class ServicesConfig(KickstartConfig):
class XConfig(KickstartConfig):
"""A class to apply a kickstart X configuration to a system."""
+ RUNLEVELS = {3: 'multi-user.target', 5: 'graphical.target'}
+
def apply(self, ksxconfig):
- if ksxconfig.startX:
- f = open(self.path("/etc/inittab"), "rw+")
- buf = f.read()
- buf = buf.replace("id:3:initdefault", "id:5:initdefault")
- f.seek(0)
- f.write(buf)
- f.close()
if ksxconfig.defaultdesktop:
f = open(self.path("/etc/sysconfig/desktop"), "w")
f.write("DESKTOP="+ksxconfig.defaultdesktop+"\n")
f.close()
+ if ksxconfig.startX:
+ if not os.path.isdir(self.path('/etc/systemd/system')):
+ logging.warning("there is no /etc/systemd/system directory, cannot update default.target!")
+ return
+ default_target = self.path('/etc/systemd/system/default.target')
+ if os.path.islink(default_target):
+ os.unlink(default_target)
+ os.symlink(self.path('/lib/systemd/system/graphical.target'), default_target)
+
class RPMMacroConfig(KickstartConfig):
"""A class to apply the specified rpm macros to the filesystem"""
def apply(self, ks):
commit efc4fa2e962ac20c0a19ae5aa09e8e8c4ef1f791
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Dec 4 12:34:58 2012 -0800
set selinux permissive mode when building
diff --git a/tools/livecd-creator b/tools/livecd-creator
index 44d07a1..a39e43f 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -23,6 +23,7 @@ import sys
import time
import optparse
import logging
+import selinux
import imgcreate
from imgcreate.fs import makedirs
@@ -143,6 +144,12 @@ def main():
print >> sys.stderr, "You must run %s as root" % sys.argv[0]
return 1
+ # Set selinux to Permissive if it is enforcing
+ selinux_enforcing = False
+ if selinux.is_selinux_enabled() and selinux.security_getenforce():
+ selinux_enforcing = True
+ selinux.security_setenforce(0)
+
if options.fslabel:
fslabel = options.fslabel
name = fslabel
@@ -196,6 +203,8 @@ def main():
else:
# Cannot happen, we validate this when parsing options.
logging.error(u"'%s' is not a valid image type" % options.image_type)
+ if selinux_enforcing:
+ selinux.security_setenforce(1)
return 1
creator.compress_type = options.compress_type
@@ -219,6 +228,8 @@ def main():
return 1
finally:
creator.cleanup()
+ if selinux_enforcing:
+ selinux.security_setenforce(1)
return 0
commit 925d47614b1b49360dfc1be0af0c7ed5330d9d12
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Dec 4 10:53:28 2012 -0800
fix kickstart logging entry
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py
index 7ee4102..e3d4697 100644
--- a/imgcreate/kickstart.py
+++ b/imgcreate/kickstart.py
@@ -159,7 +159,7 @@ class TimezoneConfig(KickstartConfig):
shutil.copy2(self.path("/usr/share/zoneinfo/%s" %(tz,)),
self.path("/etc/localtime"))
except (OSError, shutil.Error) as e:
- log.error("Error copying timezone: %s" %(e.strerror,))
+ logging.error("Error copying timezone: %s" %(e.strerror,))
class AuthConfig(KickstartConfig):
commit 2f58f519a2693d4eecac9adb968061c503c18ab1
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Dec 4 10:52:19 2012 -0800
write hostname to /etc/hostname (#870805)
diff --git a/imgcreate/kickstart.py b/imgcreate/kickstart.py
index 7adb37a..7ee4102 100644
--- a/imgcreate/kickstart.py
+++ b/imgcreate/kickstart.py
@@ -328,11 +328,6 @@ class NetworkConfig(KickstartConfig):
else:
f.write("NETWORKING_IPV6=no\n")
- if hostname:
- f.write("HOSTNAME=%s\n" % hostname)
- else:
- f.write("HOSTNAME=localhost.localdomain\n")
-
if gateway:
f.write("GATEWAY=%s\n" % gateway)
@@ -354,6 +349,16 @@ class NetworkConfig(KickstartConfig):
f.write("::1\t\tlocalhost6.localdomain6 localhost6\n")
f.close()
+ def write_hostname(self, hostname):
+ if not hostname:
+ return
+
+ path = self.path("/etc/hostname")
+ f = file(path, "w+")
+ os.chmod(path, 0644)
+ f.write("%s\n" % (hostname,))
+ f.close()
+
def write_resolv(self, nodns, nameservers):
if nodns or not nameservers:
return
@@ -407,6 +412,7 @@ class NetworkConfig(KickstartConfig):
self.write_sysconfig(useipv6, hostname, gateway)
self.write_hosts(hostname)
+ self.write_hostname(hostname)
self.write_resolv(nodns, nameservers)
class SelinuxConfig(KickstartConfig):