Merge pull request #2189 from yarikoptic/bf-initd-exit

debian-initd: exit with non-0 if fail, account that 255 is "Ok" exit code, use 255 explicitly instead of -1
pull/2215/head
Sergey G. Brester 2018-09-06 13:54:16 +02:00 committed by GitHub
commit 5b0c3e75d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 12 deletions

View File

@ -69,7 +69,7 @@ class Fail2banClient(Fail2banCmdLine, Thread):
# Print a new line because we probably come from wait
output("")
logSys.warning("Caught signal %d. Exiting" % signum)
exit(-1)
exit(255)
def __ping(self, timeout=0.1):
return self.__processCmd([["ping"] + ([timeout] if timeout != -1 else [])],
@ -500,5 +500,5 @@ def exec_command_line(argv):
if client.start(argv):
exit(0)
else:
exit(-1)
exit(255)

View File

@ -668,7 +668,7 @@ def exec_command_line(*args):
if errors:
sys.stderr.write("\n".join(errors) + "\n\n")
parser.print_help()
sys.exit(-1)
sys.exit(255)
output( "" )
output( "Running tests" )
@ -696,4 +696,4 @@ def exec_command_line(*args):
fail2banRegex = Fail2banRegex(opts)
if not fail2banRegex.start(args):
sys.exit(-1)
sys.exit(255)

View File

@ -212,7 +212,7 @@ class Fail2banServer(Fail2banCmdLine):
if not phase.get('done', False):
if server: # pragma: no cover
server.quit()
exit(-1)
exit(255)
if background:
logSys.debug('Starting server done')
@ -223,7 +223,7 @@ class Fail2banServer(Fail2banCmdLine):
logSys.error(e)
if server: # pragma: no cover
server.quit()
exit(-1)
exit(255)
return True
@ -238,4 +238,4 @@ def exec_command_line(argv):
if server.start(argv):
exit(0)
else:
exit(-1)
exit(255)

View File

@ -581,7 +581,7 @@ class Fail2banClientTest(Fail2banClientServerBase):
# test reload missing jail (direct):
self.execCmd(FAILED, startparams, "reload", "~~unknown~jail~fail~~")
self.assertLogged("Failed during configuration: No section: '~~unknown~jail~fail~~'")
self.assertLogged("Exit with code -1")
self.assertLogged("Exit with code 255")
self.pruneLog()
finally:
self.pruneLog()

View File

@ -180,10 +180,17 @@ do_reload() {
#
log_end_msg_wrapper()
{
if [ $1 != 0 ] && [ $1 != $2 ]; then
value=1
else
value=0
fi
if [ "$3" != "no" ]; then
[ $1 -lt $2 ] && value=0 || value=1
log_end_msg $value
fi
if [ $value != "0" ]; then
exit $1
fi
}
command="$1"
@ -191,13 +198,13 @@ case "$command" in
start|force-start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start "$command"
log_end_msg_wrapper $? 2 "$VERBOSE"
log_end_msg_wrapper $? 255 "$VERBOSE"
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
log_end_msg_wrapper $? 2 "$VERBOSE"
log_end_msg_wrapper $? 255 "$VERBOSE"
;;
restart|force-reload)
@ -206,7 +213,7 @@ case "$command" in
case "$?" in
0|1)
do_start
log_end_msg_wrapper $? 1 "always"
log_end_msg_wrapper $? 0 "always"
;;
*)
# Failed to stop