From 18f31df2f499d67448d6833923f4fc54b0035ead Mon Sep 17 00:00:00 2001 From: Marcin Kulisz Date: Tue, 20 Sep 2016 18:59:54 +0100 Subject: [PATCH] Stretch (9.0) patch #3 - EC2: fixing insserv & + ssh keys removal for releases after Jessie --- bootstrapvz/common/tasks/initd.py | 11 +++++++++-- bootstrapvz/common/tasks/ssh.py | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bootstrapvz/common/tasks/initd.py b/bootstrapvz/common/tasks/initd.py index a7362e1..c7c4304 100644 --- a/bootstrapvz/common/tasks/initd.py +++ b/bootstrapvz/common/tasks/initd.py @@ -12,6 +12,7 @@ class InstallInitScripts(Task): @classmethod def run(cls, info): import stat + from bootstrapvz.common.releases import jessie rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) @@ -20,10 +21,16 @@ class InstallInitScripts(Task): dst = os.path.join(info.root, 'etc/init.d', name) copy(src, dst) os.chmod(dst, rwxr_xr_x) - log_check_call(['chroot', info.root, 'insserv', '--default', name]) + if info.manifest.release > jessie: + log_check_call(['chroot', info.root, 'systemctl', 'enable', name]) + else: + log_check_call(['chroot', info.root, 'insserv', '--default', name]) for name in info.initd['disable']: - log_check_call(['chroot', info.root, 'insserv', '--remove', name]) + if info.manifest.release > jessie: + log_check_call(['chroot', info.root, 'systemctl', 'mask', name]) + else: + log_check_call(['chroot', info.root, 'insserv', '--remove', name]) class AddExpandRoot(Task): diff --git a/bootstrapvz/common/tasks/ssh.py b/bootstrapvz/common/tasks/ssh.py index bfe7707..3e9b32b 100644 --- a/bootstrapvz/common/tasks/ssh.py +++ b/bootstrapvz/common/tasks/ssh.py @@ -101,6 +101,7 @@ class ShredHostkeys(Task): def run(cls, info): ssh_hostkeys = ['ssh_host_dsa_key', 'ssh_host_rsa_key'] + from bootstrapvz.common.releases import wheezy if info.manifest.release >= wheezy: ssh_hostkeys.append('ssh_host_ecdsa_key') @@ -109,4 +110,5 @@ class ShredHostkeys(Task): public = [path + '.pub' for path in private] from ..tools import log_check_call - log_check_call(['shred', '--remove'] + private + public) + log_check_call(['shred', '--remove'] + [key for key in private + public + if os.path.isfile(key)])