check whether /sbin/start-stop-daemon.REAL exists before overwriting it

This commit is contained in:
Johannes 'josch' Schauer 2019-10-28 14:52:21 +01:00
parent daab09bfdd
commit da4f9e4349
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -862,7 +862,11 @@ sub run_chroot(&$) {
chmod 0755, "$options->{root}/usr/sbin/policy-rc.d" or error "cannot chmod policy-rc.d: $!"; 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") {
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: $!"; 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: $!"; open my $fh, '>', "$options->{root}/sbin/start-stop-daemon" or error "cannot open start-stop-daemon: $!";
print $fh "#!/bin/sh\n"; print $fh "#!/bin/sh\n";