diff options
Diffstat (limited to 'xc/programs/xdm/auth.c')
-rw-r--r-- | xc/programs/xdm/auth.c | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/xc/programs/xdm/auth.c b/xc/programs/xdm/auth.c index c01cde8fc..e14c0c117 100644 --- a/xc/programs/xdm/auth.c +++ b/xc/programs/xdm/auth.c @@ -1,4 +1,4 @@ -/* $XConsortium: auth.c,v 1.57 94/10/07 19:46:21 converse Exp kaleb $ */ +/* $XConsortium: auth.c,v 1.58 94/11/21 18:33:11 kaleb Exp gildea $ */ /* Copyright (c) 1988 X Consortium @@ -42,6 +42,12 @@ from the X Consortium. #include <X11/X.h> #include <sys/types.h> #include <sys/stat.h> + +#include <errno.h> +#ifdef X_NOT_STDC_ENV +extern int errno; +#endif + #include <sys/socket.h> #ifndef ESIX # include <sys/ioctl.h> @@ -87,7 +93,7 @@ extern Xauth *MitGetAuth (); extern int XdmInitAuth (); extern Xauth *XdmGetAuth (); #ifdef XDMCP -extern int XdmGetXdmcpAuth (); +extern void XdmGetXdmcpAuth (); #else #define XdmGetXdmcpAuth NULL #endif @@ -108,7 +114,7 @@ struct AuthProtocol { char *name; int (*InitAuth)(); Xauth *(*GetAuth)(); - int (*GetXdmcpAuth)(); + void (*GetXdmcpAuth)(); int inited; }; @@ -265,6 +271,9 @@ CleanUpFileName (src, dst, len) *dst = '\0'; } +static char authdir1[] = "authdir"; +static char authdir2[] = "authfiles"; + static MakeServerAuthFile (d) struct display *d; @@ -276,13 +285,16 @@ MakeServerAuthFile (d) #define NAMELEN 255 #endif char cleanname[NAMELEN]; + int r; + struct stat statb; if (d->clientAuthFile && *d->clientAuthFile) len = strlen (d->clientAuthFile) + 1; else { CleanUpFileName (d->name, cleanname, NAMELEN - 8); - len = strlen (authDir) + strlen (cleanname) + 12; + len = strlen (authDir) + strlen (authdir1) + strlen (authdir2) + + strlen (cleanname) + 14; } if (d->authFile) free (d->authFile); @@ -293,7 +305,31 @@ MakeServerAuthFile (d) strcpy (d->authFile, d->clientAuthFile); else { - sprintf (d->authFile, "%s/A%s-XXXXXX", authDir, cleanname); + sprintf (d->authFile, "%s/%s", authDir, authdir1); + r = stat(d->authFile, &statb); + if (r == 0) { + if (statb.st_uid != 0) + (void) chown(d->authFile, 0, statb.st_gid); + if ((statb.st_mode & 0077) != 0) + (void) chmod(d->authFile, statb.st_mode & 0700); + } else { + if (errno == ENOENT) + r = mkdir(d->authFile, 0700); + if (r < 0) { + free (d->authFile); + d->authFile = NULL; + return FALSE; + } + } + sprintf (d->authFile, "%s/%s/%s", authDir, authdir1, authdir2); + r = mkdir(d->authFile, 0700); + if (r < 0 && errno != EEXIST) { + free (d->authFile); + d->authFile = NULL; + return FALSE; + } + sprintf (d->authFile, "%s/%s/%s/A%s-XXXXXX", + authDir, authdir1, authdir2, cleanname); (void) mktemp (d->authFile); } return TRUE; @@ -600,10 +636,10 @@ writeAuth (file, auth) FILE *file; Xauth *auth; { -#if 0 /* too verbose */ + if (debugLevel >= 15) { /* normally too verbose */ Debug ("writeAuth: doWrite = %d\n", doWrite); dumpAuth (auth); /* does Debug only */ -#endif + } if (doWrite) XauWriteAuth (file, auth); } @@ -745,7 +781,7 @@ DefineSelf (fd, file, auth) if (IA_SIN(&ifaddr)->sin_addr.s_addr == htonl(0x7f000001) ) continue; - writeAddr (FamilyInternet, 4, &(IA_SIN(&ifaddr)->sin_addr), file, auth); + writeAddr (FamilyInternet, 4, (char *)&(IA_SIN(&ifaddr)->sin_addr), file, auth); } close(ipfd); |