Re: Fchown on unix domain sockets?

David Wagner
2004-11-02T05:27:48Z

Jan Engelhardt wrote:
>How about setting the permissions beforehand?

This makes you susceptible to TOCTTOU (race condition) attacks in some
cases. Often, the only way to change ownership or permissions of a file
you want to operate on securely is to use fchown()/fchmod() etc.

It came as a surprise to me that open() + fchown()/fchmod() does not
work in some cases that chown()/chmod() do. I wonder whether this has
any effect on applications. Could this result in security holes in
applications that are unaware of this property?