Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

man 7 unix on Linux states:

In the Linux implementation, sockets which are visible in the file system honor the permissions of the directory they are in. Their owner, group and their permissions can be changed. Creation of a new socket will fail if the process does not have write and search (execute) permission on the directory the socket is created in. Connecting to the socket object requires read/write permission. This behavior differs from many BSD-derived systems which ignore permissions for UNIX domain sockets. Portable programs should not rely on this feature for security.

Which systems ignore permissions for UNIX domain sockets?

share|improve this question

2 Answers 2

HP-UX for example ignores permissions on the socket file.

Note that the docs are talking about permissions on the socket file. All implementations respect permissions on the parent directories - a portable program must make sockets in a private directory, rather than rely on making sockets with restrictive permissions (via umask) in a public directory.

share|improve this answer

Not sure what they mean given that

  • sockets originated in BSDs and in 4.3BSD, the documentation clearly specifies that write permission is required for a connect().
  • On Linux as well, read permission is not required, only write.

POSIX doesn't seem to require the connect() to fail if the socket file is not writeable, but explicitly allows it (connect may fail [...] if the named socket is not writeable). That "may" suggests there may be indeed systems that don't honour the permissions, but I doubt they would be BSD derived.

share|improve this answer
1  
I notice that the POSIX specification has it under "may fail", not "shall fail", which suggests that the intent was to allow the implementation to go either way. Weirdly, the "search permission on directory" part is there too, and I can't imagine those permissions not being checked, ever. –  Wumpus Q. Wumbley Jul 15 '13 at 10:49
    
@WumpusQ.Wumbley, you're right, answer edited accordingly. –  Stéphane Chazelas Jul 15 '13 at 11:15
3  
Also, after looking through some old code at minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/… it looks like 4.2BSD had a connect without permission check. Compare to the 4.3BSD code which does an access(ip, IWRITE) in unp_connect. So maybe "many BSD-derived systems" actually means "the few unlucky 4.2BSD survivors". Even in 4.2BSD, the directory permissions would of course be checked by the namei. –  Wumpus Q. Wumbley Jul 15 '13 at 11:16
    
@WumpusQ.Wumbley, good finding which makes my answer probably irrelevant/incorrect since a few systems branched off BSD before 4.3 –  Stéphane Chazelas Jul 15 '13 at 11:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.