xlock.c revision 919
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Permission is hereby granted, free of charge, to any person obtaining a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * copy of this software and associated documentation files (the "Software"),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to deal in the Software without restriction, including without limitation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the rights to use, copy, modify, merge, publish, distribute, sublicense,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and/or sell copies of the Software, and to permit persons to whom the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Software is furnished to do so, subject to the following conditions:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The above copyright notice and this permission notice (including the next
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * paragraph) shall be included in all copies or substantial portions of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Software.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright * DEALINGS IN THE SOFTWARE.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * xlock.c - X11 client to lock a display and show a screen saver.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright (c) 1988-91 by Patrick J. Naughton.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Permission to use, copy, modify, and distribute this software and its
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * documentation for any purpose and without fee is hereby granted,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * provided that the above copyright notice appear in all copies and that
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * both that copyright notice and this permission notice appear in
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai * supporting documentation.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This file is provided AS IS with no warranties of any kind. The author
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * shall have no liability with respect to the infringement of copyrights,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * trade secrets or any patents by this file or any part thereof. In no
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * event will the author be liable for any lost revenue or profits or
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * other special, indirect and consequential damages.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Comments and additions should be sent to the author:
3db3f65c6274eb042354801a308c8e9bc4994553amw * naughton@eng.sun.com
3db3f65c6274eb042354801a308c8e9bc4994553amw * Patrick J. Naughton
3db3f65c6274eb042354801a308c8e9bc4994553amw * MS 10-20
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sun Laboritories, Inc.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 2550 Garcia Ave
3db3f65c6274eb042354801a308c8e9bc4994553amw * Mountain View, CA 94043
3db3f65c6274eb042354801a308c8e9bc4994553amw * Revision History:
3db3f65c6274eb042354801a308c8e9bc4994553amw * 24-Jun-91: make foreground and background color get used on mono.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 24-May-91: added -usefirst.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 16-May-91: added pyro and random modes.
3db3f65c6274eb042354801a308c8e9bc4994553amw * ripped big comment block out of all other files.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 08-Jan-91: fix some problems with password entry.
3db3f65c6274eb042354801a308c8e9bc4994553amw * removed renicing code.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 29-Oct-90: added cast to XFree() arg.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added volume arg to call to XBell().
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * 28-Oct-90: center prompt screen.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * make sure Xlib input buffer does not use up all of swap.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * make displayed text come from resource file for better I18N.
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * add backward compatible signal handlers for pre 4.1 machines.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 31-Aug-90: added blank mode.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added swarm mode.
3db3f65c6274eb042354801a308c8e9bc4994553amw * moved usleep() and seconds() out to usleep.c.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added SVR4 defines to xlock.h
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 29-Jul-90: added support for multiple screens to be locked by one xlock.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * moved global defines to xlock.h
3db3f65c6274eb042354801a308c8e9bc4994553amw * removed use of allowsig().
3db3f65c6274eb042354801a308c8e9bc4994553amw * 07-Jul-90: reworked commandline args and resources to use Xrm.
3db3f65c6274eb042354801a308c8e9bc4994553amw * moved resource processing out to resource.c
3db3f65c6274eb042354801a308c8e9bc4994553amw * 02-Jul-90: reworked colors to not use dynamic colormap.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 23-May-90: added autoraise when obscured.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 15-Apr-90: added hostent alias searching for host authentication.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 18-Feb-90: added SunOS3.5 fix.
3db3f65c6274eb042354801a308c8e9bc4994553amw * changed -mono -> -color, and -saver -> -lock.
3db3f65c6274eb042354801a308c8e9bc4994553amw * allow non-locking screensavers to display on remote machine.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added -echokeys to disable echoing of '?'s on input.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * cleaned up all of the parameters and defaults.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 20-Dec-89: added -xhost to allow access control list to be left alone.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added -screensaver (don't disable screen saver) for the paranoid.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Moved seconds() here from all of the display mode source files.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Fixed bug with calling XUngrabHosts() in finish().
3db3f65c6274eb042354801a308c8e9bc4994553amw * 19-Dec-89: Fixed bug in GrabPointer.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Changed fontname to XLFD style.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 23-Sep-89: Added fix to allow local hostname:0 as a display.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Put empty case for Enter/Leave events.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Moved colormap installation later in startup.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * 20-Sep-89: Linted and made -saver mode grab the keyboard and mouse.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Replaced SunView code for life mode with Jim Graham's version,
3db3f65c6274eb042354801a308c8e9bc4994553amw * so I could contrib it without legal problems.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sent to expo for X11R4 contrib.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 19-Sep-89: Added '?'s on input.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 27-Mar-89: Added -qix mode.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Fixed GContext->GC.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 20-Mar-89: Added backup font (fixed) if XQueryLoadFont() fails.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Changed default font to lucida-sans-24.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 08-Mar-89: Added -nice, -mode and -display, built vector for life and hop.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 24-Feb-89: Replaced hopalong display with life display from SunView1.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 22-Feb-89: Added fix for color servers with n < 8 planes.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 16-Feb-89: Updated calling conventions for XCreateHsbColormap();
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added -count for number of iterations per color.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Fixed defaulting mechanism.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Ripped out VMS hacks.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sent to expo for X11R3 contrib.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 15-Feb-89: Changed default font to pellucida-sans-18.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 20-Jan-89: Added -verbose and fixed usage message.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 19-Jan-89: Fixed monochrome gc bug.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 16-Dec-88: Added SunView style password prompting.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 19-Sep-88: Changed -color to -mono. (default is color on color displays).
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added -saver option. (just do display... don't lock.)
3db3f65c6274eb042354801a308c8e9bc4994553amw * 31-Aug-88: Added -time option.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Removed code for fractals to separate file for modularity.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added signal handler to restore host access.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Installs dynamic colormap with a Hue Ramp.
3db3f65c6274eb042354801a308c8e9bc4994553amw * If grabs fail then exit.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added VMS Hacks. (password 'iwiwuu').
3db3f65c6274eb042354801a308c8e9bc4994553amw * Sent to expo for X11R2 contrib.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 08-Jun-88: Fixed root password pointer problem and changed PASSLENGTH to 20.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 20-May-88: Added -root to allow root to unlock.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 12-Apr-88: Added root password override.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added screen saver override.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Added access control handling instead.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 01-Apr-88: Added XGrabServer/XUngrabServer for more security.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 30-Mar-88: Removed startup password requirement.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Removed cursor to avoid phosphor burn.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 27-Mar-88: Rotate fractal by 45 degrees clockwise.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 24-Mar-88: Added color support. [-color]
3db3f65c6274eb042354801a308c8e9bc4994553amw * wrote the man page.
3db3f65c6274eb042354801a308c8e9bc4994553amw * 23-Mar-88: Added HOPALONG routines from Scientific American Sept. 86 p. 14.
3db3f65c6274eb042354801a308c8e9bc4994553amw * added password requirement for invokation
3db3f65c6274eb042354801a308c8e9bc4994553amw * removed option for command line password
3db3f65c6274eb042354801a308c8e9bc4994553amw * added requirement for display to be "unix:0".
3db3f65c6274eb042354801a308c8e9bc4994553amw * 22-Mar-88: Recieved Walter Milliken's comp.windows.x posting.
3db3f65c6274eb042354801a308c8e9bc4994553amw fprintf(stderr, "%s: %s failure: %s\n", ProgramName, pamfunc, \
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic Window win[MAXSCREENS]; /* window used to cover screen */
12b65585e720714b31036daaa2b30eb76014048eGordon Rossstatic Window icon[MAXSCREENS]; /* window used during password typein */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic Window root[MAXSCREENS]; /* convenience pointer to the root window */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic GC textgc[MAXSCREENS]; /* graphics context used for text rendering */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic XColor fgcol[MAXSCREENS];/* used for text rendering */
12b65585e720714b31036daaa2b30eb76014048eGordon Rossstatic XColor bgcol[MAXSCREENS];/* background of text screen */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwXColor ssblack[MAXSCREENS];/* black color for screen saver screen */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwXColor sswhite[MAXSCREENS];/* white color for screen saver screen */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int iconx[MAXSCREENS]; /* location of left edge of icon */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int icony[MAXSCREENS]; /* location of top edge of icon */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rossstatic Cursor passwdcursor; /* cursor used in getPassword */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rossstatic Pixmap lockm; /* pixmaps for cursor and mask */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rossstatic char no_bits[] = {0}; /* dummy array for the blank cursor */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int passy;
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic Bool reallyechokeys = False; /* Echo real keys instead of ?'s */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross#define CWMASK CWOverrideRedirect | CWBackPixel | CWEventMask | CWColormap
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* VARARGS1 */
3db3f65c6274eb042354801a308c8e9bc4994553amw * Server access control support.
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic XHostAddress *XHosts; /* the list of "friendly" client machines */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int HostAccessCount; /* the number of machines in XHosts */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic Bool HostAccessState; /* whether or not we even look at the list */
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw XHosts = XListHosts(dsp, &HostAccessCount, &HostAccessState);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
f96bd5c800e73e351b0b6e4bd7f00b578dad29bbAlan Wright * Simple wrapper to get an asynchronous grab on the keyboard and mouse.
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego * If either grab fails, we sleep for one second and try again since some
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego * window manager might have had the mouse grabbed to drive the menu choice
3db3f65c6274eb042354801a308c8e9bc4994553amw * that picked "Lock Screen..". If either one fails the second time we print
3db3f65c6274eb042354801a308c8e9bc4994553amw * an error message and exit.
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego error("%s: couldn't grab keyboard! (%d)\n", status);
3db3f65c6274eb042354801a308c8e9bc4994553amw status = XGrabPointer(dsp, win[0], True, AllPointerEventMask,
3db3f65c6274eb042354801a308c8e9bc4994553amw status = XGrabPointer(dsp, win[0], True, AllPointerEventMask,
3db3f65c6274eb042354801a308c8e9bc4994553amw * Assuming that we already have an asynch grab on the pointer,
3db3f65c6274eb042354801a308c8e9bc4994553amw * just grab it again with a new cursor shape and ignore the return code.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) XGrabPointer(dsp, win[0], True, AllPointerEventMask,
3db3f65c6274eb042354801a308c8e9bc4994553amw GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown * Restore all grabs, reset screensaver, restore colormap, close connection.
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw XSetScreenSaver(dsp, sstimeout, ssinterval, ssblanking, ssexposures);
3db3f65c6274eb042354801a308c8e9bc4994553amw len = XLookupString((XKeyEvent *) & event, keystr, 20, NULL, NULL);
3db3f65c6274eb042354801a308c8e9bc4994553amw for (i = 0; i < len; i++) {
3db3f65c6274eb042354801a308c8e9bc4994553amw switch (c) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * eat all events if there are more than enough pending... this
3db3f65c6274eb042354801a308c8e9bc4994553amw * keeps the Xlib event buffer from growing larger than all
3db3f65c6274eb042354801a308c8e9bc4994553amw * available memory and crashing xlock.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (XPending(dsp) > 100) { /* 100 is arbitrarily big enough */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw XSetForeground(dsp, Scr[screen].gc, bgcol[screen].pixel);
3db3f65c6274eb042354801a308c8e9bc4994553amw * eat all events if there are more than enough pending... this
3db3f65c6274eb042354801a308c8e9bc4994553amw * keeps the Xlib event buffer from growing larger than all
3db3f65c6274eb042354801a308c8e9bc4994553amw * available memory and crashing xlock.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (XPending(dsp) > 100) { /* 100 is arbitrarily big enough */
3db3f65c6274eb042354801a308c8e9bc4994553amw if (((XButtonEvent *) & event)->window == icon[screen]) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (event.xvisibility.state != VisibilityUnobscured) {
3db3f65c6274eb042354801a308c8e9bc4994553amw s[0] = '\0';
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* SYSV */
3db3f65c6274eb042354801a308c8e9bc4994553amw if (upw == NULL) { /* should not pass NULL to getspnam */
3db3f65c6274eb042354801a308c8e9bc4994553amw return(1);
3db3f65c6274eb042354801a308c8e9bc4994553amw return(0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return(1);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#else /* SYSV */
3db3f65c6274eb042354801a308c8e9bc4994553amw return(1);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return(0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return(1);
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* SYSV */
3db3f65c6274eb042354801a308c8e9bc4994553amw return(0);
3db3f65c6274eb042354801a308c8e9bc4994553amw y = icony[screen] + font->ascent + font->ascent + font->descent + 2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw XSetForeground(dsp, Scr[screen].gc, bgcol[screen].pixel);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw passx = left + 1 + XTextWidth(font, prompt, strlen(prompt))
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross XSetForeground(dsp, Scr[screen].gc, bgcol[screen].pixel);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic int pamconv(int num_msg, struct pam_message **msg,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *response = calloc(num_msg, sizeof (struct pam_response));
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross for (i = 0; i < num_msg; i++ , m++ , r++) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross fprintf(stderr, "pam_msg: %d: '%s'\n", m->msg_style, m->msg);
3db3f65c6274eb042354801a308c8e9bc4994553amw switch (m->msg_style) {
3db3f65c6274eb042354801a308c8e9bc4994553amw /* FALLTHRU */
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego /* timeout or other error */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* free responses */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (i = 0; i < num_msg; i++, r++) {
3db3f65c6274eb042354801a308c8e9bc4994553amw * audit_lock - audit entry to screenlock
3db3f65c6274eb042354801a308c8e9bc4994553amw * Entry Process running with appropriate privilege to generate
3db3f65c6274eb042354801a308c8e9bc4994553amw * audit records and real uid of the user.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Exit ADT_screenlock audit record written.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw /* Audit start of screen lock -- equivalent to logout ;-) */
3db3f65c6274eb042354801a308c8e9bc4994553amw if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((event = adt_alloc_event(ah, ADT_screenlock)) == NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_alloc_event(ADT_screenlock): %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_put_event(ADT_screenlock): %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw * audit_unlock - audit screen unlock
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Entry Process running with appropriate privilege to generate
3db3f65c6274eb042354801a308c8e9bc4994553amw * audit records and real uid of the user.
3db3f65c6274eb042354801a308c8e9bc4994553amw * pam_status = PAM error code; reason for failure.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Exit ADT_screenunlock audit record written.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_start_session(ADT_screenunlock): %m");
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((event = adt_alloc_event(ah, ADT_screenunlock)) == NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_alloc_event(ADT_screenunlock): %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAIL_PAM +
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_put_event(ADT_screenunlock(%s): %m",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * audit_passwd - audit password change
3db3f65c6274eb042354801a308c8e9bc4994553amw * Entry Process running with appropriate privilege to generate
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * audit records and real uid of the user.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pam_status = PAM error code; reason for failure.
3db3f65c6274eb042354801a308c8e9bc4994553amw * Exit ADT_passwd audit record written.
3db3f65c6274eb042354801a308c8e9bc4994553amw if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_start_session(ADT_passwd): %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw if ((event = adt_alloc_event(ah, ADT_passwd)) == NULL) {
3db3f65c6274eb042354801a308c8e9bc4994553amw "adt_alloc_event(ADT_passwd): %m");
3db3f65c6274eb042354801a308c8e9bc4994553amw pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAIL_PAM +
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross "adt_put_event(ADT_passwd(%s): %m",
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross#endif /* SYSV */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross#endif /* SYSV */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross pam_error = pam_start(XLOCK_PAM_SERVICE, user, &pc, &pamh);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* Check /etc/default/login to see if we should add
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross PAM_DISALLOW_NULL_AUTHTOK to pam_flags */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross (void) defopen((char *)NULL); /* close current file */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross /* Disable user password non-PAM authentication */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross#endif /* USE_PAM */
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross XSetForeground(dsp, Scr[screen].gc, bgcol[screen].pixel);
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross XFillRectangle(dsp, win[screen], Scr[screen].gc,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross left = iconx[screen] + ICONW + font->max_bounds.width;
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross left + XTextWidth(font, text_name, strlen(text_name)), y,
7f3ef643e446c82e27a9386991b140b128baf22cGordon Ross iconx[screen], y, text_info, strlen(text_info));
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
3db3f65c6274eb042354801a308c8e9bc4994553amw * This section gets a little messy. In SYSV, the number of
3db3f65c6274eb042354801a308c8e9bc4994553amw * cases to handle increases because of the existence of the
3db3f65c6274eb042354801a308c8e9bc4994553amw * shadow file. There are also a number of cases that need
3db3f65c6274eb042354801a308c8e9bc4994553amw * to be dealt with where either root or user passwords are
3db3f65c6274eb042354801a308c8e9bc4994553amw * nil. Hopefully the code below is easy enough to follow.
3db3f65c6274eb042354801a308c8e9bc4994553amw && (!allowroot || strcmp(crypt(buffer, rootpass), rootpass)));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* just hit return, and it wasn't his password */
3db3f65c6274eb042354801a308c8e9bc4994553amw * the user has no password, but something was typed anyway.
3db3f65c6274eb042354801a308c8e9bc4994553amw * sounds fishy: don't let him in...
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* SYSV */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* clear plaintext password so you can't grunge around /dev/kmem */
3db3f65c6274eb042354801a308c8e9bc4994553amw /* clear encrypted passwords just in case */
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* clear encrypted passwords just in case */
3db3f65c6274eb042354801a308c8e9bc4994553amw } while (event.type != ButtonPress && event.type != KeyPress);
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown error("%s: caught terminate signal.\nAccess control list restored.\n",(char*)NULL);
3db3f65c6274eb042354801a308c8e9bc4994553amwstatic void
3db3f65c6274eb042354801a308c8e9bc4994553amw#endif /* sun */
3db3f65c6274eb042354801a308c8e9bc4994553amw } while (getPassword());
3db3f65c6274eb042354801a308c8e9bc4994553amw srandom(time((long *) 0)); /* random mode needs the seed set. */
3db3f65c6274eb042354801a308c8e9bc4994553amw fprintf(stderr, "%s: can't find font: %s, using %s...\n",
3db3f65c6274eb042354801a308c8e9bc4994553amw error("%s: can't even find %s!!!\n", FALLBACK_FONTNAME);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fprintf(stderr, "%s: can't get the user password. Exiting ...\n",
3db3f65c6274eb042354801a308c8e9bc4994553amw fprintf(stderr,"\tYou need to run xlock in setuid root mode on your local machine.\n");
3db3f65c6274eb042354801a308c8e9bc4994553amw error("\tContact your system administrator.\n", (char *) NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw error("%s: can only support %d screens.\n", MAXSCREENS);
3db3f65c6274eb042354801a308c8e9bc4994553amw cmap = XCreateColormap(dsp, root[screen], vis, AllocNone);
3db3f65c6274eb042354801a308c8e9bc4994553amw XAllocNamedColor(dsp, cmap, "White", &sswhite[screen], &tmp);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw XAllocNamedColor(dsp, cmap, "Black", &ssblack[screen], &tmp);
3db3f65c6274eb042354801a308c8e9bc4994553amw XAllocNamedColor(dsp, cmap, "White", &bgcol[screen], &tmp);
3db3f65c6274eb042354801a308c8e9bc4994553amw XAllocNamedColor(dsp, cmap, "Black", &fgcol[screen], &tmp);
3db3f65c6274eb042354801a308c8e9bc4994553amw XAllocNamedColor(dsp, cmap, "White", &bgcol[screen], &tmp);
3db3f65c6274eb042354801a308c8e9bc4994553amw XAllocNamedColor(dsp, cmap, "Black", &fgcol[screen], &tmp);
3db3f65c6274eb042354801a308c8e9bc4994553amw hsbramp(0.0, saturation, 1.0, 1.0, saturation, 1.0, colorcount,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for (i = 0; i < colorcount; i++) {
3db3f65c6274eb042354801a308c8e9bc4994553amw fprintf(stderr, "%d pixels allocated\n", Scr[screen].npixels);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw xswa.event_mask = KeyPressMask | ButtonPressMask | VisibilityChangeMask;
3db3f65c6274eb042354801a308c8e9bc4994553amw xswa.colormap = cmap; /* In DEBUG mode, we do not see this */
3db3f65c6274eb042354801a308c8e9bc4994553amw win[screen] = XCreateWindow(dsp, root[screen], 0, 0, WIDTH, HEIGHT, 0,
3db3f65c6274eb042354801a308c8e9bc4994553amw xswa.colormap = cmap; /* In DEBUG mode, we do not see this */
3db3f65c6274eb042354801a308c8e9bc4994553amw#define CIMASK CWBorderPixel | CWBackPixel | CWEventMask | CWColormap
3db3f65c6274eb042354801a308c8e9bc4994553amw lockc = XCreateBitmapFromData(dsp, root[0], no_bits, 1, 1);
3db3f65c6274eb042354801a308c8e9bc4994553amw lockm = XCreateBitmapFromData(dsp, root[0], no_bits, 1, 1);
3db3f65c6274eb042354801a308c8e9bc4994553amw XSetScreenSaver(dsp, 0, 0, 0, 0); /* disable screen saver */