summaryrefslogtreecommitdiffstats
path: root/libxtables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-11-26 21:11:25 +0100
committerPhil Sutter <phil@nwl.cc>2021-12-16 14:30:29 +0100
commit316d8efbb7cd2d252c8627df77261a466493d09b (patch)
tree5ecf053e8cd5313517ef900e8d79f5e455e0cac6 /libxtables
parent4bff5aef6e63fb4d403d539f4c9d2d90492120b8 (diff)
libxtables: Extend basic_exit_err()
Basically merge the function with xtables_exit_error, printing a status-specific footer for parameter or version problems. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'libxtables')
-rw-r--r--libxtables/xtables.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index d670175d..50fd6a44 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -90,6 +90,18 @@ void basic_exit_err(enum xtables_exittype status, const char *msg, ...)
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, "\n");
+ if (status == PARAMETER_PROBLEM) {
+ if (line != -1)
+ fprintf(stderr, "Error occurred at line: %d\n", line);
+ fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n",
+ xt_params->program_name, xt_params->program_name);
+ } else if (status == VERSION_PROBLEM) {
+ fprintf(stderr,
+ "Perhaps %s or your kernel needs to be upgraded.\n",
+ xt_params->program_name);
+ }
+ /* On error paths, make sure that we don't leak memory */
+ xtables_free_opts(1);
exit(status);
}