delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/03/19/16:05:08

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 19 Mar 2003 16:10:09 -0500
From: Jason Tishler <jason AT tishler DOT net>
Subject: chmod() on AF_UNIX sockets broken
To: Cygwin <cygwin AT cygwin DOT com>
Mail-followup-to: Cygwin <cygwin AT cygwin DOT com>
Message-id: <20030319211009.GA1116@tishler.net>
MIME-version: 1.0
User-Agent: Mutt/1.4i

--Boundary_(ID_DcAPNjcZ/GC9naH3EkNfFA)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

While tracking down a PostgreSQL problem, I uncovered that chmod()
appears to have no affect on AF_UNIX sockets on recent Cygwin versions.

The attached test case, afunix.cc, demonstrates the problem:

    $ # Cygwin 1.3.22-1
    $ afunix
    $ ls -l /tmp/.afunix 
    srwx------    1 jt       Domain U        0 Mar 19 15:57 /tmp/.afunix

    $ # Red Hat Linux 8.0
    $ afunix
    $ ls -l /tmp/.afunix 
    srwxrwxrwx    1 jt       dev             0 Mar 19 17:13 /tmp/.afunix

    $ # Cygwin 1.3.18-1
    $ afunix
    $ ls -l /tmp/.afunix 
    srwxrwxrwx    1 jt       Domain U        0 Mar 19 17:13 /tmp/.afunix

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

--Boundary_(ID_DcAPNjcZ/GC9naH3EkNfFA)
Content-type: text/plain; charset=us-ascii; NAME=afunix.cc
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=afunix.cc

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/errno.h>
#include <sys/stat.h>

int
main()
{
	
	const char file[] = "/tmp/.afunix";

	umask(0077);

	int status = unlink(file);
	if (status < 0 && errno != ENOENT)
	{
		printf("unlink() failed with %d\n", errno);
		return 1;
	}

	int fd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (fd < 0)
	{
		printf("socket() failed with %d\n", errno);
		return 1;
	}

	struct sockaddr_un address;
	memset(&address, 0, sizeof(address));
	address.sun_family = AF_UNIX;
	strcpy(address.sun_path, file);
	int len = sizeof(address);
	status = bind(fd, (sockaddr*) &address, len);
	if (status < 0)
	{
		printf("bind() failed with %d\n", errno);
		return 1;
	}

	status = chmod(file, 0777);
	if (status < 0)
	{
		printf("chmod() failed with %d\n", errno);
		return 1;
	}

	return 0;
}


--Boundary_(ID_DcAPNjcZ/GC9naH3EkNfFA)
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--Boundary_(ID_DcAPNjcZ/GC9naH3EkNfFA)--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019