Subject: Are permissions of local sockets correct?
To: None <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 08/21/2005 23:25:56
Hi all,

while trying gamin (a file alteration monitor, like fam), I found that it
refuses to work because it detects that the local sockets it creates
have "too much permissions" (that is, 777).

As I see in our code, local sockets are always created with this
mode, regardless of the user's umask.  Is this correct?  And if so,
why?

FreeBSD, OpenBSD and Linux respect the umask.  If our behavior is
not correct, what about the following patch?

Index: uipc_usrreq.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.83
diff -u -r1.83 uipc_usrreq.c
--- uipc_usrreq.c       16 Jun 2005 14:36:42 -0000      1.83
+++ uipc_usrreq.c       21 Aug 2005 21:16:11 -0000
@@ -638,7 +638,7 @@
        }
        VATTR_NULL(&vattr);
        vattr.va_type =3D VSOCK;
-       vattr.va_mode =3D ACCESSPERMS;
+       vattr.va_mode =3D ACCESSPERMS & ~(p->p_cwdi->cwdi_cmask);
        VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
        error =3D VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
        vn_finished_write(mp, 0);

Thanks,

--=20
Julio M. Merino Vidal <jmmv84@gmail.com>
http://www.livejournal.com/users/jmmv/
The NetBSD Project - http://www.NetBSD.org/