Re: [PATCH] iptables-save: Exit with error if unable to open proc file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Habets <thomas@xxxxxxxxx> wrote:
> I sent this before without being subscribed, but it doesn't seem to
> have reached the archives so now retrying while subscribed.

Weird, its an open list (no subscribe required).

> If you're not root, then iptables-save silently fails (both to stderr
> and exit code). This patch fixes that.

Thanks, patch looks good but

> --- a/iptables/ip6tables-save.c
> +++ b/iptables/ip6tables-save.c
> @@ -35,10 +35,16 @@ static int for_each_table(int (*func)(const char
> *tablename))
>         int ret = 1;
>         FILE *procfile = NULL;
>         char tablename[XT_TABLE_MAXNAMELEN+1];
> +       const char *filename = "/proc/net/ip6_tables_names";

static const char filename[] = "

> -       procfile = fopen("/proc/net/ip6_tables_names", "re");
> -       if (!procfile)
> -               return ret;
> +       procfile = fopen(filename, "re");
> +       if (!procfile) {
> +               if (errno == ENOENT) {
> +                       return ret;
> +               }

iptables uses kernel coding style, so

	if (errno == ENOENT)
		return ret;

(no { } )

> +               fprintf(stderr, "Failed to list table names in %s:
> %s\n", filename, strerror(errno));
> +               exit(1);

Looks like your mua mangled the patch and broke long lines.
Can you send with git-send-email?

Otherwise see Documentation/email-clients.txt
in the linux kernel sources.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux