From da4f9e434908fcc5282ba6c697575a3e7abbeed8 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Mon, 28 Oct 2019 14:52:21 +0100 Subject: [PATCH] check whether /sbin/start-stop-daemon.REAL exists before overwriting it --- mmdebstrap | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mmdebstrap b/mmdebstrap index e9b2458..99d517f 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -862,7 +862,11 @@ sub run_chroot(&$) { chmod 0755, "$options->{root}/usr/sbin/policy-rc.d" or error "cannot chmod policy-rc.d: $!"; } + # the file might not exist if it was removed in a hook if (-e "$options->{root}/sbin/start-stop-daemon") { + if (-e "$options->{root}/sbin/start-stop-daemon.REAL") { + error "$options->{root}/sbin/start-stop-daemon.REAL already exists"; + } move("$options->{root}/sbin/start-stop-daemon", "$options->{root}/sbin/start-stop-daemon.REAL") or error "cannot move start-stop-daemon: $!"; open my $fh, '>', "$options->{root}/sbin/start-stop-daemon" or error "cannot open start-stop-daemon: $!"; print $fh "#!/bin/sh\n";