From 748f23269bb5d896feaf22e514929f378b6833af Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 13 Jun 2019 16:23:36 +0000 Subject: [PATCH] Check for the existance of /etc/inittab before attempting to modify it. --- tools/onlrfs.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index a7906398..a9a4cb5d 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -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')