fixed setting unix socket permissions
first call fchmod() to prevent TOCTTOU, then apply permissions using chmod()
This commit is contained in:
@@ -34,11 +34,10 @@ socket_bind_listen(int domain, int type, int protocol,
|
||||
if (!fd.CreateNonBlock(domain, type, protocol))
|
||||
throw MakeSocketError("Failed to create socket");
|
||||
|
||||
|
||||
#ifdef HAVE_UN
|
||||
if (domain == AF_UNIX) {
|
||||
/* allow everybody to connect */
|
||||
fchmod(fd.Get(), 0666);
|
||||
/* Prevent access until right permissions are set */
|
||||
fchmod(fd.Get(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user