netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Thomas Habets <thomas@habets.se>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH] iptables-save: Exit with error if unable to open proc file
Date: Wed, 18 Jan 2017 14:32:30 +0100	[thread overview]
Message-ID: <20170118133230.GE12001@breakpoint.cc> (raw)
In-Reply-To: <CA+kHd+fMWmomd0ZTWO3nj0iCSOTmXoW-J4S7XNrYq86JznBM0Q@mail.gmail.com>

Thomas Habets <thomas@habets.se> 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.

  reply	other threads:[~2017-01-18 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18 13:23 [PATCH] iptables-save: Exit with error if unable to open proc file Thomas Habets
2017-01-18 13:32 ` Florian Westphal [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-01-18 13:58 thomas
2017-01-18 14:07 ` Florian Westphal
2017-01-18 14:12 thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170118133230.GE12001@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=thomas@habets.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).