Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

if needed creates directory for log_file and pid_file

  • Loading branch information...
commit ef0f7697dc56db2930a2fc5b1ffeda78a796bcbb 1 parent 7a19809
@russoz russoz authored
Showing with 15 additions and 5 deletions.
  1. +1 −0  Build.PL
  2. +14 −5 lib/Net/LDAP/SimpleServer.pm
View
1  Build.PL
@@ -16,6 +16,7 @@ my $builder = Module::Build->new(
'File::Path' => 0,
'File::Spec' => 0,
'File::HomeDir' => 0,
+ 'File::Basename' => 0,
'Test::More' => 0,
'version' => 0,
'Carp' => 0,
View
19 lib/Net/LDAP/SimpleServer.pm
@@ -16,6 +16,7 @@ sub import {
die $@ if $@;
}
+use File::Basename;
use File::HomeDir;
use File::Spec;
use File::Path qw{make_path};
@@ -49,11 +50,6 @@ sub options {
}
sub default_values {
- if ( !-d BASEDIR ) {
- carp q{ Creating Net::LDAP::SimpleServer basedir: } . BASEDIR;
- make_path(BASEDIR);
- make_path(LOGDIR);
- }
return {
host => '*',
port => 389,
@@ -69,12 +65,25 @@ sub default_values {
};
}
+sub _make_dir {
+ my $file = shift;
+ return unless $file;
+
+ my $dir = dirname($file);
+ return unless $dir;
+ return if -d $dir;
+
+ make_path($dir);
+}
+
sub post_configure_hook {
my $self = shift;
my $prop = $self->{'ldap'};
croak q{Cannot find conf file "} . $self->{server}->{conf_file} . q{"}
if $self->{server}->{conf_file} and not -r $self->{server}->{conf_file};
+ _make_dir($self->{server}->{log_file});
+ _make_dir($self->{server}->{pid_file});
croak q{Configuration has no "data" file!}
unless exists $prop->{data};
croak qq{Cannot read data file "} . $prop->{data} . q{"}
Please sign in to comment.
Something went wrong with that request. Please try again.