diff options
-rwxr-xr-x | lacme-accountd | 23 | ||||
-rw-r--r-- | lacme-accountd.1.md | 9 |
2 files changed, 19 insertions, 13 deletions
diff --git a/lacme-accountd b/lacme-accountd index 1dc5f03..b9a6e33 100755 --- a/lacme-accountd +++ b/lacme-accountd @@ -69,16 +69,19 @@ do { ( ($ENV{XDG_CONFIG_HOME} // "$ENV{HOME}/.config") . "/lacme/$NAME.conf" , "@@sysconfdir@@/lacme/$NAME.conf" ); - die "Error: Can't find configuration file\n" unless defined $conffile; - print STDERR "Using configuration file: $conffile\n" if $OPTS{debug}; - - my $h = Config::Tiny::->read($conffile) or die Config::Tiny::->errstr()."\n"; - my $h2 = delete $h->{_} // {}; - die "Invalid section(s): ".join(', ', keys %$h)."\n" if %$h; - my %h = map { $_ => delete $h2->{$_} } qw/privkey gpg socket quiet/; - die "Unknown option(s): ".join(', ', keys %$h2)."\n" if %$h2; - $h{quiet} = lc $h{quiet} eq 'yes' ? 1 : 0 if defined $h{quiet}; - $OPTS{$_} //= $h{$_} foreach grep {defined $h{$_}} keys %h; + + if (defined $OPTS{config} or -e $conffile) { + print STDERR "Using configuration file: $conffile\n" if $OPTS{debug}; + my $h = Config::Tiny::->read($conffile) or die Config::Tiny::->errstr()."\n"; + my $h2 = delete $h->{_} // {}; + die "Invalid section(s): ".join(', ', keys %$h)."\n" if %$h; + my %h = map { $_ => delete $h2->{$_} } qw/privkey gpg socket quiet/; + die "Unknown option(s): ".join(', ', keys %$h2)."\n" if %$h2; + $h{quiet} = lc $h{quiet} eq 'yes' ? 1 : 0 if defined $h{quiet}; + $OPTS{$_} //= $h{$_} foreach grep {defined $h{$_}} keys %h; + } else { + print STDERR "Ignoring missing configuration file at default location $conffile\n" if $OPTS{debug}; + } $OPTS{quiet} = 0 if $OPTS{debug}; die "Error: 'privkey' is not specified\n" unless defined $OPTS{privkey}; diff --git a/lacme-accountd.1.md b/lacme-accountd.1.md index e628476..5303418 100644 --- a/lacme-accountd.1.md +++ b/lacme-accountd.1.md @@ -41,9 +41,12 @@ Options `--config=`*filename* -: Use *filename* as configuration file. See the **[configuration - file](#configuration-file)** section below for the configuration - options. +: Use *filename* as configuration file. `lacme-accountd` fails when + `--config=` is used with a non-existent file, but a non-existent + default location is treated as if it were an empty file. + + See the **[configuration file](#configuration-file)** section below + for the configuration options. `--privkey=`*value* |