netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Oliver Ford <ojford@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/1] iptables: Add file output option to iptables-save
Date: Mon, 29 May 2017 14:03:49 +0200	[thread overview]
Message-ID: <20170529120349.GA11209@salvia> (raw)
In-Reply-To: <1495801516-14937-1-git-send-email-ojford@gmail.com>

On Fri, May 26, 2017 at 12:25:16PM +0000, Oliver Ford wrote:
> Adds an option to output the results of iptables-save,
> ip6tables-save, and xtables-save save to a file.
> Updates the man page with this new option.
> 
> Uses the dup2 call to replace stdout with the specified file.
> Error output is unchanged.
> 
> This is a feature requested by a Gentoo developer in
> Bugzilla #905.

Applied, thanks.

One minor glitch here.

> @@ -159,6 +162,21 @@ int ip6tables_save_main(int argc, char *argv[])
>  		case 'M':
>  			xtables_modprobe_program = optarg;
>  			break;
> +		case 'f':
> +			file = fopen(optarg, "w");
> +			if (file == NULL) {
> +				fprintf(stderr, "Failed to open file, error: %s\n",
> +					strerror(errno));
> +				exit(1);
> +			}
> +			int ret = dup2(fileno(file), STDOUT_FILENO);

We prefer not to have variable declarations in the body. So I slightly
mangled your patch. See patch in the git repo for final version.

Thanks.

      parent reply	other threads:[~2017-05-29 12:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 12:25 [PATCH 1/1] iptables: Add file output option to iptables-save Oliver Ford
2017-05-26 12:31 ` Pablo Neira Ayuso
2017-05-26 14:43   ` Oliver Ford
2017-05-26 15:57     ` Pablo Neira Ayuso
2017-05-29 12:03 ` Pablo Neira Ayuso [this message]

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=20170529120349.GA11209@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=ojford@gmail.com \
    /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).