summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2022-10-01 00:10:34 +0200
committerPhil Sutter <phil@nwl.cc>2022-10-05 18:19:38 +0200
commit9cdb52d655608e92f101cb56562e4756a47abd81 (patch)
tree2424b1b545b4b9ee0496c1b042d109871293e23a
parentdba32a76aacf84181a9bd3ba1e301e59ab49d370 (diff)
extensions: libebt_log: Avoid empty log-prefix in output
Just like iptables LOG target, omit --log-prefix from output if the string is empty.
-rw-r--r--extensions/libebt_log.c7
-rw-r--r--extensions/libebt_log.t4
2 files changed, 6 insertions, 5 deletions
diff --git a/extensions/libebt_log.c b/extensions/libebt_log.c
index 8858cf0e..47708d79 100644
--- a/extensions/libebt_log.c
+++ b/extensions/libebt_log.c
@@ -161,9 +161,10 @@ static void brlog_print(const void *ip, const struct xt_entry_target *target,
{
struct ebt_log_info *loginfo = (struct ebt_log_info *)target->data;
- printf("--log-level %s --log-prefix \"%s\"",
- eight_priority[loginfo->loglevel].c_name,
- loginfo->prefix);
+ printf("--log-level %s", eight_priority[loginfo->loglevel].c_name);
+
+ if (loginfo->prefix[0])
+ printf(" --log-prefix \"%s\"", loginfo->prefix);
if (loginfo->bitmask & EBT_LOG_IP)
printf(" --log-ip");
diff --git a/extensions/libebt_log.t b/extensions/libebt_log.t
index a0df6169..f7116c41 100644
--- a/extensions/libebt_log.t
+++ b/extensions/libebt_log.t
@@ -1,6 +1,6 @@
:INPUT,FORWARD,OUTPUT
--log;=;OK
--log-level crit;=;OK
---log-level 1;--log-level alert --log-prefix "";OK
---log-level emerg --log-ip --log-arp --log-ip6;--log-level emerg --log-prefix "" --log-ip --log-arp --log-ip6 -j CONTINUE;OK
+--log-level 1;--log-level alert;OK
+--log-level emerg --log-ip --log-arp --log-ip6;=;OK
--log-level crit --log-ip --log-arp --log-ip6 --log-prefix foo;--log-level crit --log-prefix "foo" --log-ip --log-arp --log-ip6 -j CONTINUE;OK