All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Brasilino <brasilino@prrr.mpf.gov.br>
To: netfilter-devel@lists.netfilter.org
Subject: Is 'iptables-restore' not caching EOF ??
Date: Tue, 25 Jul 2006 09:51:11 -0400	[thread overview]
Message-ID: <44C621CF.6050700@prrr.mpf.gov.br> (raw)

Hi All:

Hope this issue isn't off-topic.
I'm developing a daemon which authenticates a user and creates
netfilter rules based on user profile.
Following Harald's advise, during FISL 7.0 here in Brazil, he said
to open a pipe to 'iptables-restore --noflush' rather than
fork()ing/exec()ing lots of 'iptables' binary. And I'm doing that.
My problem is that I fork(), dup2() and execv()
'iptables-restore' and then I write() from parent end of the pipe
and close() it, the 'iptables-restore' forked child seems not
receiving EOF because it isn't exiting. And I need the
exit status to verify if rules was created.

I've tried two way of writing to the pipe and closing it:

First try:

ret = write(CommIptablesRestore[COMM_WRITE], buffer, strlen (buffer));
close(CommIptablesRestore[COMM_WRITE]);

Second try (as of 'iptables-restore' reading code):

FILE *fp = NULL;
fp = fdopen(CommIptablesRestore[COMM_WRITE], "w");
fputs(buffer, fp);
fflush(fp);
fclose(fp);

Where 'CommIptablesRestore[COMM_WRITE]' is the parent end of pipe
filedescriptor and 'buffer' stores rules until 'COMMIT\n'.

So after closing my daemon exits and 'iptables-restore' does
not exits and stills on sleep status. Using 'strace' I can see
that 'iptables-restore' stills read()ing STDIN. So seems
it is not caching 'EOF' to exit.

Is that a feature, bug or I'm messing something up?

I didn´t post where a full code snippet to avoid mailing list
pollution... but I can send directly.

Thanks a lot in advance.

-- 
[]'s

Lucas Brasilino
brasilino@prrr.mpf.gov.br
Procuradoria da República no Estado de Roraima
+55-95-36239642

                 reply	other threads:[~2006-07-25 13:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=44C621CF.6050700@prrr.mpf.gov.br \
    --to=brasilino@prrr.mpf.gov.br \
    --cc=netfilter-devel@lists.netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.