Newsgroups: comp.sys.sgi Path: utzoo!censor!geac!alias!dino!chk From: chk%alias@csri.toronto.edu (C. Harald Koch) Subject: Re: patch for X11R4 version of XDM Message-ID: <1990Dec3.195631.27612@alias.uucp> Sender: news@alias.uucp (USENET News) Reply-To: chk%alias@csri.toronto.edu (C. Harald Koch) Organization: Alias Research, Inc. Toronto ON Canada References: <1990Nov27.213113.8766@alias.uucp> Date: 3 Dec 90 15:27:39 GMT In <1990Nov27.213113.8766@alias.uucp> I write: >Basically, the fix is to call WaitForSomething() instead of WaitForChild() >on sgi machines. Normally, the code there will also process dead children >(necessary for Xservers support) but the code also relies heavily on BSD >signal semantics, and fails on SysV machines. Heh. I have been informed that IRIX now supports BSD signals also, if you link with the -lbsd library. To get the MIT distribution to do this, you have to change mit/config/sgi.cf to still use -lbsd as a link library under 3.3. The changes are near the top of sgi.cf, where it checks for MajorRevision == 3 and MinorRevision <= 2; add '-lbsd' to the list of libraries used under 3.3. Also, you have to change many of the occurrences of #ifdef SYSV to #if defined(SYSV) && !defined(sgi). I have included my current set of patches to XDM below; there are a couple of changes that make debugging a) easier and b) more secure hidden in there, but other than that the changes are for compiling full functionality under IRIX 3.3. As usual, these patches have been tested but not very well, since we have a limited environment here. Use at your own risk. Enjoy! ---------- Cut Here ---------- diff -r -c ../xdm.DIST/daemon.c ./daemon.c *** ../xdm.DIST/daemon.c Wed Sep 12 16:46:18 1990 --- ./daemon.c Wed Oct 24 14:55:49 1990 *************** *** 25,30 **** --- 25,31 ---- #endif extern void exit (); + extern int debugLevel; BecomeDaemon () { *************** *** 50,57 **** #endif close (0); ! close (1); ! close (2); if ((i = open ("/dev/tty", O_RDWR)) >= 0) { /* did open succeed? */ #if defined(SYSV) && defined(TIOCTTY) --- 51,60 ---- #endif close (0); ! if (debugLevel == 0) { ! close (1); ! close (2); ! } if ((i = open ("/dev/tty", O_RDWR)) >= 0) { /* did open succeed? */ #if defined(SYSV) && defined(TIOCTTY) *************** *** 67,72 **** * Set up the standard file descriptors. */ (void) open ("/", O_RDONLY); /* root inode already in core */ ! (void) dup2 (0, 1); ! (void) dup2 (0, 2); } --- 70,77 ---- * Set up the standard file descriptors. */ (void) open ("/", O_RDONLY); /* root inode already in core */ ! if (debugLevel == 0) { ! (void) dup2 (0, 1); ! (void) dup2 (0, 2); ! } } diff -r -c ../xdm.DIST/dm.c ./dm.c *** ../xdm.DIST/dm.c Tue Sep 18 10:53:43 1990 --- ./dm.c Mon Dec 3 11:52:37 1990 *************** *** 60,66 **** char **argv; { int oldpid, oldumask; ! #ifndef SYSV static SIGVAL ChildNotify (); #endif --- 60,66 ---- char **argv; { int oldpid, oldumask; ! #if !defined(SYSV) || defined(sgi) static SIGVAL ChildNotify (); #endif *************** *** 86,93 **** fprintf (stderr, "Only root wants to run %s\n", argv[0]); exit (1); } ! if (debugLevel == 0 && daemonMode) ! BecomeDaemon (); if (oldpid = StorePid ()) { if (oldpid == -1) --- 86,104 ---- fprintf (stderr, "Only root wants to run %s\n", argv[0]); exit (1); } ! if (daemonMode) { ! if (debugLevel) { ! int fd; ! if ((fd = open("/tmp/xdm.debug", O_CREAT|O_TRUNC|O_WRONLY, 0666)) == -1) { ! debugLevel = 0; ! } ! else { ! dup2(fd, 1); ! dup2(fd, 2); ! } ! } ! BecomeDaemon (); ! } if (oldpid = StorePid ()) { if (oldpid == -1) *************** *** 111,119 **** ScanServers (); StartDisplays (); (void) signal (SIGHUP, RescanNotify); - #ifndef SYSV (void) signal (SIGCHLD, ChildNotify); ! #endif while (AnyWellKnownSockets() || AnyDisplaysLeft ()) { if (Rescan) --- 122,129 ---- ScanServers (); StartDisplays (); (void) signal (SIGHUP, RescanNotify); (void) signal (SIGCHLD, ChildNotify); ! while (AnyWellKnownSockets() || AnyDisplaysLeft ()) { if (Rescan) *************** *** 121,127 **** RescanServers (); Rescan = 0; } ! #ifdef SYSV WaitForChild (); #else WaitForSomething (); --- 131,137 ---- RescanServers (); Rescan = 0; } ! #if defined(SYSV) && !defined(sgi) WaitForChild (); #else WaitForSomething (); *************** *** 135,141 **** { Debug ("Caught SIGHUP\n"); Rescan = 1; ! #ifdef SYSV signal (SIGHUP, RescanNotify); #endif } --- 145,151 ---- { Debug ("Caught SIGHUP\n"); Rescan = 1; ! #if defined(SYSV) && !defined(sgi) signal (SIGHUP, RescanNotify); #endif } *************** *** 248,254 **** Debug ("Shutting down entire manager\n"); DestroyWellKnownSockets (); ForEachDisplay (StopDisplay); ! #ifdef SYSV /* to avoid another one from killing us unceremoniously */ (void) signal (SIGTERM, StopAll); (void) signal (SIGINT, StopAll); --- 258,264 ---- Debug ("Shutting down entire manager\n"); DestroyWellKnownSockets (); ForEachDisplay (StopDisplay); ! #if defined(SYSV) && !defined(sgi) /* to avoid another one from killing us unceremoniously */ (void) signal (SIGTERM, StopAll); (void) signal (SIGINT, StopAll); *************** *** 262,272 **** int ChildReady; ! #ifndef SYSV static SIGVAL ChildNotify () { ChildReady = 1; } #endif --- 272,282 ---- int ChildReady; ! #if !defined(SYSV) || defined(sgi) static SIGVAL ChildNotify () { ChildReady = 1; } #endif *************** *** 277,283 **** waitType status; int mask; ! #ifdef SYSV /* XXX classic sysV signal race condition here with RescanNotify */ if ((pid = wait (&status)) != -1) #else --- 287,293 ---- waitType status; int mask; ! #if defined(SYSV) && !defined(sgi) /* XXX classic sysV signal race condition here with RescanNotify */ if ((pid = wait (&status)) != -1) #else diff -r -c ../xdm.DIST/dm.h ./dm.h *** ../xdm.DIST/dm.h Wed Sep 12 16:46:16 1990 --- ./dm.h Mon Dec 3 11:48:02 1990 *************** *** 35,41 **** #undef dirty /* Some bozo put a macro called dirty in sys/param.h */ #endif /* pegasus */ ! #ifdef SYSV # define waitCode(w) (((w) >> 8) & 0xff) # define waitSig(w) ((w) & 0xff) typedef int waitType; --- 35,41 ---- #undef dirty /* Some bozo put a macro called dirty in sys/param.h */ #endif /* pegasus */ ! #if defined(SYSV) && !defined(sgi) # define waitCode(w) (((w) >> 8) & 0xff) # define waitSig(w) ((w) & 0xff) typedef int waitType; diff -r -c ../xdm.DIST/server.c ./server.c *** ../xdm.DIST/server.c Tue Sep 18 10:53:44 1990 --- ./server.c Mon Dec 3 10:52:40 1990 *************** *** 36,42 **** static SIGVAL CatchUsr1 () { ! #ifdef SYSV (void) signal (SIGUSR1, CatchUsr1); #endif Debug ("display manager caught SIGUSR1\n"); --- 36,42 ---- static SIGVAL CatchUsr1 () { ! #if defined(SYSV) && !defined(sgi) (void) signal (SIGUSR1, CatchUsr1); #endif Debug ("display manager caught SIGUSR1\n"); *************** *** 138,144 **** if (!setjmp (pauseAbort)) { signal (SIGALRM, serverPauseAbort); signal (SIGUSR1, serverPauseUsr1); ! #ifdef SYSV if (receivedUsr1) alarm ((unsigned) 1); else --- 138,144 ---- if (!setjmp (pauseAbort)) { signal (SIGALRM, serverPauseAbort); signal (SIGUSR1, serverPauseUsr1); ! #if defined(SYSV) && !defined(sgi) if (receivedUsr1) alarm ((unsigned) 1); else *************** *** 150,156 **** Debug ("Already received USR1\n"); #endif for (;;) { ! #ifdef SYSV pid = wait ((waitType *) 0); #else if (!receivedUsr1) --- 150,156 ---- Debug ("Already received USR1\n"); #endif for (;;) { ! #if defined(SYSV) && !defined(sgi) pid = wait ((waitType *) 0); #else if (!receivedUsr1) *************** *** 166,172 **** serverPauseRet = 1; break; } ! #ifndef SYSV if (pid == 0) { Debug ("Server alive and kicking\n"); break; --- 166,172 ---- serverPauseRet = 1; break; } ! #if !defined(SYSV) || defined(sgi) if (pid == 0) { Debug ("Server alive and kicking\n"); break; diff -r -c ../xdm.DIST/session.c ./session.c *** ../xdm.DIST/session.c Tue Sep 18 10:53:43 1990 --- ./session.c Mon Dec 3 10:52:40 1990 *************** *** 443,449 **** char **environ; { execve (argv[0], argv, environ); ! #ifdef SYSV /* * shell scripts can't be run in SYSV directly */ --- 443,449 ---- char **environ; { execve (argv[0], argv, environ); ! #if defined(SYSV) && !defined(sgi) /* * shell scripts can't be run in SYSV directly */ diff -r -c ../xdm.DIST/verify.c ./verify.c *** ../xdm.DIST/verify.c Wed Sep 12 16:46:17 1990 --- ./verify.c Wed Oct 24 14:34:09 1990 *************** *** 49,55 **** p = getpwnam (greet->name); if (!p || strlen (greet->name) == 0) p = &joeblow; ! Debug ("Verify %s %s\n", greet->name, greet->password); if (strcmp (crypt (greet->password, p->pw_passwd), p->pw_passwd)) { Debug ("verify failed\n"); bzero(greet->password, strlen(greet->password)); --- 49,55 ---- p = getpwnam (greet->name); if (!p || strlen (greet->name) == 0) p = &joeblow; ! Debug ("Verify %s\n", greet->name, greet->password); if (strcmp (crypt (greet->password, p->pw_passwd), p->pw_passwd)) { Debug ("verify failed\n"); bzero(greet->password, strlen(greet->password)); *************** *** 94,99 **** --- 94,100 ---- env = setEnv (env, "DISPLAY", d->name); env = setEnv (env, "HOME", home); + env = setEnv (env, "LOGNAME", user); env = setEnv (env, "USER", user); env = setEnv (env, "PATH", d->userPath); env = setEnv (env, "SHELL", shell); *************** *** 109,114 **** --- 110,116 ---- env = setEnv (env, "DISPLAY", d->name); env = setEnv (env, "HOME", home); + env = setEnv (env, "LOGNAME", user); env = setEnv (env, "USER", user); env = setEnv (env, "PATH", d->systemPath); env = setEnv (env, "SHELL", d->systemShell); diff -r -c ../xdm.DIST/xdmshell.c ./xdmshell.c *** ../xdm.DIST/xdmshell.c Tue Sep 18 10:53:43 1990 --- ./xdmshell.c Mon Dec 3 11:54:07 1990 *************** *** 85,91 **** if (access (filename, X_OK) != 0) return -1; ! #ifdef SYSV status = 0; #else waitCode (status) = 0; --- 85,91 ---- if (access (filename, X_OK) != 0) return -1; ! #if defined(SYSV) && !defined(sgi) status = 0; #else waitCode (status) = 0; ---------- Cut Here ---------- -- C. Harald Koch VE3TLA Alias Research, Inc., Toronto ON Canada chk%alias@csri.utoronto.ca chk@gpu.utcs.toronto.edu chk@chk.mef.org "Open the Zamboni! We're coming out!" - Kathrin Garland and Anson James, 2299