1919 If at some point sticky sockets become an option, this function should be
2020 removed. But that is not expected to happen soon, so for now, it's here. */
2121
22- /* Regarding umask use: in Linux, file permissions on local sockets do matter,
23- but handling them is quite difficult, and considering the planned security
24- model for this project, most likely pointless. It is pretty much decided
25- that permissions will be set (statically) on the directory instead. To make
26- that work, we force 0777 on sockets here, otherwise the missing bits would
27- change effective permissions.
22+ /* Regarding socket permissions: by default it's uid/gid/~umask of the
23+ process, just like any other files, but actual usage will likely require
24+ different permissions *and* different gid. It is possible to chmod it here
25+ (for instance by temporarily setting particular umask) but there's no good
26+ way to change gid, so it will likely require external efforts.
2827
29- There are no other ways of passing initial socket permissions in Linux
30- afaik. In pretty much all cases, current umask will NOT be 0000, in fact
31- using 0000 outside of this code is a pretty bad idea for most services.
32-
33- Note in BSD things work exactly like that, without any umask calls, because
34- they just ignore file permissions on sockets. */
28+ If not done here, it's the same problem as with device access, so whatever
29+ will get implemented with devices might also apply to the sockets. */
3530
3631int uc_listen (int fd , const char * path , int backlog )
3732{
38- int ret , mask = 0000 ;
3933 struct sockaddr_un addr ;
40-
41- if ((ret = sys_umask (mask )) < 0 )
42- goto err ;
43-
44- mask = ret ;
34+ int ret ;
4535
4636 if ((ret = uc_address (& addr , path )) < 0 )
4737 goto err ;
@@ -57,9 +47,6 @@ int uc_listen(int fd, const char* path, int backlog)
5747 if ((ret = sys_bind (fd , & addr , sizeof (addr ))) < 0 )
5848 goto err ;
5949got :
60- if ((ret = sys_umask (mask )) < 0 )
61- goto err ;
62-
6350 ret = sys_listen (fd , backlog );
6451err :
6552 return ret ;
0 commit comments