Solaris 2.6 and sockets

Wojciech Tryc (wojtek@TRYC.ON.CA)
Fri, 03 Oct 1997 21:55:27 -0400

I have noticed strange things happening under Solaris 2.6 (final release)
Any Unix socket created by ANY application has permissions 4777!!!!
ie: srwxrwxrwx 1 root root 0 Oct 3 21:22 mysql.sock
Check out your /tmp directory :)

Here is a sample code (by Nirva):

#include <stdio.h>
#include <stdlib.h>
#include <sys/un.h>
#include <sys/socket.h>

main(int argc, char *argv[])
{
struct sockaddr_un addr;
int s;

s = socket(AF_UNIX, SOCK_STREAM, 0);

bzero(&addr, sizeof(addr));
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, "/tmp/yoursocket");
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
exit(1);
}
sleep(100);

exit(0);
}

Wojciech Tryc
-----------------------------------------------------
"There is nothing more permanent
than a temporary solution..."
-----------------------------------------------------
wojtek@tryc.on.ca wojtek@trytel.com
virterm@infreno.tusculum.edu virterm@nether.net
wojciech.tryc@kanatek.ca wojtek@fos.net
wojtek@biodome.org http://www.tryc.on.ca
-----------------------------------------------------