Applied help_nonroot.diff: Allow calling the help function as non-root.

(submitted by Torsten)


git-svn-id: svn+ssh://svn.code.sf.net/p/ddclient/code/trunk/svn@34 3873ddee-7413-0410-b6c4-c2c57c1ab35a
This commit is contained in:
wimpunk 2006-12-02 14:40:37 +00:00
parent d61684e22f
commit f1ef8ac065

View file

@ -543,6 +543,12 @@ $result = 'OK';
test_geturl(opt('geturl')) if opt('geturl'); test_geturl(opt('geturl')) if opt('geturl');
## process help option
if (opt('help')) {
*STDERR = *STDOUT;
usage(0);
}
## read config file because 'daemon' mode may be defined there. ## read config file because 'daemon' mode may be defined there.
read_config(define($opt{'file'}, default('file')), \%config, \%globals); read_config(define($opt{'file'}, default('file')), \%config, \%globals);
init_config(); init_config();
@ -1101,16 +1107,14 @@ sub init_config {
$config{$h}{'cacheable'} = [ @{$services{$proto}{'cacheable'}} ]; $config{$h}{'cacheable'} = [ @{$services{$proto}{'cacheable'}} ];
} }
} }
if (opt('help')) {
*STDERR = *STDOUT;
usage();
}
} }
###################################################################### ######################################################################
## usage ## usage
###################################################################### ######################################################################
sub usage { sub usage {
my $exitcode = 1;
$exitcode = shift if @_ != 0; # use first arg if given
my $msg = ''; my $msg = '';
if (@_) { if (@_) {
my $format = shift; my $format = shift;
@ -1120,7 +1124,7 @@ sub usage {
} }
printf STDERR "%s%s\n", $msg, $opt_usage; printf STDERR "%s%s\n", $msg, $opt_usage;
sendmail(); sendmail();
exit 1; exit $exitcode;
} }
###################################################################### ######################################################################