Mail Archives: cygwin/2007/04/27/05:56:29
Greetings,
Has Cygwin 1.5.24-2 and XP.
A program creates local domain socket. If S_IRUSR bit is
removed from the socket file, then this file is converted to a
regular file.
This program shows this problem (check the output of "ls -l sock"):
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <string.h>
#include <unistd.h>
int
main(void)
{
struct sockaddr_un addr;
int sd;
sd = socket(PF_LOCAL, SOCK_DGRAM, 0);
if (sd < 0)
return 1;
memset(&addr, 0, sizeof(addr));
addr.sun_family = PF_LOCAL;
strncpy(addr.sun_path, "./sock", sizeof(addr.sun_path) - 1);
if (bind(sd, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0)
return 1;
if (chmod(addr.sun_path, S_IWUSR) < 0)
return 1;
if (listen(sd, 4) < 0)
return 1;
if (close(sd) < 0)
return 1;
return 0;
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -