]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
ipset-translate: allow invoking with a path name
authorQuentin Armitage <quentin@armitage.org.uk>
Thu, 11 Aug 2022 16:52:18 +0000 (17:52 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 16 Aug 2022 21:38:37 +0000 (23:38 +0200)
Executing /usr/sbin/ipset-translate results in the ipset functionality being run, rather than the ipset-translate functionality.

 # ipset-translate destroy fred
 This command is not supported, use `ipset-translate restore < file'

 # /usr/sbin/ipset-translate destroy fred
 ipset v7.15: The set with the given name does not exist

use basename() to resolve the issue.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1626
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/ipset.c

index 6d42b60d2fe9d33d249f823b17322dd499773637..162f477d49cd0accaf01e6335b4548592cb2edca 100644 (file)
@@ -6,6 +6,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#define _GNU_SOURCE
 #include <assert.h>                    /* assert */
 #include <stdio.h>                     /* fprintf */
 #include <stdlib.h>                    /* exit */
@@ -31,7 +32,7 @@ main(int argc, char *argv[])
                exit(1);
        }
 
-       if (!strcmp(argv[0], "ipset-translate")) {
+       if (!strcmp(basename(argv[0]), "ipset-translate")) {
                ret = ipset_xlate_argv(ipset, argc, argv);
        } else {
                ret = ipset_parse_argv(ipset, argc, argv);