On Sat, Mar 31, 2012 at 10:13 AM, Tim Coote <tim+fedoraproject.org(a)coote.org
wrote:
Hullo
I'm trying to modify an f16 livecd to enable ssh on boot, so that I can
get to it when it's not in front of me.
I'm using a physical laptop with an f16 install from livecd and then yum
update'd
the stock f16 livecd-tools falls over with this error:
File "/usr/lib/python2.7/site-packages/imgcreate/creator.py", line 464,
in __destroy_selinuxfs
arglist = ["/bin/umount", self._instroot + self.__selinux_mountpoint +
"/load"]
AttributeError: 'LiveImageEditor' object has no attribute
'_ImageCreator__selinux_mountpoint'
Which if I look in the source of /usr/bin/edit-livecd seems to be
understandable.
If I update to the updates-testing repo version of livecd-tools:
livecd-tools-16.11-1.fc16.i686
I get this error:
[tim@pluto make]$ sudo edit-livecd -n withssh
Fedora-16-i686-Live-Desktop.iso
Fedora-16-i686-Live-Desktop.iso
umount: /var/tmp/edit-liveos-W2ZKFk/install_root/sys/fs/selinux/load: not
found
Traceback (most recent call last):
File "/usr/bin/edit-livecd", line 723, in <module>
sys.exit(main())
File "/usr/bin/edit-livecd", line 697, in main
editor.mount(LiveOS, cachedir = None)
File "/usr/bin/edit-livecd", line 251, in mount
os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
OSError: [Errno 17] File exists
I *think* that this is because self._instroot is set to None in class
LiveImageEditor(LiveImageCreator):, and does not appear to be reassigned.
Should the f16 livecd-tools version of edit-livecd work and are there any
particular options/configurations that I must set to get it to work? Or
should I just install from somewhere else (I'd much rather not do that as
it will screw up the other dependencies on the box, but if necessary, I
could spin up a VM and do it on that.)
All help gratefully received.
Tim
--
I'm working on new features for edit-livecd and my code has these changes
from the master branch that should address the bugs you've encountered.
--Fred
commit 1f597357a172435554e322658d016ec64c709d25
Author: Frederick Grose <fgrose(a)sugarlabs.org>
Date: Sat Mar 31 19:07:01 2012 -0400
Provide a force-selinux option for edit-livecd.
Only symlink /proc/self/mounts if /etc/mtab does not exist.
Bind mount /etc/resolv.conf to better support networking.
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index e09bdcf..1baf999 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -444,14 +444,14 @@ class ImageCreator(object):
os.symlink(src, self._instroot + dest)
os.umask(origumask)
- def __create_selinuxfs(self):
+ def __create_selinuxfs(self, force=False):
if not os.path.exists(self.__selinux_mountpoint):
return
arglist = ["/bin/mount", "--bind", "/dev/null",
self._instroot +
self.__selinux_mountpoint + "/load"]
subprocess.call(arglist, close_fds = True)
- if kickstart.selinux_enabled(self.ks):
+ if force or kickstart.selinux_enabled(self.ks):
# label the fs like it is a root before the bind mounting
arglist = ["/sbin/setfiles", "-F", "-r",
self._instroot,
selinux.selinux_file_context_path(), self._instroot]
subprocess.call(arglist, close_fds = True)
@@ -463,12 +463,13 @@ class ImageCreator(object):
subprocess.call(arglist, close_fds = True)
def __destroy_selinuxfs(self):
- if not os.path.exists(self.__selinux_mountpoint):
- return
+ """If the system was running SELinux, clean up our
lies."""
+
+ selinux_load = self._instroot + self.__selinux_mountpoint + '/load'
+ if os.path.exists(selinux_load):
+ arglist = ["/bin/umount", selinux_load]
+ subprocess.call(arglist, close_fds=True)
- # 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)
def mount(self, base_on = None, cachedir = None):
"""Setup the target filesystem in preparation for an install.
diff --git a/tools/edit-livecd b/tools/edit-livecd
index 948064b..4232051 100755
--- a/tools/edit-livecd
+++ b/tools/edit-livecd
@@ -241,14 +241,24 @@ class LiveImageEditor(LiveImageCreator):
cachesrc = cachedir or (self._ImageCreator__builddir +
"/yum-cache")
makedirs(cachesrc)
- for (f, dest) in [("/sys", None), ("/proc", None),
- ("/dev/pts", None), ("/dev/shm", None),
- (cachesrc, "/var/cache/yum")]:
- self._ImageCreator__bindmounts.append(BindChrootMount(f,
self._instroot, dest))
-
+ bindmounts = [('/sys', None), ('/proc', None),
('/dev/pts', None),
+ ('/dev/shm', None), (cachesrc, '/var/cache/yum'),
+ ('/etc/resolv.conf', None)]
+ if self.force_selinux:
+ bindmounts += [(self._ImageCreator__selinux_mountpoint, None)]
+ for (f, dest) in bindmounts:
+ if os.path.exists(f):
+ self._ImageCreator__bindmounts.extend([BindChrootMount(f,
+ self._instroot, dest)])
+ else:
+ logging.warn("Skipping (%s, %s) because source doesn't "
+ "exist." % (f, dest))
self._do_bindmounts()
-
- os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
+ if self.force_selinux:
+ self._ImageCreator__create_selinuxfs(force=True)
+ if not os.path.exists('/etc/mtab'):
+ os.symlink('/proc/self/mounts', os.path.join(self._instroot,
+ 'etc', 'mtab'))
self.__copy_img_root(base_on)
self._brand(self._builder)
@@ -545,6 +555,7 @@ def parse_options(args):
%prog [-n=<name>]
[-o <output>]
[-k <kickstart-file>]
+ [-f, --force-selinux]
[-s <script.sh>]
[-t <tmpdir>]
[-e <excludes>]
@@ -568,6 +579,10 @@ def parse_options(args):
parser.add_option("-k", "--kickstart", type="string",
dest="kscfg",
help="Path or url to kickstart config file")
+ parser.add_option("-f", "--force-selinux",
action="store_true",
+ dest="force_selinux", default=False,
+ help='Force setting SELinux attributes on install
root.')
+
parser.add_option("-s", "--script", type="string",
dest="script",
help="specify script to run chrooted in the LiveOS "
"fsimage")
@@ -677,6 +692,7 @@ def main():
editor._exclude = options.exclude
editor._exclude_file = options.exclude_file
editor._include = options.include
+ editor.force_selinux = options.force_selinux
editor.clone = options.clone
editor.tmpdir = options.tmpdir
editor._builder = options.builder