Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dist/cpanfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated by Dist::Zilla::Plugin::CPANFile v6.032
# This file is generated by Dist::Zilla::Plugin::CPANFile v6.033
# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.

requires "Algorithm::Backoff::Exponential" => "0.006";
Expand All @@ -15,6 +15,7 @@ requires "File::Basename" => "0";
requires "File::Copy" => "0";
requires "File::Path" => "0";
requires "File::Temp" => "0";
requires "File::stat" => "0";
requires "Getopt::Long" => "0";
requires "Hash::Merge" => "0";
requires "IO::Handle" => "0";
Expand Down
27 changes: 27 additions & 0 deletions lib/App/Sqitch/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Locale::TextDomain qw(App-Sqitch);
use App::Sqitch::X qw(hurl);
use Config::GitLike 1.15;
use utf8;
use File::stat;

extends 'Config::GitLike';

Expand Down Expand Up @@ -97,9 +98,35 @@ sub load_dirs {
sub load_file {
my $self = shift;
$self->{_initialized} ||= $self->{__loading_dirs};
$self->chmod_files_if_needed(@_);
$self->SUPER::load_file(@_);
}

# chmod_files_if_needed
#
# Utility method that changes the permissions of a configuration
# file into mode 0600 if they are different.
#
# Returns the number of chmod-ed files.
#
sub chmod_files_if_needed {
my $self = shift;
my $changed = 0;


for (@_) {
next unless ( -f "$_" );
my $stat = stat("$_");
next unless ( $stat );
if ( $stat->mode & 07777 != 0600 ) {
chmod 0600, $_;
$changed++;
}
}

return $changed;
}

1;

=head1 Name
Expand Down
Loading