pst@comdesign.cdi.com (Paul Traina) (01/31/89)
I've just brought up X11R3 on Suns (SunOS 3.5) and a MacII w/A/UX. xdm is failing to execute the Xsession script. I've checked the protection on /usr/lib/X11/xdm/Xsession, it looks just fine to me. The error I get is "Session execution failed /usr/lib/X11/xdm/Xsession". Turns out, in yet another "AT&T, the right choice" brain-deadism has struck. execvp & execlp will run the shell if the argument passed is a non-executable, but execve (what we need) won't. My kludgey solution was the following diff to clients/xdm/session.c. Since I got the source off of scam.berkeley.edu last week, I'm not positive what patch level we're at, but I believe we're at least at patch level 7 on X11R3. I'm sorry for the roughness of this patch, but I needed to get this done quickly. A proper job would be to add emulation of the execve() system call into Berklib.c for those of us who are using System5. Please let me know if you have any problems, if you have better ideas, just send them on to the nice folks at Athena. *** session.c.dist Mon Jan 30 21:47:11 1989 --- session.c Mon Jan 30 23:05:21 1989 *************** *** 28,33 # include <X11/Xatom.h> # include <setjmp.h> static int clientPid; ManageSession (d) --- 28,37 ----- # include <X11/Xatom.h> # include <setjmp.h> + # if defined(macII) || defined(SYSV) + # include <sys/errno.h> + # endif + static int clientPid; ManageSession (d) *************** *** 169,174 char *failsafeArgv[2]; int pid; Debug ("StartSession %s: ", verify->argv[0]); for (f = verify->argv; *f; f++) Debug ("%s ", *f); --- 173,184 ----- char *failsafeArgv[2]; int pid; + #if defined(macII) || defined(SYSV) + extern int errno; + int i; + char *args[255]; + #endif + Debug ("StartSession %s: ", verify->argv[0]); for (f = verify->argv; *f; f++) Debug ("%s ", *f); *************** *** 197,202 } Debug ("executing session %s\n", verify->argv[0]); execve (verify->argv[0], verify->argv, verify->userEnviron); LogError ("Session execution failed %s\n", verify->argv[0]); Debug ("exec failed\n"); failsafeArgv[0] = d->failsafeClient; --- 207,232 ----- } Debug ("executing session %s\n", verify->argv[0]); execve (verify->argv[0], verify->argv, verify->userEnviron); + + #if defined(macII) || defined(SYSV) + /* SystemV (and MacII's) will only exec shell scripts if + execvp or execlp are used. The easiest way to kludge + it is if an exec fails, try again, calling the shell. + -- note we get shell out of systemEnviron, not user + environ -- this isn't a bug */ + + if (errno == ENOEXEC) { + Debug("exec failed, interpreting as shell script\n"); + if (!(args[0] = getEnv(verify->systemEnviron,"SHELL"))) + args[0] = "/bin/sh"; + args[1] = "-c"; + for (i = 2, f = verify->argv; *f; i++, f++) + args[i] = *f; + args[i] = 0; + execve(args[0], args, verify->userEnviron); + } + #endif + LogError ("Session execution failed %s\n", verify->argv[0]); Debug ("exec failed\n"); failsafeArgv[0] = d->failsafeClient; ------ work: pst@condor.cdi.com {apple,pyramid,ucsbcsl,uunet}!comdesign!pst play: pst@ai.ai.mit.edu {ucsbcsl,comdesign,dscvax2}!nessus!pst school: pst@cornu.ucsb.edu pst@sbitp.bitnet "I'm not a scientist, but I play one on TV."