From 953e324ca3b8d9616ed7569eed60ada4c7e57f71 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Mon, 1 Jul 2013 23:33:59 +0200 Subject: [PATCH] Implemented DisableGetTTYs --- providers/ec2/__init__.py | 3 ++- providers/ec2/tasks/boot.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index f43eb51..dc14f2c 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -42,7 +42,8 @@ def tasks(tasklist, manifest): apt.AptUpgrade(), boot.ConfigureGrub(), boot.ModifyFstab(), - boot.BlackListModules()) + boot.BlackListModules(), + boot.DisableGetTTYs()) from common.tasks import TriggerRollback tasklist.add(TriggerRollback()) diff --git a/providers/ec2/tasks/boot.py b/providers/ec2/tasks/boot.py index 63a514d..ff67fc7 100644 --- a/providers/ec2/tasks/boot.py +++ b/providers/ec2/tasks/boot.py @@ -60,3 +60,18 @@ class BlackListModules(Task): blacklist_path = os.path.join(info.root, 'etc/modprobe.d/blacklist.conf') with open(blacklist_path, 'a') as blacklist: blacklist.write(('# disable pc speaker\nblacklist pcspkr')) + + +class DisableGetTTYs(Task): + description = 'Disabling getty processes' + phase = phases.system_modification + + def run(self, info): + from common.tools import sed_i + inittab_path = os.path.join(info.root, 'etc/inittab') + tty1 = '1:2345:respawn:/sbin/getty 38400 tty1' + sed_i(inittab_path, '^'+tty1, '#'+tty1) + ttyx = ':23:respawn:/sbin/getty 38400 tty' + for i in range(2, 6): + i = str(i) + sed_i(inittab_path, '^'+i+ttyx+i, '#'+i+ttyx+i)