Check for the existance of /etc/inittab before attempting to modify it.

This commit is contained in:
Jeffrey Townsend
2019-06-13 16:23:36 +00:00
parent 3f4bb55187
commit 748f23269b

View File

@@ -517,29 +517,30 @@ rm -f /usr/sbin/policy-rc.d
onlu.execute('sudo rm %s' % f,
ex=OnlRfsError('Could not remove file %s' % f))
if not options.get('ttys', False):
f = os.path.join(dir_, 'etc/inittab')
ua.chmod('a+w', f)
ua.chmod('a+w', os.path.dirname(f))
if os.path.exists(os.path.join(dir_, 'etc/inittab')):
if not options.get('ttys', False):
f = os.path.join(dir_, 'etc/inittab')
ua.chmod('a+w', f)
ua.chmod('a+w', os.path.dirname(f))
logger.info("Clearing %s ttys..." % f)
for line in fileinput.input(f, inplace=True):
if re.match("^[123456]:.*", line):
line = "#" + line
print line,
logger.info("Clearing %s ttys..." % f)
for line in fileinput.input(f, inplace=True):
if re.match("^[123456]:.*", line):
line = "#" + line
print line,
ua.chmod('go-w', f)
ua.chmod('go-w', os.path.dirname(f))
ua.chmod('go-w', f)
ua.chmod('go-w', os.path.dirname(f))
if options.get('console', True):
logger.info('Configuring Console Access in %s' % f)
f = os.path.join(dir_, 'etc/inittab')
ua.chmod('a+w', f)
ua.chmod('a+w', os.path.dirname(f))
with open(f, 'a') as h:
h.write("T0:23:respawn:/sbin/pgetty\n")
ua.chmod('go-w', f)
ua.chmod('go-w', os.path.dirname(f))
if options.get('console', True):
logger.info('Configuring Console Access in %s' % f)
f = os.path.join(dir_, 'etc/inittab')
ua.chmod('a+w', f)
ua.chmod('a+w', os.path.dirname(f))
with open(f, 'a') as h:
h.write("T0:23:respawn:/sbin/pgetty\n")
ua.chmod('go-w', f)
ua.chmod('go-w', os.path.dirname(f))
if options.get('asr', None):
asropts = options.get('asr')