]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables-restore: Use xt_params->program_name
authorPhil Sutter <phil@nwl.cc>
Tue, 17 Sep 2019 14:45:20 +0000 (16:45 +0200)
committerPhil Sutter <phil@nwl.cc>
Fri, 18 Oct 2019 09:57:21 +0000 (11:57 +0200)
Instead of setting newargv[0] to argv[0]'s value, just use whatever
xt_params->program_name contains. The latter is arbitrarily defined, but
may still be more correct than real argv[0] which may simply be for
instance xtables-nft-multi. Either way, there is no practical
significance since newargv[0] is used exclusively in debug output.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft-shared.h
iptables/xtables-restore.c
iptables/xtables-translate.c

index a330aceb9785c03930e25aab0ab7fcd08c1faf4d..5c6641505f3db83b4cb9c9b9cc344ce93d71171c 100644 (file)
@@ -262,8 +262,7 @@ struct nft_xt_restore_cb {
 
 void xtables_restore_parse(struct nft_handle *h,
                           const struct nft_xt_restore_parse *p,
-                          struct nft_xt_restore_cb *cb,
-                          int argc, char *argv[]);
+                          struct nft_xt_restore_cb *cb);
 
 void nft_check_xt_legacy(int family, bool is_ipt_save);
 #endif
index cb03104e91a7b59ac037cd111a3d57a7b36018bc..24bfce516d34c264f1ab38c10e66794d9c1fb39c 100644 (file)
@@ -87,8 +87,7 @@ static const struct xtc_ops xtc_ops = {
 
 void xtables_restore_parse(struct nft_handle *h,
                           const struct nft_xt_restore_parse *p,
-                          struct nft_xt_restore_cb *cb,
-                          int argc, char *argv[])
+                          struct nft_xt_restore_cb *cb)
 {
        const struct builtin_table *curtable = NULL;
        char buffer[10240];
@@ -264,7 +263,7 @@ void xtables_restore_parse(struct nft_handle *h,
                                parsestart = buffer;
                        }
 
-                       add_argv(argv[0], 0);
+                       add_argv(xt_params->program_name, 0);
                        add_argv("-t", 0);
                        add_argv(curtable->name, 0);
 
@@ -434,7 +433,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       xtables_restore_parse(&h, &p, &restore_cb, argc, argv);
+       xtables_restore_parse(&h, &p, &restore_cb);
 
        nft_fini(&h);
        fclose(p.in);
@@ -500,7 +499,7 @@ int xtables_eb_restore_main(int argc, char *argv[])
 
        nft_init_eb(&h, "ebtables-restore");
        h.noflush = noflush;
-       xtables_restore_parse(&h, &p, &ebt_restore_cb, argc, argv);
+       xtables_restore_parse(&h, &p, &ebt_restore_cb);
        nft_fini(&h);
 
        return 0;
@@ -524,7 +523,7 @@ int xtables_arp_restore_main(int argc, char *argv[])
        struct nft_handle h;
 
        nft_init_arp(&h, "arptables-restore");
-       xtables_restore_parse(&h, &p, &arp_restore_cb, argc, argv);
+       xtables_restore_parse(&h, &p, &arp_restore_cb);
        nft_fini(&h);
 
        return 0;
index 4ae9ff57c0eb3cf3c5e22079743a5b62fcb2eba8..64e7667a253e7696e445a9a8c976674c4d449403 100644 (file)
@@ -535,7 +535,7 @@ static int xtables_restore_xlate_main(int family, const char *progname,
 
        printf("# Translated by %s v%s on %s",
               argv[0], PACKAGE_VERSION, ctime(&now));
-       xtables_restore_parse(&h, &p, &cb_xlate, argc, argv);
+       xtables_restore_parse(&h, &p, &cb_xlate);
        printf("# Completed on %s", ctime(&now));
 
        nft_fini(&h);