From b3c770898a8613e511dc1e69ddf79c3b806de6f4 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Sat, 13 Apr 2024 12:03:54 +0300 Subject: [PATCH] Ignore opts (#436) * Be less strict about args at startup Ignore unknown options. * Don't fail if pid file is accessible --- common.c | 12 ++++++------ sslh-conf.c | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common.c b/common.c index af3947e..d17c14d 100644 --- a/common.c +++ b/common.c @@ -853,19 +853,19 @@ void write_pid_file(const char* pidfile) f = fopen(pidfile, "w"); if (!f) { - print_message(msg_system_error, "write_pid_file:%s:%s", pidfile, strerror(errno)); - exit(3); + print_message(msg_system_error, "write_pid_file: %s: %s\n", pidfile, strerror(errno)); + return; } res = fprintf(f, "%d\n", getpid()); if (res < 0) { - print_message(msg_system_error, "write_pid_file:fprintf:%s", strerror(errno)); - exit(3); + print_message(msg_system_error, "write_pid_file: fprintf: %s\n", strerror(errno)); + return; } res = fclose(f); if (res == EOF) { - print_message(msg_system_error, "write_pid_file:fclose:%s", strerror(errno)); - exit(3); + print_message(msg_system_error, "write_pid_file: fclose: %s\n", strerror(errno)); + return; } } diff --git a/sslh-conf.c b/sslh-conf.c index 037ef49..dbc29ee 100644 --- a/sslh-conf.c +++ b/sslh-conf.c @@ -2239,10 +2239,13 @@ int sslhcfg_cl_parse(int argc, char* argv[], struct sslhcfg_item* cfg) /* Parse command line */ nerrors = arg_parse(argc, argv, argtable); if (nerrors) { - arg_print_errors(stdout, sslhcfg_end, "sslhcfg"); + // print bad args + arg_print_errors(stdout, sslhcfg_end, "sslhcfg"); + // print usage arg_print_syntax(stdout, argtable, "\n"); + // print options arg_print_glossary(stdout, argtable, " %-25s\t%s\n"); - return -1; + fprintf(stderr, "Invalid args are ignored, please fix them\n"); }