let's encrypt output can be a symlink, so always de-reference it https://www.virtualmin.com/node/42419

This commit is contained in:
Jamie Cameron 2016-09-29 16:28:54 -07:00
parent ceae4b5228
commit 7208412de2
2 changed files with 7 additions and 7 deletions

View File

@ -6382,7 +6382,7 @@ foreach my $f (@_) {
return wantarray ? ($rv, $err) : $rv; return wantarray ? ($rv, $err) : $rv;
} }
=head2 copy_source_dest(source, dest) =head2 copy_source_dest(source, dest, [copy-link-target])
Copy some file or directory to a new location. Returns 1 on success, or 0 Copy some file or directory to a new location. Returns 1 on success, or 0
on failure - also sets $! on failure. If the source is a directory, uses on failure - also sets $! on failure. If the source is a directory, uses
@ -6393,7 +6393,7 @@ and special files.
sub copy_source_dest sub copy_source_dest
{ {
return (1, undef) if (&is_readonly_mode()); return (1, undef) if (&is_readonly_mode());
my ($src, $dst) = @_; my ($src, $dst, $copylink) = @_;
my $ok = 1; my $ok = 1;
my ($err, $out); my ($err, $out);
&webmin_debug_log('COPY', "src=$src dst=$dst") &webmin_debug_log('COPY', "src=$src dst=$dst")
@ -6425,7 +6425,7 @@ elsif (-d $src) {
$err = $out; $err = $out;
} }
} }
elsif (-l $src) { elsif (-l $src && !$copylink) {
# A link .. re-create # A link .. re-create
my $linkdst = readlink($src); my $linkdst = readlink($src);
$ok = &symlink_logged($linkdst, $dst); $ok = &symlink_logged($linkdst, $dst);

View File

@ -136,7 +136,7 @@ else {
if (!$ok) { if (!$ok) {
return &text('letsencrypt_ecsr', $csr); return &text('letsencrypt_ecsr', $csr);
} }
&copy_source_dest($csr, "/tmp/lets.csr"); &copy_source_dest($csr, "/tmp/lets.csr", 1);
# Find a reasonable python version # Find a reasonable python version
my $python = &get_letsencrypt_python_cmd(); my $python = &get_letsencrypt_python_cmd();
@ -174,9 +174,9 @@ else {
my $certfinal = "$module_config_directory/$doms[0].cert"; my $certfinal = "$module_config_directory/$doms[0].cert";
my $keyfinal = "$module_config_directory/$doms[0].key"; my $keyfinal = "$module_config_directory/$doms[0].key";
my $chainfinal = "$module_config_directory/$doms[0].chain"; my $chainfinal = "$module_config_directory/$doms[0].chain";
&copy_source_dest($cert, $certfinal); &copy_source_dest($cert, $certfinal, 1);
&copy_source_dest($key, $keyfinal); &copy_source_dest($key, $keyfinal, 1);
&copy_source_dest($chain, $chainfinal); &copy_source_dest($chain, $chainfinal, 1);
&set_ownership_permissions(undef, undef, 0600, $certfinal); &set_ownership_permissions(undef, undef, 0600, $certfinal);
&set_ownership_permissions(undef, undef, 0600, $keyfinal); &set_ownership_permissions(undef, undef, 0600, $keyfinal);
&set_ownership_permissions(undef, undef, 0600, $chainfinal); &set_ownership_permissions(undef, undef, 0600, $chainfinal);