MT#64527 ngcp-panel-create-keys: Fix race condition when creating TLS certs

We should not create and populate the TLS keys and certificate files
with the default permissions from open(), to then fix that up in a later
call. Instead use the specified permissions (even if they might get
restricted further by the current umask), and then we will possibly open
them up again when doing the chmod().

Spotted-by: Michael Prokop <mprokop@sipwise.com>
Change-Id: I810e041cc4038bdaed8a3335ca45009129c928de
mr26.0
Guillem Jover 6 months ago
parent 5190438b95
commit fb44ee879a

@ -108,7 +108,9 @@ sub save_pem {
path_mod => $path_mod,
path_owner => $path_owner,
path_group => $path_group);
open(my $fh, '>', $filename) or die "Could not open file '$filename': $!\n";
sysopen my $fh, $filename, O_WRONLY | O_CREAT, $mod
or die "Could not open file '$filename': $!\n";
print $fh $data;
close $fh;
_chownmod($filename,$owner,$group,$mod);

Loading…
Cancel
Save