All of lore.kernel.org
 help / color / mirror / Atom feed
* Is 'iptables-restore' not caching EOF ??
@ 2006-07-25 13:51 Lucas Brasilino
  0 siblings, 0 replies; only message in thread
From: Lucas Brasilino @ 2006-07-25 13:51 UTC (permalink / raw)
  To: netfilter-devel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-07-25 13:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-25 13:51 Is 'iptables-restore' not caching EOF ?? Lucas Brasilino

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.