diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-23 01:40:28 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2011-05-23 01:40:28 -0700 |
commit | 1a75c7c53f64d0eec5eb3477900a6cc76aec3281 (patch) | |
tree | 9af3920b44797f0a0602d7a85b7353dbcef81349 /libpiny | |
parent | 1adce71880fffe22d54e06bad8b13aa2e6d6b035 (diff) | |
download | piny-code-1a75c7c53f64d0eec5eb3477900a6cc76aec3281.tar.gz piny-code-1a75c7c53f64d0eec5eb3477900a6cc76aec3281.zip |
Be more paranoid about Config::Simple.
Diffstat (limited to 'libpiny')
-rw-r--r-- | libpiny/lib/Piny/Config.pm | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm index b949198..aaa415a 100644 --- a/libpiny/lib/Piny/Config.pm +++ b/libpiny/lib/Piny/Config.pm @@ -88,7 +88,12 @@ sub _build__conf { my $conf; if ( $s->has_confpath and -e $s->confpath ) { - $conf = Config::Simple->new( $s->confpath )->vars; + $conf = Config::Simple->new( $s->confpath ); + if ( defined $conf ) { + $conf = $conf->vars; + } else { + $conf = { }; + }; } else { $conf = { }; }; @@ -97,11 +102,15 @@ sub _build__conf { if ( -s $home ) { - my $userconf = Config::Simple->new( $home )->vars; + my $userconf = Config::Simple->new( $home ); + + if ( defined $userconf ) { + $userconf = $userconf->vars; - foreach my $key ( keys %$userconf ) { - if ( not exists $conf->{$key} ) { - $conf->{$key} = $userconf->{$key}; + foreach my $key ( keys %$userconf ) { + if ( not exists $conf->{$key} ) { + $conf->{$key} = $userconf->{$key}; + }; }; }; @@ -109,11 +118,15 @@ sub _build__conf { if ( -s "/etc/piny-default.conf" ) { - my $default = Config::Simple->new( "/etc/piny-default.conf" )->vars; + my $default = Config::Simple->new( "/etc/piny-default.conf" ); - foreach my $key ( keys %$default ) { - if ( not exists $conf->{$key} ) { - $conf->{$key} = $default->{$key}; + if ( defined $default ) { + $default = $default->vars; + + foreach my $key ( keys %$default ) { + if ( not exists $conf->{$key} ) { + $conf->{$key} = $default->{$key}; + }; }; }; @@ -121,10 +134,14 @@ sub _build__conf { if ( -s "/etc/piny-override.conf" ) { - my $override = Config::Simple->new( "/etc/piny-override.conf" )->vars; + my $override = Config::Simple->new( "/etc/piny-override.conf" ); + + if ( defined $override ) { + $override = $override->vars; - foreach my $key ( keys %$override ) { - $conf->{$key} = $override->{$key}; + foreach my $key ( keys %$override ) { + $conf->{$key} = $override->{$key}; + }; }; }; |