Post by Luke Small
I'm trying to do some operations in which I fork and the child closes and
simplifies socketpair listings and sends the simpler list of malloced file
descriptors to a function and sends ioctl data after it opens a socket. The
parent sends a short greeting to the child to show that it is ready. The
child is supposed to receive it and send back an ip4 address to the parent,
but it seems to be hung up and very busy. Any ideas?
I couldn't make out what you meant by reading this a few times, however let
me try. fork() is a common operation to create a new process... you can
for example use it to keep a root owned process around and the child does
privilege seperation however does InterProcess Communication with the root
owned parent. The IPC can be shared memory, a socketpair, a pipe, a named
pipe or socket. I think you mean to set up a socketpair between the parent
and the child. Right here with this kind of model of IPC it is perhaps
wise to use the imsg framework that is in OpenBSD.
This is probably what you want to use. The child sends an IP4 address to
the parent via the socketpair? OK, you don't even need a greeting just
select or poll around the descriptors and test for received data. And then
process it to do your ioctl operations and possibly return data via the
BTW at work I wrote such a program, hence this looks fairly familiar what you
described. It takes an IP address on a listening socket and sends via a
socketpair to a root owned process which then inserts the IP4 into a pf table
via ioctl, and then does another ioctl to flush the states for that IP4.
Unfortunately I can't share the code, it's not licensed for sharing.