--- ./xc/config/cf/sun.cf.orig Thu Apr 15 10:57:35 2004 +++ ./xc/config/cf/sun.cf Sat Apr 17 11:28:58 2004 @@ -297,6 +297,7 @@ # endif # if OSMinorVersion > 9 /* Solaris 10 and later */ # define HasSetenv YES +# define HasGetpeerucred YES /* Solaris 10 includes FreeType already. It's also available in GNOME 2.0 for * Solaris 8 & 9, and in Solaris 9 4/03 and later, but there's no easy way to * detect that in imake, so users of those releases who want to use the --- ./xc/config/cf/Imake.tmpl.orig Thu Apr 15 17:34:43 2004 +++ ./xc/config/cf/Imake.tmpl Sat Apr 17 11:28:31 2004 @@ -465,6 +465,9 @@ #ifndef HasGetpeereid #define HasGetpeereid NO #endif +#ifndef HasGetpeerucred +#define HasGetpeerucred NO +#endif #ifndef NoStrstr #define NoStrstr NO #endif --- ./xc/programs/Xserver/os/Imakefile.orig Fri Mar 5 05:41:11 2004 +++ ./xc/programs/Xserver/os/Imakefile Sat Apr 17 11:26:55 2004 @@ -89,8 +89,12 @@ STRLCAT_OBJS = strlcat.o strlcpy.o #endif -#if HasGetpeereid -GETPEEREID_DEFINES = -DHAS_GETPEEREID +#if HasGetpeerucred +GETPEER_DEFINES = -DHAS_GETPEERUCRED +#else +# if HasGetpeereid +GETPEER_DEFINES = -DHAS_GETPEEREID +# endif #endif BOOTSTRAPCFLAGS = @@ -128,7 +132,7 @@ #endif DEFINES = -DXSERV_t -DTRANS_SERVER $(CONNECTION_FLAGS) $(MEM_DEFINES) \ $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) \ - $(KRB5_DEFINES) $(RGB_DEFINES) $(GETPEEREID_DEFINES) \ + $(KRB5_DEFINES) $(RGB_DEFINES) $(GETPEER_DEFINES) \ $(RANDOM_DEFINES) INCLUDES = -I. -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \ -I$(SERVERSRC)/Xext -I$(FONTINCSRC) -I$(SERVERSRC)/render \ --- ./xc/programs/Xserver/os/access.c.orig Thu Apr 15 10:58:22 2004 +++ ./xc/programs/Xserver/os/access.c Sat Apr 17 11:26:40 2004 @@ -1,5 +1,5 @@ /* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.1.4.3.2.3 2004/03/22 11:57:11 ago Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -88,6 +88,9 @@ #include #endif +#ifdef HAS_GETPEERUCRED +# include +#endif #if defined(DGUX) #include @@ -1365,12 +1368,14 @@ int LocalClientCred(ClientPtr client, int *pUid, int *pGid) { -#if defined(HAS_GETPEEREID) || defined(SO_PEERCRED) +#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) int fd; XtransConnInfo ci; #ifdef HAS_GETPEEREID uid_t uid; gid_t gid; +#elif defined(HAS_GETPEERUCRED) + ucred_t *peercred = NULL; #elif defined(SO_PEERCRED) struct ucred peercred; socklen_t so_len = sizeof(peercred); @@ -1379,10 +1384,15 @@ if (client == NULL) return -1; ci = ((OsCommPtr)client->osPrivate)->trans_conn; - /* We can only determine peer credentials for Unix domain sockets */ +#if !(defined(sun) && defined(HAS_GETPEERUCRED)) + /* Most implementations can only determine peer credentials for Unix + * domain sockets - Solaris getpeerucred can work with a bit more, so + * we just let it tell us if the connection type is supported or not + */ if (!_XSERVTransIsLocal(ci)) { return -1; } +#endif fd = _XSERVTransGetConnectionNumber(ci); #ifdef HAS_GETPEEREID if (getpeereid(fd, &uid, &gid) == -1) @@ -1392,6 +1402,15 @@ if (pGid != NULL) *pGid = gid; return 0; +#elif defined(HAS_GETPEERUCRED) + if (getpeerucred(fd, &peercred) < 0) + return -1; + if (pUid != NULL) + *pUid = ucred_geteuid(peercred); + if (pGid != NULL) + *pGid = ucred_getegid(peercred); + ucred_free(peercred); + return 0; #elif defined(SO_PEERCRED) if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) return -1;