diff --git a/src/addagent/main.c b/src/addagent/main.c index 683bc5f4c9..eaf79ad849 100644 --- a/src/addagent/main.c +++ b/src/addagent/main.c @@ -11,7 +11,7 @@ #include /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); static void print_banner(void); #ifndef WIN32 static void manage_shutdown(int sig) __attribute__((noreturn)); @@ -34,7 +34,7 @@ static int setenv(const char *name, const char *val, __attribute__((unused)) int } #endif -static void helpmsg() +static void helpmsg(int status) { print_header(); print_out(" %s: -[Vhlj] [-a -n ] [-d sec] [-e id] [-r id] [-i id] [-f file]", ARGV0); @@ -52,7 +52,7 @@ static void helpmsg() print_out(" -f Bulk generate client keys from file (Manager only)"); print_out(" contains lines in IP,NAME format"); print_out(" should also exist within /var/ossec due to manage_agents chrooting"); - exit(1); + exit(status); } static void print_banner() @@ -117,7 +117,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - helpmsg(); + helpmsg(0); break; case 'e': #ifdef CLIENT @@ -195,7 +195,7 @@ int main(int argc, char **argv) setenv("OSSEC_REMOVE_DUPLICATED", optarg, 1); break; default: - helpmsg(); + helpmsg(1); break; } } diff --git a/src/agentlessd/main.c b/src/agentlessd/main.c index 0c020e8e50..febeda1f83 100644 --- a/src/agentlessd/main.c +++ b/src/agentlessd/main.c @@ -12,11 +12,11 @@ #include "config/config.h" /* Prototypes */ -static void help_agentlessd(void) __attribute__((noreturn)); +static void help_agentlessd(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_agentlessd() +static void help_agentlessd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -32,7 +32,7 @@ static void help_agentlessd() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -54,7 +54,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_agentlessd(); + help_agentlessd(0); break; case 'd': nowDebug(); @@ -90,7 +90,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_agentlessd(); + help_agentlessd(1); break; } } diff --git a/src/analysisd/analysisd.c b/src/analysisd/analysisd.c index 0a81971de4..c646bf3240 100644 --- a/src/analysisd/analysisd.c +++ b/src/analysisd/analysisd.c @@ -89,7 +89,7 @@ static int hourly_firewall; /* Print help statement */ __attribute__((noreturn)) -static void help_analysisd(void) +static void help_analysisd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -105,7 +105,7 @@ static void help_analysisd(void) print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } #ifndef TESTRULE @@ -148,7 +148,7 @@ int main_analysisd(int argc, char **argv) print_version(); break; case 'h': - help_analysisd(); + help_analysisd(0); break; case 'd': nowDebug(); @@ -185,7 +185,7 @@ int main_analysisd(int argc, char **argv) test_config = 1; break; default: - help_analysisd(); + help_analysisd(1); break; } diff --git a/src/analysisd/makelists.c b/src/analysisd/makelists.c index dfbe6a4a31..d2e7f164cc 100644 --- a/src/analysisd/makelists.c +++ b/src/analysisd/makelists.c @@ -38,7 +38,7 @@ GeoIP *geoipdb; /* print help statement */ __attribute__((noreturn)) -static void help_makelists(void) +static void help_makelists(int status) { print_header(); print_out(" %s: -[VhdtF] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -54,7 +54,7 @@ static void help_makelists(void) print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -84,7 +84,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_makelists(); + help_makelists(0); break; case 'd': nowDebug(); @@ -120,7 +120,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_makelists(); + help_makelists(1); break; } } diff --git a/src/analysisd/testrule.c b/src/analysisd/testrule.c index ce8b101394..fd52d87c8f 100644 --- a/src/analysisd/testrule.c +++ b/src/analysisd/testrule.c @@ -38,7 +38,7 @@ void DecodeEvent(Eventinfo *lf); /* Print help statement */ __attribute__((noreturn)) -static void help_logtest(void) +static void help_logtest(int status) { print_header(); print_out(" %s: -[Vhdtva] [-c config] [-D dir] [-U rule:alert:decoder]", ARGV0); @@ -54,7 +54,7 @@ static void help_logtest(void) print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" -U Unit test. Refer to contrib/ossec-testing/runtests.py"); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -96,7 +96,7 @@ int main(int argc, char **argv) test_config = 1; break; case 'h': - help_logtest(); + help_logtest(0); break; case 'd': nowDebug(); @@ -129,7 +129,7 @@ int main(int argc, char **argv) full_output = 1; break; default: - help_logtest(); + help_logtest(1); break; } } diff --git a/src/client-agent/main.c b/src/client-agent/main.c index b5d9ff1a17..309a5fc0b5 100644 --- a/src/client-agent/main.c +++ b/src/client-agent/main.c @@ -17,11 +17,11 @@ #endif /* Prototypes */ -static void help_agentd(void) __attribute((noreturn)); +static void help_agentd(int status) __attribute((noreturn)); /* Print help statement */ -static void help_agentd() +static void help_agentd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -37,7 +37,7 @@ static void help_agentd() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -65,7 +65,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_agentd(); + help_agentd(0); break; case 'd': nowDebug(); @@ -102,7 +102,7 @@ int main(int argc, char **argv) cfg = optarg; break; default: - help_agentd(); + help_agentd(1); break; } } diff --git a/src/logcollector/main.c b/src/logcollector/main.c index d28a9fef5d..f19a462d02 100644 --- a/src/logcollector/main.c +++ b/src/logcollector/main.c @@ -23,11 +23,11 @@ #include "logcollector.h" /* Prototypes */ -static void help_logcollector(void) __attribute__((noreturn)); +static void help_logcollector(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_logcollector() +static void help_logcollector(int status) { print_header(); print_out(" %s: -[Vhdtf] [-c config]", ARGV0); @@ -40,7 +40,7 @@ static void help_logcollector() print_out(" -f Run in foreground"); print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -63,7 +63,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_logcollector(); + help_logcollector(0); break; case 'd': nowDebug(); @@ -82,7 +82,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_logcollector(); + help_logcollector(1); break; } diff --git a/src/monitord/main.c b/src/monitord/main.c index fdf18e684c..28e9830176 100644 --- a/src/monitord/main.c +++ b/src/monitord/main.c @@ -13,11 +13,11 @@ #include "os_net/os_net.h" /* Prototypes */ -static void help_monitord(void) __attribute__((noreturn)); +static void help_monitord(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_monitord() +static void help_monitord(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -33,7 +33,7 @@ static void help_monitord() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -58,7 +58,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_monitord(); + help_monitord(0); break; case 'd': nowDebug(); @@ -94,7 +94,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_monitord(); + help_monitord(1); break; } diff --git a/src/os_auth/main-client.c b/src/os_auth/main-client.c index 8451daa11d..ee731c3e16 100644 --- a/src/os_auth/main-client.c +++ b/src/os_auth/main-client.c @@ -40,10 +40,10 @@ int main() #include #include "auth.h" -static void help_agent_auth(void) __attribute__((noreturn)); +static void help_agent_auth(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_agent_auth() +static void help_agent_auth(int status) { print_header(); print_out(" %s: -[Vhdt] [-g group] [-D dir] [-m IP address] [-p port] [-A name] [-c ciphers] [-v path] [-x path] [-k path]", ARGV0); @@ -64,7 +64,7 @@ static void help_agent_auth() print_out(" -k Full path to agent key"); print_out(" -P Authorization password file [default: /var/ossec/etc/authd.pass"); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -109,7 +109,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_agent_auth(); + help_agent_auth(0); break; case 'd': nowDebug(); @@ -183,7 +183,7 @@ int main(int argc, char **argv) authenticate++; break; default: - help_agent_auth(); + help_agent_auth(1); break; } } diff --git a/src/os_auth/main-server.c b/src/os_auth/main-server.c index f3837c43b3..49bf27a29d 100644 --- a/src/os_auth/main-server.c +++ b/src/os_auth/main-server.c @@ -30,13 +30,13 @@ #define POOL_SIZE 512 /* Prototypes */ -static void help_authd(void) __attribute((noreturn)); +static void help_authd(int status) __attribute((noreturn)); static int ssl_error(const SSL *ssl, int ret); static void clean_exit(SSL_CTX *ctx, int sock) __attribute__((noreturn)); /* Print help statement */ -static void help_authd() +static void help_authd(int status) { print_header(); print_out(" %s: -[Vhdti] [-g group] [-D dir] [-p port] [-c ciphers] [-v path] [-x path] [-k path]", ARGV0); @@ -57,7 +57,7 @@ static void help_authd() print_out(" -x Full path to server certificate"); print_out(" -k Full path to server key"); print_out(" "); - exit(1); + exit(status); } /* Generates a random and temporary shared pass to be used by the agents. */ @@ -187,7 +187,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_authd(); + help_authd(0); break; case 'd': nowDebug(); @@ -257,7 +257,7 @@ int main(int argc, char **argv) server_key = optarg; break; default: - help_authd(); + help_authd(1); break; } } diff --git a/src/os_csyslogd/main.c b/src/os_csyslogd/main.c index 1aa35dea5d..d9de5d9525 100644 --- a/src/os_csyslogd/main.c +++ b/src/os_csyslogd/main.c @@ -10,11 +10,11 @@ #include "csyslogd.h" /* Prototypes */ -static void help_csyslogd(void) __attribute__((noreturn)); +static void help_csyslogd(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_csyslogd() +static void help_csyslogd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -30,7 +30,7 @@ static void help_csyslogd() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -57,7 +57,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_csyslogd(); + help_csyslogd(0); break; case 'd': nowDebug(); @@ -93,7 +93,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_csyslogd(); + help_csyslogd(1); break; } } diff --git a/src/os_dbd/main.c b/src/os_dbd/main.c index 9da07d954d..2df3ac2df1 100644 --- a/src/os_dbd/main.c +++ b/src/os_dbd/main.c @@ -16,7 +16,7 @@ /* Prototypes */ static void print_db_info(void); -static void help_dbd(void) __attribute__((noreturn)); +static void help_dbd(int status) __attribute__((noreturn)); /* Print information regarding enabled databases */ @@ -36,7 +36,7 @@ static void print_db_info() } /* Print help statement */ -static void help_dbd() +static void help_dbd(int status) { print_header(); print_out(" %s: -[Vhdtfv] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -55,7 +55,7 @@ static void help_dbd() print_out(" Database Support:"); print_db_info(); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -82,9 +82,9 @@ int main(int argc, char **argv) switch (c) { case 'V': dbd_print_version(); - break; + return 0; case 'h': - help_dbd(); + help_dbd(0); break; case 'd': nowDebug(); @@ -120,7 +120,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_dbd(); + help_dbd(1); break; } } diff --git a/src/os_execd/execd.c b/src/os_execd/execd.c index 0aadaeca9a..0eb6ebe36f 100644 --- a/src/os_execd/execd.c +++ b/src/os_execd/execd.c @@ -18,7 +18,7 @@ int repeated_offenders_timeout[] = {0, 0, 0, 0, 0, 0, 0}; #ifndef WIN32 /* Prototypes */ -static void help_execd(void) __attribute__((noreturn)); +static void help_execd(int status) __attribute__((noreturn)); static void execd_shutdown(int sig) __attribute__((noreturn)); static void ExecdStart(int q) __attribute__((noreturn)); @@ -29,7 +29,7 @@ static OSHash *repeated_hash; /* Print help statement */ -static void help_execd() +static void help_execd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-g group] [-c config]", ARGV0); @@ -43,7 +43,7 @@ static void help_execd() print_out(" -g Group to run as (default: %s)", GROUPGLOBAL); print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" "); - exit(1); + exit(status); } /* Shut down execd properly */ @@ -90,7 +90,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_execd(); + help_execd(0); break; case 'd': nowDebug(); @@ -114,7 +114,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_execd(); + help_execd(1); break; } } diff --git a/src/os_maild/maild.c b/src/os_maild/maild.c index 1542956444..305c078c3b 100644 --- a/src/os_maild/maild.c +++ b/src/os_maild/maild.c @@ -22,11 +22,11 @@ char _g_subject[SUBJECT_SIZE + 2]; /* Prototypes */ static void OS_Run(MailConfig *mail) __attribute__((nonnull)) __attribute__((noreturn)); -static void help_maild(void) __attribute__((noreturn)); +static void help_maild(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_maild() +static void help_maild(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -42,7 +42,7 @@ static void help_maild() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -67,7 +67,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_maild(); + help_maild(0); break; case 'd': nowDebug(); @@ -103,7 +103,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_maild(); + help_maild(1); break; } } diff --git a/src/remoted/main.c b/src/remoted/main.c index 65900a7293..954ce3605c 100644 --- a/src/remoted/main.c +++ b/src/remoted/main.c @@ -11,11 +11,11 @@ #include "remoted.h" /* Prototypes */ -static void help_remoted(void) __attribute__((noreturn)); +static void help_remoted(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_remoted() +static void help_remoted(int status) { print_header(); print_out(" %s: -[Vhdtf] [-u user] [-g group] [-c config] [-D dir]", ARGV0); @@ -31,7 +31,7 @@ static void help_remoted() print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -56,7 +56,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_remoted(); + help_remoted(0); break; case 'd': nowDebug(); @@ -93,7 +93,7 @@ int main(int argc, char **argv) dir = optarg; break; default: - help_remoted(); + help_remoted(1); break; } } diff --git a/src/reportd/report.c b/src/reportd/report.c index ac8bb40560..c62f2094aa 100644 --- a/src/reportd/report.c +++ b/src/reportd/report.c @@ -10,11 +10,11 @@ #include "shared.h" /* Prototypes */ -static void help_reportd(void) __attribute__((noreturn)); +static void help_reportd(int status) __attribute__((noreturn)); /* Print help statement */ -static void help_reportd() +static void help_reportd(int status) { print_header(); print_out(" Generate reports (via stdin)"); @@ -39,7 +39,7 @@ static void help_reportd() print_out(" -f level 10 (to filter on level >= 10)"); print_out(" -f group authentication -r user srcip (to show srcip for all users)"); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -86,7 +86,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_reportd(); + help_reportd(0); break; case 'd': nowDebug(); @@ -148,7 +148,7 @@ int main(int argc, char **argv) r_filter.show_alerts = 1; break; default: - help_reportd(); + help_reportd(1); break; } diff --git a/src/rootcheck/rootcheck.c b/src/rootcheck/rootcheck.c index c4a17d8532..6e63dd80bb 100644 --- a/src/rootcheck/rootcheck.c +++ b/src/rootcheck/rootcheck.c @@ -31,7 +31,7 @@ char total_ports_tcp[65535 + 1]; /* Print help statement */ -void help_rootcheck() +void help_rootcheck(int status) { print_header(); print_out(" %s: -[Vhdtsr] [-c config] [-D dir]", ARGV0); @@ -46,7 +46,7 @@ void help_rootcheck() print_out(" -c Configuration file to use"); print_out(" -D Directory to chroot into (default: %s)", DEFAULTDIR); print_out(" "); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -120,7 +120,7 @@ int rootcheck_init(int test_config) print_version(); break; case 'h': - help_rootcheck(); + help_rootcheck(0); break; case 'd': nowDebug(); @@ -147,7 +147,7 @@ int rootcheck_init(int test_config) rootcheck.readall = 1; break; default: - help_rootcheck(); + help_rootcheck(1); break; } } diff --git a/src/shared/help.c b/src/shared/help.c index 19e34bb544..3f3675447a 100644 --- a/src/shared/help.c +++ b/src/shared/help.c @@ -25,5 +25,5 @@ void print_version() print_out("%s %s - %s", __ossec_name, __ossec_version, __author); print_out(" "); print_out("%s", __license); - exit(1); + exit(0); } diff --git a/src/syscheckd/syscheck.c b/src/syscheckd/syscheck.c index 4e3f4b75cb..7e6855c809 100644 --- a/src/syscheckd/syscheck.c +++ b/src/syscheckd/syscheck.c @@ -18,7 +18,7 @@ /* Prototypes */ static void read_internal(int debug_level); #ifndef WIN32 -static void help_syscheckd(void) __attribute__((noreturn)); +static void help_syscheckd(int status) __attribute__((noreturn)); #endif syscheck_config syscheck; @@ -167,7 +167,7 @@ int Start_win32_Syscheck() #ifndef WIN32 /* Print help statement */ -static void help_syscheckd() +static void help_syscheckd(int status) { print_header(); print_out(" %s: -[Vhdtf] [-c config]", ARGV0); @@ -180,7 +180,7 @@ static void help_syscheckd() print_out(" -f Run in foreground"); print_out(" -c Configuration file to use (default: %s)", DEFAULTCPATH); print_out(" "); - exit(1); + exit(status); } /* Syscheck unix main */ @@ -200,7 +200,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - help_syscheckd(); + help_syscheckd(0); break; case 'd': nowDebug(); @@ -219,7 +219,7 @@ int main(int argc, char **argv) test_config = 1; break; default: - help_syscheckd(); + help_syscheckd(1); break; } } diff --git a/src/util/agent_control.c b/src/util/agent_control.c index add94b85e6..c063aaa62c 100644 --- a/src/util/agent_control.c +++ b/src/util/agent_control.c @@ -15,9 +15,9 @@ #define ARGV0 "agent_control" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Control remote agents.\n", ARGV0); printf("Available options:\n"); @@ -35,7 +35,7 @@ static void helpmsg() printf("\t-s Changes the output to CSV (comma delimited).\n"); printf("\t-j Changes the output to JSON .\n"); printf("\t-u Used with -r and -b Specifies the agent to use.\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -75,7 +75,7 @@ int main(int argc, char **argv) /* User arguments */ if (argc < 2) { - helpmsg(); + helpmsg(1); } while ((c = getopt(argc, argv, "VehdlLcsjarmu:i:b:f:R:")) != -1) { @@ -84,7 +84,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - helpmsg(); + helpmsg(0); break; case 'd': nowDebug(); @@ -106,43 +106,43 @@ int main(int argc, char **argv) break; case 's': csv_output = 1; - json_output = 0; + json_output = 0; break; - case 'j': + case 'j': json_output = 1; - csv_output = 0; + csv_output = 0; break; case 'c': active_only++; break; case 'i': info_agent++; - //FALLTHRU + //FALLTHRU case 'u': if (!optarg) { merror("%s: -u needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } agent_id = optarg; break; case 'b': if (!optarg) { merror("%s: -b needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } ip_address = optarg; break; case 'f': if (!optarg) { - merror("%s: -e needs an argument", ARGV0); - helpmsg(); + merror("%s: -f needs an argument", ARGV0); + helpmsg(1); } ar = optarg; break; case 'R': if (!optarg) { merror("%s: -R needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } agent_id = optarg; restart_agent = 1; @@ -151,7 +151,7 @@ int main(int argc, char **argv) restart_all_agents = 1; break; default: - helpmsg(); + helpmsg(1); break; } @@ -327,7 +327,7 @@ int main(int argc, char **argv) exit(0); }else{ printf("\n** Invalid agent id '%s'.\n", agent_id); - helpmsg(); + helpmsg(1); } } } else { @@ -605,7 +605,7 @@ int main(int argc, char **argv) } printf("\n** Invalid argument combination.\n"); - helpmsg(); + helpmsg(1); return (0); } diff --git a/src/util/clear_stats.c b/src/util/clear_stats.c index 02cff9a469..6f6926e9a3 100644 --- a/src/util/clear_stats.c +++ b/src/util/clear_stats.c @@ -15,10 +15,10 @@ #define ARGV0 "clear_stats" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Clear the events stats (averages).\n", ARGV0); printf("Available options:\n"); @@ -26,7 +26,7 @@ static void helpmsg() printf("\t-a Clear all the stats (averages).\n"); printf("\t-d Clear the daily averages.\n"); printf("\t-w Clear the weekly averages.\n\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -45,7 +45,7 @@ int main(int argc, char **argv) /* user arguments */ if (argc != 2) { - helpmsg(); + helpmsg(1); } /* Get the group name */ @@ -75,7 +75,7 @@ int main(int argc, char **argv) /* User options */ if (strcmp(argv[1], "-h") == 0) { - helpmsg(); + helpmsg(0); } else if (strcmp(argv[1], "-a") == 0) { clear_daily = 1; clear_weekly = 1; @@ -85,7 +85,7 @@ int main(int argc, char **argv) clear_weekly = 1; } else { printf("\n** Invalid option '%s'.\n", argv[1]); - helpmsg(); + helpmsg(1); } /* Clear daily files */ diff --git a/src/util/list_agents.c b/src/util/list_agents.c index e6c0dc24d7..c867eb97f8 100644 --- a/src/util/list_agents.c +++ b/src/util/list_agents.c @@ -14,10 +14,10 @@ #define ARGV0 "list_agents" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: List available agents.\n", ARGV0); printf("Available options:\n"); @@ -25,7 +25,7 @@ static void helpmsg() printf("\t-a List all agents.\n"); printf("\t-c List the connected (active) agents.\n"); printf("\t-n List the not connected (active) agents.\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -45,7 +45,7 @@ int main(int argc, char **argv) /* User arguments */ if (argc < 2) { - helpmsg(); + helpmsg(1); } /* Get the group name */ @@ -75,7 +75,7 @@ int main(int argc, char **argv) /* User options */ if (strcmp(argv[1], "-h") == 0) { - helpmsg(); + helpmsg(0); } else if (strcmp(argv[1], "-a") == 0) { flag = GA_ALL; msg = "is available."; @@ -87,7 +87,7 @@ int main(int argc, char **argv) msg = "is not active."; } else { printf("\n** Invalid option '%s'.\n", argv[1]); - helpmsg(); + helpmsg(1); } agent_list = get_agents(flag); diff --git a/src/util/ossec-regex.c b/src/util/ossec-regex.c index 2284fde189..2e7e254fc8 100644 --- a/src/util/ossec-regex.c +++ b/src/util/ossec-regex.c @@ -13,13 +13,13 @@ #define ARGV0 "ossec-regex" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: ossec-regex pattern\n", ARGV0); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -35,13 +35,13 @@ int main(int argc, char **argv) /* User arguments */ if (argc != 2) { - helpmsg(); + helpmsg(1); return (-1); } /* User options */ if (strcmp(argv[1], "-h") == 0) { - helpmsg(); + helpmsg(0); return (-1); } diff --git a/src/util/rootcheck_control.c b/src/util/rootcheck_control.c index ef4f1bef07..52fc901ecb 100644 --- a/src/util/rootcheck_control.c +++ b/src/util/rootcheck_control.c @@ -16,10 +16,10 @@ #define ARGV0 "rootcheck_control" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Manages the policy and auditing database.\n", ARGV0); @@ -35,7 +35,7 @@ static void helpmsg() printf("\t-L Used with -i, prints the last scan.\n"); printf("\t-s Changes the output to CSV (comma delimited).\n"); printf("\t-j Changes the output to JSON.\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -61,7 +61,7 @@ int main(int argc, char **argv) /* User arguments */ if (argc < 2) { - helpmsg(); + helpmsg(1); } while ((c = getopt(argc, argv, "VhqrDdLlcsju:i:")) != -1) { @@ -70,7 +70,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - helpmsg(); + helpmsg(0); break; case 'D': nowDebug(); @@ -99,21 +99,21 @@ int main(int argc, char **argv) case 'i': info_agent++; if (!optarg) { - merror("%s: -u needs an argument", ARGV0); - helpmsg(); + merror("%s: -i needs an argument", ARGV0); + helpmsg(1); } agent_id = optarg; break; case 'u': if (!optarg) { merror("%s: -u needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } agent_id = optarg; update_rootcheck = 1; break; default: - helpmsg(); + helpmsg(1); break; } @@ -267,7 +267,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid agent id '%s'.\n", agent_id); - helpmsg(); + helpmsg(1); } } @@ -327,7 +327,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid agent id '%s'.\n", agent_id); - helpmsg(); + helpmsg(1); } } @@ -367,7 +367,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid argument combination.\n"); - helpmsg(); + helpmsg(1); } diff --git a/src/util/syscheck_control.c b/src/util/syscheck_control.c index 91ebdc4e9b..621f6c431a 100644 --- a/src/util/syscheck_control.c +++ b/src/util/syscheck_control.c @@ -14,10 +14,10 @@ #define ARGV0 "syscheck_control" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Manages the integrity checking database.\n", ARGV0); @@ -41,7 +41,7 @@ static void helpmsg() printf("\n"); printf("\t'Show information about /etc/passwd from agent with ID 019'\n"); printf("\t%s -i 019 -f /etc/passwd\n", ARGV0); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -67,7 +67,7 @@ int main(int argc, char **argv) /* User arguments */ if (argc < 2) { - helpmsg(); + helpmsg(1); } while ((c = getopt(argc, argv, "VhzrDdlcsju:i:f:")) != -1) { @@ -76,7 +76,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - helpmsg(); + helpmsg(0); break; case 'D': nowDebug(); @@ -106,27 +106,27 @@ int main(int argc, char **argv) info_agent++; if (!optarg) { merror("%s: -u needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } agent_id = optarg; break; case 'f': if (!optarg) { merror("%s: -u needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } fname = optarg; break; case 'u': if (!optarg) { merror("%s: -u needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } agent_id = optarg; update_syscheck = 1; break; default: - helpmsg(); + helpmsg(1); break; } } @@ -314,7 +314,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid agent id '%s'.\n", agent_id); - helpmsg(); + helpmsg(1); } } @@ -377,7 +377,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid agent id '%s'.\n", agent_id); - helpmsg(); + helpmsg(1); } } @@ -426,7 +426,7 @@ int main(int argc, char **argv) exit(1); } else { printf("\n** Invalid argument combination.\n"); - helpmsg(); + helpmsg(1); } return (0); diff --git a/src/util/syscheck_update.c b/src/util/syscheck_update.c index 37f01c72f5..5f6aa8eba7 100644 --- a/src/util/syscheck_update.c +++ b/src/util/syscheck_update.c @@ -14,10 +14,10 @@ #define ARGV0 "syscheck_update" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Updates (clears) the integrity check database.\n", ARGV0); printf("Available options:\n"); @@ -26,7 +26,7 @@ static void helpmsg() printf("\t-a Update (clear) syscheck database for all agents.\n"); printf("\t-u Update (clear) syscheck database for a specific agent.\n"); printf("\t-u local Update (clear) syscheck database locally.\n\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -42,7 +42,7 @@ int main(int argc, char **argv) /* User arguments */ if (argc < 2) { - helpmsg(); + helpmsg(1); } /* Get the group name */ @@ -72,7 +72,7 @@ int main(int argc, char **argv) /* User options */ if (strcmp(argv[1], "-h") == 0) { - helpmsg(); + helpmsg(0); } else if (strcmp(argv[1], "-l") == 0) { printf("\nOSSEC HIDS %s: Updates the integrity check database.", ARGV0); @@ -82,7 +82,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "-u") == 0) { if (argc != 3) { printf("\n** Option -u requires an extra argument\n"); - helpmsg(); + helpmsg(1); } } else if (strcmp(argv[1], "-a") == 0) { DIR *sys_dir; @@ -123,7 +123,7 @@ int main(int argc, char **argv) exit(0); } else { printf("\n** Invalid option '%s'.\n", argv[1]); - helpmsg(); + helpmsg(1); } /* Local */ @@ -164,7 +164,7 @@ int main(int argc, char **argv) i = OS_IsAllowedID(&keys, argv[2]); if (i < 0) { printf("\n** Invalid agent id '%s'.\n", argv[2]); - helpmsg(); + helpmsg(1); } /* Delete syscheck */ diff --git a/src/util/verify-agent-conf.c b/src/util/verify-agent-conf.c index 1e9f98fc34..f5031d3bc3 100644 --- a/src/util/verify-agent-conf.c +++ b/src/util/verify-agent-conf.c @@ -16,10 +16,10 @@ #define ARGV0 "verify-agent-conf" /* Prototypes */ -static void helpmsg(void) __attribute__((noreturn)); +static void helpmsg(int status) __attribute__((noreturn)); -static void helpmsg() +static void helpmsg(int status) { printf("\nOSSEC HIDS %s: Verify agent.conf syntax for errors.\n", ARGV0); printf("Usage: %s [-f ]\n\n", ARGV0); @@ -30,7 +30,7 @@ static void helpmsg() printf("\t will be used.\n"); printf(" "); printf("\t Validation is successful, if no errors are shown.\n"); - exit(1); + exit(status); } int main(int argc, char **argv) @@ -51,7 +51,7 @@ int main(int argc, char **argv) print_version(); break; case 'h': - helpmsg(); + helpmsg(0); break; case 'd': nowDebug(); @@ -59,12 +59,12 @@ int main(int argc, char **argv) case 'f': if (!optarg) { merror("%s: -f needs an argument", ARGV0); - helpmsg(); + helpmsg(1); } ar = optarg; break; default: - helpmsg(); + helpmsg(1); break; } }