Re: Fchown on unix domain sockets?

Jan Engelhardt
2004-11-01T14:22:06Z

>Please CC any reply to jmc AT xisl.com as I'm not subscribed.
>
>I wanted to change the ownership on a unix domain socket in a program (running
>as root) I was writing and I was wondering if "fchown" worked on the socket
>descriptor (after I'd run "bind" of course).
>
>It doesn't, you have to use "chown" on the path name - however "fchown"
>silently does nothing, it doesn't report an error.

I think that's normal, because chown() applies to an object in the filesystem,
while fchown() applies to the FD. (In fact, it applies to an inode.)
However, socket fd of any kind don't have an associated inode, because, well
sockets are not stored on the filesystem.

As some manpage might say, the socket thing you see in "ls -l" is just a
reference thing. When you connect to it, ls -l /proc/pidofprogram/fd/ does not
show the path, but [socket:xxxx] which shows that the filesystem object is not
used anymore.

>I don't mind it not working but I think it should report an error. This is on
>2.6.3 kernel.

What would you like it to do? EINVAL like the others or change the actual
inode's permission?

Jan Engelhardt
--
Gesellschaft für Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 Göttingen, www.gwdg.de