Skip to content

Commit

Permalink
do not fail if File::lchown module is not available, Closes: #925590
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrfai committed Sep 13, 2019
1 parent b4a38f5 commit 1bd6ec6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/fcopy
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ use File::Path;
use File::Basename;
use File::Spec;
use File::Temp qw/tempfile/;
use File::lchown qw/lchown lutimes/;
use Getopt::Std;

# load module only if available
our $haslchown = eval {
require File::lchown;
File::lchown->import (qw/lchown lutimes/);
1;
};

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Global variables
my $debug;
Expand Down Expand Up @@ -373,7 +379,7 @@ sub set_mode {
($uid,$gid) = name2num($owner,$group);
warn "chown/chmod u:$uid g:$gid m:$mode $destfile\n" if $debug;
return if $dryrun; # do not execute if -n or FCOPY_DRYRUN was given
if ($issymlink) {
if ($issymlink && $haslchown) {
lchown ($uid,$gid, $destfile) || ewarn("lchown $owner $group $destfile failed. $!");
unless ($preinst) {
lutimes ($stime,$stime, $destfile) || ewarn("lutimes for $destfile failed. $!");
Expand Down

0 comments on commit 1bd6ec6

Please sign in to comment.