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@34 3873ddee-7413-0410-b6c4-c2c57c1ab35a
This commit is contained in:
parent
9383adf9d9
commit
33b438c5f9
1 changed files with 9 additions and 5 deletions
14
svn/ddclient
14
svn/ddclient
|
@ -543,6 +543,12 @@ $result = 'OK';
|
|||
|
||||
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(define($opt{'file'}, default('file')), \%config, \%globals);
|
||||
init_config();
|
||||
|
@ -1101,16 +1107,14 @@ sub init_config {
|
|||
$config{$h}{'cacheable'} = [ @{$services{$proto}{'cacheable'}} ];
|
||||
}
|
||||
}
|
||||
if (opt('help')) {
|
||||
*STDERR = *STDOUT;
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## usage
|
||||
######################################################################
|
||||
sub usage {
|
||||
my $exitcode = 1;
|
||||
$exitcode = shift if @_ != 0; # use first arg if given
|
||||
my $msg = '';
|
||||
if (@_) {
|
||||
my $format = shift;
|
||||
|
@ -1120,7 +1124,7 @@ sub usage {
|
|||
}
|
||||
printf STDERR "%s%s\n", $msg, $opt_usage;
|
||||
sendmail();
|
||||
exit 1;
|
||||
exit $exitcode;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in a new issue