keane@ultima.cs.uts.oz.au (Chris Keane) (06/09/90)
Submitted-by: keane@ultima.cs.uts.oz.au (Chris Keane) Posting-number: Volume 7, Issue 87 Archive-name: xdm/patch1.01 Here are the diffs to xdm to put a console window up (so console messages don't destroy the screen). Please note that these are in no way official patches to xdm! Use them at your own risk! These diffs should be unpacked in ...mit/clients/xdm and applied with: #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README.console get_pty.c makeconsole.c patch1 xdmconsole.c # xdmconsole.h # Wrapped by keane@zeus on Fri Jun 8 16:32:36 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README.console' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README.console'\" else echo shar: Extracting \"'README.console'\" \(3059 characters\) sed "s/^X//" >'README.console' <<'END_OF_FILE' X X XHere are the diffs to xdm to put a console window up (so console messages Xdon't destroy the screen). Please note that these are in no way official Xpatches to xdm! Use them at your own risk! These diffs should be unpacked Xin ...mit/clients/xdm and applied with: X Xmake Makefile Xmake X XThese diffs have been tested on Sun3, Sun386i and sunSS1 workstations all Xrunning SunOS 4.0.x. The diffs have been tested under X11r3 and X11r4, although Xonly the diffs for X11r4 are included here. If you need the X11r3 stuff, I Xspose I can hack a copy out, but the diffs are so small you should be able to do Xit yourself. X XThis new version creates an application called xdmconsole. All it really Xdoes it display any text that it reads from stdin. This window is created Xwhen the xdm Login widget appears. The window persists throughout a user's Xsession (unless the silly fool kills it :-). The window is destroyed at the Xend of a user's session and is re-created when the Login widget re-appears. XThere is a tiny period between the xdm-reset and the arrival of the Login Xwidget in which messages to the console will actually appear on the console... XI thought about it and can't think of any nice ways of fixing it, the Xproblem isn't major (I've never seen it happen), so I didn't worry. X XThe patch to xdm basically allows for the creation of the tty/pty pair Xthat becomes the new console (this happens in dm.c), the hijack of the Xconsole output (using ioctl with TIOCCONS, the console is re-assigned to Xthe tty of the tty/pty pair), the re-assignment of stdin to the pty side Xof the pair and the creation of the xdmconsole process (that, suprise, Xsuprise, reads from stdin which just now happens to be the pty) (all this Xhappens in makeconsole.c, get_pty.c and is called from session.c) X XThe code to get a pty/tty pair was lifted wholesale from xterm. X XBe warned! The code for this (esp. the X stuff) is exceedingly bad. Rather Xshameful might be more accurate (c'mon, it was my 2nd attempt at XLib Xprogramming). I hadn't even heard of the X toolkit when I first wrote this Xcode, and don't expect to be able to set any resources either. XAlso, be careful of changing anything! The text printing in the window Xrelies on the text being a certain size (puke :-), and, in fact, the Xwindow being a certain size as well. The current setting places the Xwindow in the horizontal middle of your screen, with about a 30 pixel gap Xbetween the bottom of the window and the bottom of the screen. X XAlso, you will have to set X XDisplayManager*grabServer: false X Xin .../xdm/xdm-config, otherwise the window simply won't be able to appear Xuntil the user actually logs in, which rather defeats the purpose :-) X XAll in all, though, it doesn't look TOO bad. One day I may even get around Xto making it really nice, but please be aware that I'll only provide Xminimal support for it. X Xregards... X Chris Keane. X Glorified Laboratory Attendant, X University of Technology, Sydney. X keane@ultima.cs.uts.oz.au X or is it keane@ultima.socs.uts.edu.au? X I can never remember. X END_OF_FILE if test 3059 -ne `wc -c <'README.console'`; then echo shar: \"'README.console'\" unpacked with wrong size! fi # end of 'README.console' fi if test -f 'get_pty.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'get_pty.c'\" else echo shar: Extracting \"'get_pty.c'\" \(1387 characters\) sed "s/^X//" >'get_pty.c' <<'END_OF_FILE' X#include "ptyx.h" X#include <stdio.h> X Xextern char *ttydev; Xextern char *ptydev; X Xget_pty (pty) Xint *pty; X{ X static int devindex, letter = 0; X X X ttydev = (char *) malloc (strlen (TTYDEV) + 1); X ptydev = (char *) malloc (strlen (PTYDEV) + 1); X if (!ttydev || !ptydev) { X fprintf (stderr, X "cons: unable to allocate memory for ttydev or ptydev\n"); X return (1); X } X strcpy (ttydev, TTYDEV); X strcpy (ptydev, PTYDEV); X X X while (PTYCHAR1[letter]) { X ttydev [strlen(ttydev) - 2] = ptydev [strlen(ptydev) - 2] = X PTYCHAR1 [letter]; X X while (PTYCHAR2[devindex]) { X ttydev [strlen(ttydev) - 1] = ptydev [strlen(ptydev) - 1] = X PTYCHAR2 [devindex]; X if ((*pty = open (ptydev, O_RDWR)) >= 0) { X /* We need to set things up for our next entry X * into this function! X */ X (void) devindex++; X return(0); X } X devindex++; X } X devindex = 0; X (void) letter++; X } X /* We were unable to allocate a pty master! Return an error X * condition and let our caller terminate cleanly. X */ X return(1); X} END_OF_FILE if test 1387 -ne `wc -c <'get_pty.c'`; then echo shar: \"'get_pty.c'\" unpacked with wrong size! fi # end of 'get_pty.c' fi if test -f 'makeconsole.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makeconsole.c'\" else echo shar: Extracting \"'makeconsole.c'\" \(835 characters\) sed "s/^X//" >'makeconsole.c' <<'END_OF_FILE' X#include <fcntl.h> X#include <sys/termios.h> X#include <sys/wait.h> X#define FONT "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1" X#include "xdmconsole.h" X#define PTYPROC "/usr/bin/X11/xdmconsole" X Xchar *ttydev; Xchar *ptydev; X Xextern int tty, pty; X X Xint getttys() X{ X if ((get_pty(&pty)) != 0) return(-1); X if ((tty=open(ttydev, O_RDWR, 0)) < 0) X { X return(-1); X } X return(0); X} X X X Xint make_console() X{ X int childpid; X X if ((childpid=fork())==0) X { X close(0); X dup(pty); X X execl(PTYPROC, "console", 0); X } X if (ioctl(tty, TIOCCONS, 0) < 0) X { X return(-1); X } X return(childpid); X} X Xint kill_console(childpid) Xint childpid; X{ X X/* X if (childpid > 20) X if (kill(childpid, 9) != -1) X if (wait((union wait *) 0) == -1) X perror("console"); X for some reason, this seems to kill xdm totally sometimes (about 1 in 50) X*/ X X} END_OF_FILE if test 835 -ne `wc -c <'makeconsole.c'`; then echo shar: \"'makeconsole.c'\" unpacked with wrong size! fi # end of 'makeconsole.c' fi if test -f 'patch1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patch1'\" else echo shar: Extracting \"'patch1'\" \(9035 characters\) sed "s/^X//" >'patch1' <<'END_OF_FILE' X*** Imakefile Fri Jun 8 15:51:50 1990 X--- Imakefile Fri Jun 1 12:02:59 1990 X*************** X*** 27,43 **** X SRCS1 = auth.c daemon.c server.c dpylist.c dm.c error.c \ X file.c greet.c reset.c resource.c protodpy.c policy.c \ X session.c socket.c util.c verify.c Login.c mitauth.c \ X! cryptokey.c $(DESSRCS) X OBJS1 = auth.o daemon.o server.o dpylist.o dm.o error.o \ X file.o greet.o reset.o resource.o protodpy.o policy.o \ X session.o socket.o util.o verify.o Login.o mitauth.o \ X! cryptokey.o $(DESOBJS) X SRCS2 = xdmshell.c X OBJS2 = xdmshell.o X SRCS4 = sessreg.c X OBJS4 = sessreg.o X! PROGRAMS = xdm xdmshell sessreg X X #if !HasVoidSignalReturn X SIGDEFS = -DSIGNALRETURNSINT X #endif X--- 27,46 ---- X SRCS1 = auth.c daemon.c server.c dpylist.c dm.c error.c \ X file.c greet.c reset.c resource.c protodpy.c policy.c \ X session.c socket.c util.c verify.c Login.c mitauth.c \ X! cryptokey.c get_pty.c makeconsole.c $(DESSRCS) X OBJS1 = auth.o daemon.o server.o dpylist.o dm.o error.o \ X file.o greet.o reset.o resource.o protodpy.o policy.o \ X session.o socket.o util.o verify.o Login.o mitauth.o \ X! cryptokey.o get_pty.o makeconsole.o $(DESOBJS) X SRCS2 = xdmshell.c X OBJS2 = xdmshell.o X SRCS4 = sessreg.c X OBJS4 = sessreg.o X! SRCS3 = xdmconsole.c xroutines.c X! OBJS3 = xdmconsole.o xroutines.o X X+ PROGRAMS = xdm xdmshell sessreg xdmconsole X+ X #if !HasVoidSignalReturn X SIGDEFS = -DSIGNALRETURNSINT X #endif X*************** X*** 68,73 **** X--- 71,77 ---- X '-DCPP_PROGRAM="$(CPP_PROGRAM)"' X X ComplexProgramTarget_1(xdm,$(LOCAL_LIBRARIES), /**/) X+ ComplexProgramTarget_3(xdmconsole,$(XLIB), /**/) X SingleProgramTarget(xdmshell,$(OBJS2), /**/, /**/) X SingleProgramTarget(sessreg,$(OBJS4), /**/, /**/) X X*** Makefile Fri Jun 8 15:51:51 1990 X--- Makefile Fri Jun 8 15:14:15 1990 X*************** X*** 82,88 **** X X DESTDIR = X X! TOP_INCLUDES = -I$(TOP) X X CDEBUGFLAGS = -O X CCOPTIONS = X--- 82,88 ---- X X DESTDIR = X X! TOP_INCLUDES = -I$(INCROOT) X X CDEBUGFLAGS = -O X CCOPTIONS = X*************** X*** 101,108 **** X X IMAKE_DEFINES = X X! IRULESRC = $(CONFIGSRC) X! IMAKE_CMD = $(NEWTOP)$(IMAKE) -I$(NEWTOP)$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X--- 101,108 ---- X X IMAKE_DEFINES = X X! IRULESRC = $(CONFIGDIR) X! IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X*************** X*** 152,163 **** X X INSTAPPFLAGS = $(INSTDATFLAGS) X X! IMAKE = $(IMAKESRC)/imake X! DEPEND = $(DEPENDSRC)/makedepend X! RGB = $(RGBSRC)/rgb X! FONTC = $(BDFTOSNFSRC)/bdftosnf X! MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir X! MKDIRHIER = /bin/sh $(SCRIPTSRC)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X--- 152,163 ---- X X INSTAPPFLAGS = $(INSTDATFLAGS) X X! IMAKE = imake X! DEPEND = makedepend X! RGB = rgb X! FONTC = bdftosnf X! MKFONTDIR = mkfontdir X! MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X*************** X*** 185,220 **** X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X! DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a X EXTENSIONLIB = -lXext X X! DEPXLIB = $(DEPEXTENSIONLIB) X XLIB = $(EXTENSIONLIB) -lX11 X X! DEPXAUTHLIB = $(XAUTHSRC)/libXau.a X! XAUTHLIB = $(DEPXAUTHLIB) X X DEPXMULIB = X! XMULIB = -L$(XMUSRC) -lXmu X X DEPOLDXLIB = X! OLDXLIB = -L$(OLDXLIBSRC) -loldX X X DEPXTOOLLIB = X! XTOOLLIB = -L$(TOOLKITSRC) -lXt X X DEPXAWLIB = X! XAWLIB = -L$(AWIDGETSRC) -lXaw X X! LINTEXTENSIONLIB = $(EXTENSIONSRC)/lib/llib-lXext.ln X! LINTXLIB = $(XLIBSRC)/llib-lX11.ln X! LINTXMU = $(XMUSRC)/llib-lXmu.ln X! LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln X! LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln X X XWLIBSRC = $(CONTRIBSRC)/toolkits/Xw X! DEPXWLIB = $(XWLIBSRC)/libXw.a X! XWLIB = $(DEPXWLIB) X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X--- 185,220 ---- X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X! DEPEXTENSIONLIB = X EXTENSIONLIB = -lXext X X! DEPXLIB = X XLIB = $(EXTENSIONLIB) -lX11 X X! DEPXAUTHLIB = X! XAUTHLIB = -lXau X X DEPXMULIB = X! XMULIB = -lXmu X X DEPOLDXLIB = X! OLDXLIB = -loldX X X DEPXTOOLLIB = X! XTOOLLIB = -lXt X X DEPXAWLIB = X! XAWLIB = -lXaw X X! LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln X! LINTXLIB = $(USRLIBDIR)/llib-lX11.ln X! LINTXMU = $(USRLIBDIR)/llib-lXmu.ln X! LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln X! LINTXAW = $(USRLIBDIR)/llib-lXaw.ln X X XWLIBSRC = $(CONTRIBSRC)/toolkits/Xw X! DEPXWLIB = $(USRLIBDIR)/libXw.a X! XWLIB = -lXw X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X*************** X*** 236,243 **** X XDMCONFIGDIR = config/default X SUBDIRS = $(XDMCONFIGDIR) X X LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) \ X! $(TOP)/lib/Xau/libXau.a $(TOP)/lib/Xdmcp/libXdmcp.a $(XLIB) X SRCS1 = auth.c daemon.c server.c dpylist.c dm.c error.c \ X file.c greet.c reset.c resource.c protodpy.c policy.c \ X session.c socket.c util.c verify.c Login.c mitauth.c \ X--- 236,245 ---- X XDMCONFIGDIR = config/default X SUBDIRS = $(XDMCONFIGDIR) X X+ DEPLIBS = X+ X LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) \ X! -lXau -lXdmcp $(XLIB) X SRCS1 = auth.c daemon.c server.c dpylist.c dm.c error.c \ X file.c greet.c reset.c resource.c protodpy.c policy.c \ X session.c socket.c util.c verify.c Login.c mitauth.c \ X*************** X*** 296,308 **** X install.man:: xdm.man X $(INSTALL) -c $(INSTMANFLAGS) xdm.man $(MANDIR)/xdm.n X X- depend:: $(DEPEND) X- X- $(DEPEND): X- @echo "checking $@ over in $(DEPENDSRC) first..."; \ X- cd $(DEPENDSRC); $(MAKE); \ X- echo "okay, continuing in $(CURRENT_DIR)" X- X depend:: X $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) X X--- 298,303 ---- X*************** X*** 349,363 **** X X clean:: X $(RM_CMD) \#* X- X- Makefile:: $(IMAKE) X- X- $(IMAKE): X- @(cd $(IMAKESRC); if [ -f Makefile ]; then \ X- echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \ X- echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \ X- $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \ X- echo "okay, continuing in $(CURRENT_DIR)") X X Makefile:: X -@if [ -f Makefile ]; then \ X--- 344,349 ---- X*** dm.c Fri Jun 8 15:51:52 1990 X--- dm.c Fri Jun 1 11:17:13 1990 X*************** X*** 45,50 **** X--- 45,51 ---- X static SIGVAL StopAll (), RescanNotify (); X void StopDisplay (); X static void RestartDisplay (); X+ int tty, pty; X X #ifndef NOXDMTITLE X static char *Title; X*************** X*** 81,86 **** X--- 82,91 ---- X } X if (debugLevel == 0 && daemonMode) X BecomeDaemon (); X+ /* X+ * grab the console so no messages go there X+ */ X+ getttys(); X if (oldpid = StorePid ()) X { X if (oldpid == -1) X*** session.c Fri Jun 8 15:51:54 1990 X--- session.c Fri Jun 1 11:17:15 1990 X*************** X*** 96,106 **** X--- 96,112 ---- X exit(UNMANAGE_DISPLAY); X } X X+ X+ /* import the tty/pty pair from where they were initialised...Chris */ X+ extern int tty, pty; X+ X+ X ManageSession (d) X struct display *d; X { X int pid; X Display *dpy, *InitGreet (); X+ int childpid; X X Debug ("ManageSession %s\n", d->name); X (void)XSetIOErrorHandler(IOErrorHandler); X*************** X*** 112,117 **** X--- 118,127 ---- X LoadXloginResources (d); X Debug ("name now %s\n", d->name); X dpy = InitGreet (d); X+ /* X+ * Step 5a: put up a console window...Chris. X+ */ X+ childpid=make_console(); X if (d->authorization && d->authFile) X { X Debug ("Done with authorization file %s, removing\n", d->authFile); X*************** X*** 194,199 **** X--- 204,213 ---- X */ X Debug ("Source reset program %s\n", d->reset); X source (&verify, d->reset); X+ /* X+ * make sure that the console got nuked along with everything else...Chris. X+ */ X+ kill_console(childpid); X SessionExit (d, OBEYSESS_DISPLAY); X } X END_OF_FILE if test 9035 -ne `wc -c <'patch1'`; then echo shar: \"'patch1'\" unpacked with wrong size! fi # end of 'patch1' fi if test -f 'xdmconsole.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xdmconsole.c'\" else echo shar: Extracting \"'xdmconsole.c'\" \(1046 characters\) sed "s/^X//" >'xdmconsole.c' <<'END_OF_FILE' X#include <fcntl.h> X#define FONT "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1" X#include "xdmconsole.h" X Xint win_err(disp, errorcode) XDisplay *disp; XXErrorEvent *errorcode; X{ X /* Some obscure old event */ X exit(0); X} Xint naughty_win_err(disp) XDisplay *disp; X{ X /* Window not currently in existance */ X exit(0); X} X Xextern int screen; Xextern Display *disp; X Xmain() X{ X char buf[128]; X int size=0; X int inc; X char *name, stdprint[80]; X X X initwin(400, 70, Place, Place, 3, Transient, "Console"); X winfont(FONT); X inc = 15; X wincursor(XC_gumby); X winevents(ExposureMask); X showwin(); X name = (char *) malloc(64); X if (gethostname(name, 64) != -1) X { X strcpy(stdprint, name); X } X strcat(stdprint, " console."); X winprint(2,15, stdprint); X X XSetErrorHandler(win_err); X XSetIOErrorHandler(naughty_win_err); X X X for(;;) X { X if ((size=read(0, buf, sizeof(buf))) > 0); X { X buf[size]='\0'; X if (inc > 59) X { X inc -= 15; X scrollup(15); X } X inc += 15; X winwrapprint(2, inc, buf, 15); X buf[0]='\0'; X size=0; X } X } X} X END_OF_FILE if test 1046 -ne `wc -c <'xdmconsole.c'`; then echo shar: \"'xdmconsole.c'\" unpacked with wrong size! fi # end of 'xdmconsole.c' fi if test -f 'xdmconsole.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xdmconsole.h'\" else echo shar: Extracting \"'xdmconsole.h'\" \(168 characters\) sed "s/^X//" >'xdmconsole.h' <<'END_OF_FILE' X#define Transient 1 X#define Managed 0 X#define Place -1 X#include <X11/cursorfont.h> X#include <strings.h> X#include <X11/Xlib.h> X#include <X11/Xutil.h> X#include <stdio.h> END_OF_FILE if test 168 -ne `wc -c <'xdmconsole.h'`; then echo shar: \"'xdmconsole.h'\" unpacked with wrong size! fi # end of 'xdmconsole.h' fi echo shar: End of shell archive. exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.