equal
deleted
inserted
replaced
665 # |
665 # |
666 if ( $conf->{'binddn'} && ! -e $conf->{'configfile'} ) { |
666 if ( $conf->{'binddn'} && ! -e $conf->{'configfile'} ) { |
667 print "Would you like to cache your connection information? [Yn]: "; |
667 print "Would you like to cache your connection information? [Yn]: "; |
668 chomp( my $response = <STDIN> ); |
668 chomp( my $response = <STDIN> ); |
669 unless ( $response =~ /^n/i ) { |
669 unless ( $response =~ /^n/i ) { |
670 YAML::Syck::DumpFile( $conf->{'configfile'}, $conf ); |
670 main::save_config($conf->{configfile}); |
671 chmod 0600, $conf->{'configfile'}; |
|
672 print "Connection info cached to $conf->{'configfile'}.\n"; |
671 print "Connection info cached to $conf->{'configfile'}.\n"; |
673 } |
672 } |
674 } |
673 } |
675 |
674 |
676 $self->{'ldap'} = $ldap; |
675 $self->{'ldap'} = $ldap; |
2452 close YAML; |
2451 close YAML; |
2453 |
2452 |
2454 eval { $conf = YAML::Syck::Load( $data ) }; |
2453 eval { $conf = YAML::Syck::Load( $data ) }; |
2455 die "Invalid YAML in $confpath\n" if $@; |
2454 die "Invalid YAML in $confpath\n" if $@; |
2456 |
2455 |
|
2456 # remove reference to itself, if somehow it got dumped |
|
2457 # into YAML. |
|
2458 if( $conf->{configfile} and ($confpath eq $conf->{configfile})) { |
|
2459 delete $conf->{'configfile'} |
|
2460 } |
|
2461 |
2457 return $conf; |
2462 return $conf; |
2458 } |
2463 } |
2459 |
2464 |
|
2465 ### dump YAML config into conf file while making sure that |
|
2466 ### name of configfile itself is not dumped if it is equal |
|
2467 ### to the file being written. |
|
2468 ### |
|
2469 sub save_config |
|
2470 { |
|
2471 my $confpath = shift; |
|
2472 |
|
2473 my %conf2 = %$conf; |
|
2474 if( $confpath eq $conf->{configfile}) { |
|
2475 delete $conf2{'configfile'} |
|
2476 } |
|
2477 |
|
2478 YAML::Syck::DumpFile( $conf->{'configfile'}, \%conf2 ); |
|
2479 chmod 0600, $conf->{'configfile'}; |
|
2480 |
|
2481 return 1; |
|
2482 } |
|
2483 |
2460 ### EOF |
2484 ### EOF |
2461 |
2485 |