boards > tech > Net::Server socket ownership

ownericonuserlame
Joined: 2004-03-17
Posts: 662
2008.11.16 - 05:06:02 PDT
I had a bit of a hitch working on my ulppd [sourceforge.net] project. Using Net::Server, it's not possible to chown the UNIX sockets it creates. You can put a chown into the post_bind_hook and it will be executed, but it's soon undone in post_bind (the next stage). This stage takes care of dropping permissions and chowning files to the user/group it's dropping permissions to.

With this patch, you can simply pass sock_owner and sock_group to the Net::Server, and the sockets will be chowned to that user/group respectively. If one or both options are omitted, the previous behavior is maintained.

Patch is available here [ulppd.svn.sourceforge.net]
ownericonuserlame
Joined: 2004-03-17
Posts: 662
2008.11.18 - 15:23:30 PDT
Patch has been updated to include support for socket modes (chmod). Configuration option is sock_mode, and should be given a string representing octal form. Actually, you could give it in hex if you like, or even binary. Any of the following strings would work the same (owner read/write, group read, other none):

"640"
"0640"
"0x1a0"
"0b110100000"
ownericonuserlame
Joined: 2004-03-17
Posts: 662
2008.11.19 - 16:01:56 PDT
Added a patch for the Net::Server documentation available here [ulppd.svn.sourceforge.net].
ownericonuserlame
Joined: 2004-03-17
Posts: 662
2008.12.03 - 18:30:10 PDT
This introduced a new problem (technically it already existed in Net::Server) when using a sock_owner or sock_group other than the Net::Server user (or user's groups, respectively).

The patch has been updated. For more info, see Bug #3 [bugs.mifflinet.org].
hit counter