diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-03-28 09:33:03 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-03-28 09:33:03 +0000 |
commit | 1c787d6c2fd1afe065cff9e207f3eb5e1d761115 (patch) | |
tree | efd71293dad316006e987466d6b8f89df1d3012a /app/xdm/greeter | |
parent | 13e78ac89384dac8f940479f3a13bfbb6b01b6f8 (diff) |
Update to xdm 1.1.9
Diffstat (limited to 'app/xdm/greeter')
-rw-r--r-- | app/xdm/greeter/Login.c | 300 | ||||
-rw-r--r-- | app/xdm/greeter/Login.h | 144 | ||||
-rw-r--r-- | app/xdm/greeter/LoginP.h | 105 | ||||
-rw-r--r-- | app/xdm/greeter/Makefile.am | 13 | ||||
-rw-r--r-- | app/xdm/greeter/Makefile.in | 37 | ||||
-rw-r--r-- | app/xdm/greeter/greet.c | 359 | ||||
-rw-r--r-- | app/xdm/greeter/verify.c | 110 |
7 files changed, 733 insertions, 335 deletions
diff --git a/app/xdm/greeter/Login.c b/app/xdm/greeter/Login.c index 9b7562c7b..65ab1852f 100644 --- a/app/xdm/greeter/Login.c +++ b/app/xdm/greeter/Login.c @@ -1,5 +1,3 @@ -/* $XdotOrg: app/xdm/greeter/Login.c,v 1.6 2006/06/03 00:05:24 alanc Exp $ */ -/* $Xorg: Login.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */ /* Copyright 1988, 1998 The Open Group @@ -55,7 +53,6 @@ from The Open Group. * of the copyright holder. */ -/* $XFree86: xc/programs/xdm/greeter/Login.c,v 3.17tsi Exp $ */ /* * xdm - display manager daemon @@ -64,33 +61,34 @@ from The Open Group. * Login.c */ -# include <X11/IntrinsicP.h> -# include <X11/StringDefs.h> -# include <X11/keysym.h> -# include <X11/DECkeysym.h> -# include <X11/Xfuncs.h> +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/keysym.h> +#include <X11/DECkeysym.h> +#include <X11/Xfuncs.h> -# include <stdio.h> -# include <ctype.h> -# include <time.h> +#include <stdio.h> +#include <ctype.h> +#include <time.h> +#include <string.h> -# include "dm.h" -# include "dm_error.h" -# include "greet.h" -# include "LoginP.h" +#include "dm.h" +#include "dm_error.h" +#include "greet.h" +#include "LoginP.h" #ifdef XPM -#include <sys/stat.h> -#include <unistd.h> -#include <X11/Xlib.h> -#include <X11/xpm.h> -#include <X11/extensions/shape.h> +# include <sys/stat.h> +# include <unistd.h> +# include <X11/Xlib.h> +# include <X11/xpm.h> +# include <X11/extensions/shape.h> #endif /* XPM */ #include <X11/cursorfont.h> #ifdef USE_XINERAMA -#include <X11/extensions/Xinerama.h> +# include <X11/extensions/Xinerama.h> #endif #ifndef DEBUG @@ -125,7 +123,7 @@ static XtResource resources[] = { goffset(x), XtRImmediate, (XtPointer) -1}, {XtNy, XtCY, XtRPosition, sizeof (Position), goffset(y), XtRImmediate, (XtPointer) -1}, -#ifndef USE_XFT +#ifndef USE_XFT {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(textpixel), XtRString, XtDefaultForeground}, {XtNpromptColor, XtCForeground, XtRPixel, sizeof(Pixel), @@ -143,7 +141,7 @@ static XtResource resources[] = { /* end (caolan) */ #endif /* DANCING */ -#ifdef XPM +#ifdef XPM /* added by Ivan Griffin (ivan.griffin@ul.ie) */ {XtNlogoFileName, XtCLogoFileName, XtRString, sizeof(char*), offset(logoFileName), XtRImmediate, (XtPointer)0}, @@ -167,7 +165,7 @@ static XtResource resources[] = { offset(sepwidth), XtRImmediate, (XtPointer) 1}, /* end (amit) */ -#ifndef USE_XFT +#ifndef USE_XFT {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), offset (textFont), XtRString, "*-new century schoolbook-medium-r-normal-*-180-*"}, {XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), @@ -242,33 +240,33 @@ static XtResource resources[] = { # define F_DESCENT(f) ((w)->login.f##Font->max_bounds.descent) #endif -# define TEXT_X_INC(w) F_MAX_WIDTH(text) -# define TEXT_Y_INC(w) (F_ASCENT(text) + F_DESCENT(text)) +#define TEXT_X_INC(w) F_MAX_WIDTH(text) +#define TEXT_Y_INC(w) (F_ASCENT(text) + F_DESCENT(text)) -# define PROMPT_X_INC(w) F_MAX_WIDTH(prompt) -# define PROMPT_Y_INC(w) (F_ASCENT(prompt) + F_DESCENT(prompt)) +#define PROMPT_X_INC(w) F_MAX_WIDTH(prompt) +#define PROMPT_Y_INC(w) (F_ASCENT(prompt) + F_DESCENT(prompt)) -# define GREET_X_INC(w) F_MAX_WIDTH(greet) -# define GREET_Y_INC(w) (F_ASCENT(greet) + F_DESCENT(greet)) +#define GREET_X_INC(w) F_MAX_WIDTH(greet) +#define GREET_Y_INC(w) (F_ASCENT(greet) + F_DESCENT(greet)) -# define FAIL_X_INC(w) F_MAX_WIDTH(fail) -# define FAIL_Y_INC(w) (F_ASCENT(fail) + F_DESCENT(fail)) +#define FAIL_X_INC(w) F_MAX_WIDTH(fail) +#define FAIL_Y_INC(w) (F_ASCENT(fail) + F_DESCENT(fail)) -# define Y_INC(w) max (TEXT_Y_INC(w), PROMPT_Y_INC(w)) +#define Y_INC(w) max (TEXT_Y_INC(w), PROMPT_Y_INC(w)) -# define PROMPT_TEXT(w,n) ((w)->login.prompts[n].promptText) -# define DEF_PROMPT_TEXT(w,n) ((w)->login.prompts[n].defaultPrompt) -# define VALUE_TEXT(w,n) ((w)->login.prompts[n].valueText) -# define VALUE_TEXT_MAX(w,n) ((w)->login.prompts[n].valueTextMax) -# define VALUE_SHOW_START(w,n) ((w)->login.prompts[n].valueShownStart) -# define VALUE_SHOW_END(w,n) ((w)->login.prompts[n].valueShownEnd) -# define PROMPT_STATE(w,n) ((w)->login.prompts[n].state) -# define PROMPT_CURSOR(w,n) ((w)->login.prompts[n].cursor) +#define PROMPT_TEXT(w,n) ((w)->login.prompts[n].promptText) +#define DEF_PROMPT_TEXT(w,n) ((w)->login.prompts[n].defaultPrompt) +#define VALUE_TEXT(w,n) ((w)->login.prompts[n].valueText) +#define VALUE_TEXT_MAX(w,n) ((w)->login.prompts[n].valueTextMax) +#define VALUE_SHOW_START(w,n) ((w)->login.prompts[n].valueShownStart) +#define VALUE_SHOW_END(w,n) ((w)->login.prompts[n].valueShownEnd) +#define PROMPT_STATE(w,n) ((w)->login.prompts[n].state) +#define PROMPT_CURSOR(w,n) ((w)->login.prompts[n].cursor) -# define CUR_PROMPT_CURSOR(w) PROMPT_CURSOR(w,w->login.activePrompt) +#define CUR_PROMPT_CURSOR(w) PROMPT_CURSOR(w,w->login.activePrompt) -# define CUR_PROMPT_TEXT(w, n) (PROMPT_TEXT(w,n) != NULL ? \ +#define CUR_PROMPT_TEXT(w, n) (PROMPT_TEXT(w,n) != NULL ? \ PROMPT_TEXT(w,n) : DEF_PROMPT_TEXT(w,n)) #ifdef USE_XFT @@ -297,23 +295,23 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len); #endif -# define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s)) +#define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s)) -# define TEXT_PROMPT_W(w, m) (STRING_WIDTH(prompt, m) + w->login.inframeswidth) +#define TEXT_PROMPT_W(w, m) (STRING_WIDTH(prompt, m) + w->login.inframeswidth) -# define DEF_PROMPT_W(w,n) TEXT_PROMPT_W(w, w->login.prompts[n].defaultPrompt) -# define CUR_PROMPT_W(w,n) (max(MAX_DEF_PROMPT_W(w), PROMPT_TEXT(w,n) ? \ +#define DEF_PROMPT_W(w,n) TEXT_PROMPT_W(w, w->login.prompts[n].defaultPrompt) +#define CUR_PROMPT_W(w,n) (max(MAX_DEF_PROMPT_W(w), PROMPT_TEXT(w,n) ? \ TEXT_PROMPT_W(w, PROMPT_TEXT(w,n)) : 0)) -# define MAX_DEF_PROMPT_W(w) (max(DEF_PROMPT_W(w,0), DEF_PROMPT_W(w,1))) +#define MAX_DEF_PROMPT_W(w) (max(DEF_PROMPT_W(w,0), DEF_PROMPT_W(w,1))) -# define GREETING(w) ((w)->login.secure_session && !(w)->login.allow_access ?\ +#define GREETING(w) ((w)->login.secure_session && !(w)->login.allow_access ?\ (w)->login.greeting : (w)->login.unsecure_greet) -# define GREET_X(w) ((int)((w->core.width - \ +#define GREET_X(w) ((int)((w->core.width - \ STRING_WIDTH (greet, GREETING(w))) / 2)) -# define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0) +#define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0) #ifndef XPM # define GREET_W(w) (max (STRING_WIDTH (greet, w->login.greeting), \ STRING_WIDTH (greet, w->login.unsecure_greet))) @@ -322,29 +320,29 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len); STRING_WIDTH (greet, w->login.unsecure_greet)) \ + w->login.logoWidth + (2*w->login.logoPadding)) #endif /* XPM */ -# define PROMPT_X(w) (2 * PROMPT_X_INC(w)) -# define PROMPT_Y(w,n) ((GREET_Y(w) + GREET_Y_INC(w) +\ +#define PROMPT_X(w) (2 * PROMPT_X_INC(w)) +#define PROMPT_Y(w,n) ((GREET_Y(w) + GREET_Y_INC(w) +\ F_ASCENT(greet) + Y_INC(w)) + \ (n * PROMPT_SPACE_Y(w))) -# define PROMPT_W(w) (w->core.width - (2 * TEXT_X_INC(w))) -# define PROMPT_H(w) (3 * Y_INC(w) / 2) -# define VALUE_X(w,n) (PROMPT_X(w) + CUR_PROMPT_W(w,n)) -# define PROMPT_SPACE_Y(w) (10 * Y_INC(w) / 5) +#define PROMPT_W(w) (w->core.width - (2 * TEXT_X_INC(w))) +#define PROMPT_H(w) (3 * Y_INC(w) / 2) +#define VALUE_X(w,n) (PROMPT_X(w) + CUR_PROMPT_W(w,n)) +#define PROMPT_SPACE_Y(w) (10 * Y_INC(w) / 5) -# define ERROR_X(w,m) ((int)(w->core.width - STRING_WIDTH (fail, m)) / 2) -# define FAIL_X(w) ERROR_X(w, w->login.fail) -# define FAIL_Y(w) (PROMPT_Y(w,1) + 2 * FAIL_Y_INC (w) + F_ASCENT(fail)) +#define ERROR_X(w,m) ((int)(w->core.width - STRING_WIDTH (fail, m)) / 2) +#define FAIL_X(w) ERROR_X(w, w->login.fail) +#define FAIL_Y(w) (PROMPT_Y(w,1) + 2 * FAIL_Y_INC (w) + F_ASCENT(fail)) # define ERROR_W(w,m) STRING_WIDTH (fail, m) -# define FAIL_W(w) max(ERROR_W(w, w->login.failMsg), \ +#define FAIL_W(w) max(ERROR_W(w, w->login.failMsg), \ ERROR_W(w, w->login.passwdChangeMsg)) -# define PAD_X(w) (2 * (PROMPT_X(w) + max (GREET_X_INC(w), FAIL_X_INC(w)))) +#define PAD_X(w) (2 * (PROMPT_X(w) + max (GREET_X_INC(w), FAIL_X_INC(w)))) -# define PAD_Y(w) (max (max (Y_INC(w), GREET_Y_INC(w)),\ +#define PAD_Y(w) (max (max (Y_INC(w), GREET_Y_INC(w)),\ FAIL_Y_INC(w))) - + #ifndef max static inline int max (int a, int b) { return a > b ? a : b; } #endif @@ -385,7 +383,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc) int textwidth; int offset = max(cursor, VALUE_SHOW_START(w, promptNum)); int textlen = strlen (text + offset); - + textwidth = TEXT_WIDTH (text, text + offset, textlen); if (textwidth > (width - curoff)) { @@ -400,7 +398,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc) } textlen--; textwidth = TEXT_WIDTH (text, text + offset, textlen); - } + } VALUE_SHOW_START(w, promptNum) = offset; VALUE_SHOW_END(w, promptNum) = offset + textlen; @@ -439,17 +437,10 @@ realizeCursor (LoginWidget w, GC gc) int x, y; int height, width; -#ifdef FORCE_CURSOR_FLASH - static int lastx, lasty; - static struct timeval lastFlash; - struct timeval now, timeout; - int sinceLastFlash; -#endif - if (w->login.state != PROMPTING) { return; } - + x = VALUE_X (w, w->login.activePrompt); y = PROMPT_Y (w, w->login.activePrompt); height = (F_ASCENT(text) + F_DESCENT(text)); @@ -469,10 +460,12 @@ realizeCursor (LoginWidget w, GC gc) } break; case LOGIN_PROMPT_ECHO_OFF: - /* Nothing special needed */ + /* Move cursor one pixel per character to give some feedback without + giving away the password length */ + x += PROMPT_CURSOR(w, w->login.activePrompt); break; } - + XFillRectangle (XtDisplay (w), XtWindow (w), gc, x, y+1 - F_ASCENT(text), width, height-1); XDrawPoint (XtDisplay (w), XtWindow (w), gc, @@ -492,50 +485,23 @@ realizeCursor (LoginWidget w, GC gc) XDrawPoint (XtDisplay (w), XtWindow (w), gc, x+2 , y - F_ASCENT(text)+height); -#ifdef FORCE_CURSOR_FLASH - /* Force cursor to flash briefly to give user feedback */ -#define FLASH_MILLIS 100000 /* 0.10 seconds */ -#define MILLIS_PER_SEC 1000000 - X_GETTIMEOFDAY (&now); - - if ((lastx == x) && (lasty == y)) { - if (lastFlash.tv_sec == 0) - sinceLastFlash = 0; - else if ((lastFlash.tv_sec + 1) == now.tv_sec) - sinceLastFlash = - (now.tv_usec + MILLIS_PER_SEC) - lastFlash.tv_usec; - else if (lastFlash.tv_sec == now.tv_sec) - sinceLastFlash = now.tv_usec - lastFlash.tv_usec; - else - sinceLastFlash = (now.tv_sec - lastFlash.tv_sec) * MILLIS_PER_SEC; - - if (sinceLastFlash < FLASH_MILLIS) { - timeout.tv_sec = 0; - timeout.tv_usec = FLASH_MILLIS - sinceLastFlash; - select(0, NULL, NULL, NULL, &timeout); - } - } else { - lastx = x; lasty = y; - } - X_GETTIMEOFDAY (&lastFlash); -#endif /* FORCE_CURSOR_FLASH */ - XFlush (XtDisplay(w)); + XFlush (XtDisplay(w)); } static void EraseFail (LoginWidget w) { -#ifdef USE_XFT +#ifdef USE_XFT w->login.failUp = 0; RedrawFail(w); -#else +#else XSetForeground (XtDisplay (w), w->login.failGC, w->core.background_pixel); RedrawFail(w); w->login.failUp = 0; XSetForeground (XtDisplay (w), w->login.failGC, TEXT_COLOR(fail)); -#endif +#endif } static void @@ -587,9 +553,9 @@ RedrawFail (LoginWidget w) int y = FAIL_Y(w); int maxw = w->core.width - PAD_X(w); -#ifndef USE_XFT +#ifndef USE_XFT if (w->login.failUp) -#endif +#endif { Debug("RedrawFail('%s', %d)\n", w->login.fail, w->login.failUp); if (ERROR_W(w, w->login.fail) > maxw) { @@ -597,10 +563,10 @@ RedrawFail (LoginWidget w) char *tempCopy = strdup(w->login.fail); if (tempCopy != NULL) { char *start, *next; - char lastspace; + char lastspace = ' '; y = PROMPT_Y(w,LAST_PROMPT) + (2 * PROMPT_Y_INC(w)); - + for (start = next = tempCopy; start != NULL ; start = next) { /* search for longest string broken by whitespace that will fit on a single line */ @@ -620,14 +586,14 @@ RedrawFail (LoginWidget w) next = NULL; } } while ((next != NULL) && ERROR_W(w, start) < maxw); - + x = ERROR_X(w, start); #ifdef USE_XFT if (w->login.failUp == 0) { XClearArea(XtDisplay(w), XtWindow(w), x, y, ERROR_W(w, start), FAIL_Y_INC(w), False); } else -#endif +#endif DRAW_STRING (fail, x, y, start, strlen(start)); if (next != NULL) { @@ -648,7 +614,7 @@ RedrawFail (LoginWidget w) XClearArea(XtDisplay(w), XtWindow(w), x, y, ERROR_W(w, w->login.fail), FAIL_Y_INC(w), False); } else -#endif +#endif DRAW_STRING (fail, x, y, w->login.fail, strlen (w->login.fail)); } } @@ -712,7 +678,7 @@ draw_it (LoginWidget w) XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC, i-1,w->core.height-i,w->core.width-i,w->core.height-i); } - + /* make separator line */ gr_line_x = w->login.outframewidth; gr_line_y = GREET_Y(w) + GREET_Y_INC(w); @@ -738,16 +704,16 @@ draw_it (LoginWidget w) int in_frame_x = VALUE_X(w,p) - w->login.inframeswidth - 3; int in_frame_y = PROMPT_Y(w,p) - w->login.inframeswidth - 1 - TEXT_Y_INC(w); - + int in_width = PROMPT_W(w) - VALUE_X(w,p); int in_height = PROMPT_H(w) + w->login.inframeswidth + 2; - + GC topLeftGC, botRightGC; -#ifdef XPM +#ifdef XPM in_width -= (w->login.logoWidth + 2*(w->login.logoPadding)); #endif /* XPM */ - + if ((PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_ON) || (PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_OFF)) { topLeftGC = w->login.shdGC; @@ -761,16 +727,16 @@ draw_it (LoginWidget w) /* Make top/left sides */ XDrawLine(XtDisplay (w), XtWindow (w), topLeftGC, in_frame_x + i-1, in_frame_y + i-1, - in_frame_x + in_width-i, in_frame_y + i-1); + in_frame_x + in_width-i, in_frame_y + i-1); XDrawLine(XtDisplay (w), XtWindow (w), topLeftGC, in_frame_x + i-1, in_frame_y + i-1, - in_frame_x + i-1, in_frame_y + in_height-i); + in_frame_x + i-1, in_frame_y + in_height-i); /* Make bottom/right sides */ XDrawLine(XtDisplay (w), XtWindow (w), botRightGC, in_frame_x + in_width-i, in_frame_y + i-1, - in_frame_x + in_width-i, in_frame_y + in_height-i); + in_frame_x + in_width-i, in_frame_y + in_height-i); XDrawLine(XtDisplay (w), XtWindow (w), botRightGC, in_frame_x + i-1, in_frame_y + in_height-i, @@ -783,7 +749,7 @@ draw_it (LoginWidget w) #ifdef XPM gx -= ((w->login.logoWidth/2) + w->login.logoPadding); -#endif +#endif DRAW_STRING (greet, gx, GREET_Y(w), GREETING(w), strlen (GREETING(w))); } for (p = 0; p < NUM_PROMPTS ; p++) { @@ -824,12 +790,12 @@ SetPrompt (Widget ctx, int promptNum, const char *message, "LOGIN_PROMPT_NOT_SHOWN", "LOGIN_PROMPT_ECHO_ON", "LOGIN_PROMPT_ECHO_OFF", "LOGIN_TEXT_INFO" }; loginPromptState priorState; - + Debug("SetPrompt(%d, %s, %s(%d))\n", promptNum, message ? message : "<NULL>", stateNames[state], state); XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if (PROMPT_TEXT(w, promptNum) != NULL) { XtFree(PROMPT_TEXT(w, promptNum)); PROMPT_TEXT(w, promptNum) = NULL; @@ -847,18 +813,18 @@ SetPrompt (Widget ctx, int promptNum, const char *message, } messageLen = strlen(message); - + prompt = XtMalloc(messageLen + 3); if (prompt == NULL) { LogOutOfMem ("SetPrompt"); return -1; } - + strncpy(prompt, message, messageLen); - + /* Make sure text prompts have at least two spaces at end */ e = messageLen; - + if (!isspace(message[messageLen - 2])) { prompt[e] = ' '; e++; @@ -874,11 +840,11 @@ SetPrompt (Widget ctx, int promptNum, const char *message, if (w->login.state == INITIALIZING) { return 0; } - + if ((priorState == LOGIN_TEXT_INFO) && (w->login.msgTimeout != 0)) { time_t now = time(NULL); int timeleft = w->login.msgTimeout - now; - + if (timeleft > 0) { sleep(timeleft); } @@ -895,7 +861,7 @@ SetPrompt (Widget ctx, int promptNum, const char *message, w->login.activePrompt = promptNum; w->login.state = PROMPTING; } - + PROMPT_CURSOR(w, promptNum) = 0; XClearArea (XtDisplay(w), XtWindow(w), 0, 0, 0, 0, FALSE); draw_it(w); @@ -909,7 +875,7 @@ GetPrompt(Widget ctx, int promptNum) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + return CUR_PROMPT_TEXT(w,promptNum); } @@ -920,12 +886,12 @@ SetValue(Widget ctx, int promptNum, char *value) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if ((promptNum < 0) || (promptNum > LAST_PROMPT)) return -1; XDM_ASSERT(VALUE_TEXT(w, promptNum) != NULL); - + if (VALUE_TEXT(w, promptNum) == NULL) return -1; @@ -939,7 +905,7 @@ SetValue(Widget ctx, int promptNum, char *value) VALUE_SHOW_START(w, promptNum) = 0; VALUE_SHOW_END(w, promptNum) = 0; PROMPT_CURSOR(w, promptNum) = 0; - + return 0; } @@ -950,7 +916,7 @@ GetValue(Widget ctx, int promptNum) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if ((promptNum < 0) || (promptNum > LAST_PROMPT)) return NULL; @@ -966,7 +932,7 @@ realizeDeleteChar (LoginWidget ctx) if (ctx->login.state == PROMPTING) { int promptNum = ctx->login.activePrompt; int redrawFrom = PROMPT_CURSOR(ctx, promptNum); - + if (PROMPT_CURSOR(ctx,promptNum) < (int)strlen(VALUE_TEXT(ctx,promptNum))) { if (redrawFrom < VALUE_SHOW_START(ctx, ctx->login.activePrompt)) { redrawFrom = 0; @@ -1000,7 +966,7 @@ DeleteBackwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_pa CUR_PROMPT_CURSOR(ctx) -= 1; realizeDeleteChar(ctx); } - XorCursor (ctx); + XorCursor (ctx); } /*ARGSUSED*/ @@ -1017,7 +983,7 @@ DeleteForwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_par XorCursor (ctx); realizeDeleteChar(ctx); - XorCursor (ctx); + XorCursor (ctx); } /*ARGSUSED*/ @@ -1223,7 +1189,7 @@ TabField(Widget ctxw, XEvent *event, String *params, Cardinal *num_params) if (nextPrompt > LAST_PROMPT) { nextPrompt = 0; } - + if ((PROMPT_STATE(ctx, nextPrompt) == LOGIN_PROMPT_ECHO_ON) || (PROMPT_STATE(ctx, nextPrompt) == LOGIN_PROMPT_ECHO_OFF)) { ctx->login.activePrompt = nextPrompt; @@ -1441,7 +1407,7 @@ InsertChar ( break; } - if (ctx->login.state == PROMPTING) { + if (ctx->login.state == PROMPTING) { if ((len + (int)strlen(VALUE_TEXT(ctx, promptNum)) >= (VALUE_TEXT_MAX(ctx,promptNum) - 1))) { len = VALUE_TEXT_MAX(ctx,promptNum) - @@ -1476,7 +1442,7 @@ static XtConvertArgRec xftColorConvertArgs[] = { sizeof(Colormap)} }; -#define donestr(type, value, tstr) \ +# define donestr(type, value, tstr) \ { \ if (toVal->addr != NULL) { \ if (toVal->size < sizeof(type)) { \ @@ -1503,7 +1469,7 @@ XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure, Screen *screen; Colormap colormap; XftColor *color; - + if (*num_args != 2) { XtAppErrorMsg (app, @@ -1522,7 +1488,7 @@ XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure, XScreenNumberOfScreen (screen)), colormap, color); } - + static Boolean XmuCvtStringToXftColor(Display *dpy, XrmValue *args, Cardinal *num_args, @@ -1534,7 +1500,7 @@ XmuCvtStringToXftColor(Display *dpy, XftColor xftColor; Screen *screen; Colormap colormap; - + if (*num_args != 2) { XtAppErrorMsg (XtDisplayToApplicationContext (dpy), @@ -1565,14 +1531,14 @@ XmuCvtStringToXftColor(Display *dpy, } else if (!XRenderParseColor (dpy, spec, &renderColor)) return False; - if (!XftColorAllocValue (dpy, + if (!XftColorAllocValue (dpy, DefaultVisual (dpy, XScreenNumberOfScreen (screen)), colormap, &renderColor, &xftColor)) return False; - + donestr (XftColor, xftColor, XtRXftColor); } @@ -1582,7 +1548,7 @@ XmuFreeXftFont (XtAppContext app, XrmValuePtr toVal, XtPointer closure, { Screen *screen; XftFont *font; - + if (*num_args != 1) { XtAppErrorMsg (app, @@ -1608,7 +1574,7 @@ XmuCvtStringToXftFont(Display *dpy, char *name; XftFont *font; Screen *screen; - + if (*num_args != 1) { XtAppErrorMsg (XtDisplayToApplicationContext (dpy), @@ -1621,7 +1587,7 @@ XmuCvtStringToXftFont(Display *dpy, screen = *((Screen **) args[0].addr); name = (char *) fromVal->addr; - + font = XftFontOpenName (dpy, XScreenNumberOfScreen (screen), name); @@ -1651,12 +1617,12 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len) #endif /* USE_XFT */ -static void +static void ClassInitialize(void) { #ifdef USE_XFT - XtSetTypeConverter (XtRString, XtRXftColor, - XmuCvtStringToXftColor, + XtSetTypeConverter (XtRString, XtRXftColor, + XmuCvtStringToXftColor, xftColorConvertArgs, XtNumber(xftColorConvertArgs), XtCacheByDisplay, XmuFreeXftColor); XtSetTypeConverter (XtRString, XtRXftFont, @@ -1684,7 +1650,7 @@ static void Initialize ( int s_num; #endif int rv = 0; - + myXGCV.foreground = w->login.hipixel; myXGCV.background = w->core.background_pixel; valuemask = GCForeground | GCBackground; @@ -1703,7 +1669,7 @@ static void Initialize ( myXGCV.font = w->login.textFont->fid; valuemask |= GCFont; } -#endif +#endif w->login.textGC = XtGetGC(gnew, valuemask, &myXGCV); myXGCV.foreground = w->core.background_pixel; w->login.bgGC = XtGetGC(gnew, valuemask, &myXGCV); @@ -1780,7 +1746,7 @@ static void Initialize ( &(w->login.logoPixmap), /* pixmap */ &(w->login.logoMask), /* pixmap mask */ &myAttributes); /* XPM attributes */ - + if ( rv < 0 ) { LogError("Cannot load xpm file %s: %s.\n", w->login.logoFileName, @@ -1822,7 +1788,7 @@ SkipXpmLoad: VALUE_TEXT(w, LOGIN_PROMPT_USERNAME) = w->login.data.name; VALUE_TEXT_MAX(w, LOGIN_PROMPT_USERNAME) = sizeof(w->login.data.name); VALUE_SHOW_START(w, LOGIN_PROMPT_USERNAME) = 0; - + PROMPT_TEXT(w, LOGIN_PROMPT_PASSWORD) = NULL; DEF_PROMPT_TEXT(w, LOGIN_PROMPT_PASSWORD) = w->login.passwdPrompt; VALUE_TEXT(w, LOGIN_PROMPT_PASSWORD) = w->login.data.passwd; @@ -1831,7 +1797,7 @@ SkipXpmLoad: SetPrompt(gnew, LOGIN_PROMPT_PASSWORD, NULL, LOGIN_PROMPT_ECHO_OFF, False); SetPrompt(gnew, LOGIN_PROMPT_USERNAME, NULL, LOGIN_PROMPT_ECHO_ON, False); - + if (w->core.width == 0) w->core.width = max (GREET_W(w), FAIL_W(w)) + PAD_X(w); if (w->core.height == 0) { @@ -1845,7 +1811,7 @@ SkipXpmLoad: w->core.height = max(fy + pady, (w->login.logoHeight + (2*w->login.logoPadding)) + pady); - + #endif /* XPM */ } #ifdef USE_XINERAMA @@ -1858,7 +1824,7 @@ SkipXpmLoad: x = screens[0].x_org + (int)(screens[0].width - w->core.width) / 2; if ((y = w->core.y) == -1) y = screens[0].y_org + (int)(screens[0].height - w->core.height) / 3; - + XFree(screens); } else @@ -1876,7 +1842,7 @@ SkipXpmLoad: w->login.state = PROMPTING; } - + static void Realize ( Widget gw, XtValueMask *valueMask, @@ -1900,13 +1866,13 @@ static void Realize ( XDefineCursor(XtDisplay(gw), DefaultRootWindow(XtDisplay(gw)), cursor); #ifdef XPM - /* + /* * Check if Pixmap was valid */ if (True == w->login.logoValid) { /* - * Create pixmap window + * Create pixmap window */ { unsigned long valueMask = CWBackPixel | CWBackPixmap; @@ -1963,8 +1929,8 @@ static void Destroy (Widget gw) XftDrawDestroy(w->login.draw); w->login.draw = NULL; } -#endif - +#endif + XtReleaseGC(gw, w->login.textGC); XtReleaseGC(gw, w->login.bgGC); XtReleaseGC(gw, w->login.xorGC); @@ -2006,7 +1972,7 @@ static Boolean SetValues ( Cardinal *num_args) { LoginWidget currentL, newL; - + currentL = (LoginWidget) current; newL = (LoginWidget) new; if (GREETING (currentL) != GREETING (newL)) diff --git a/app/xdm/greeter/Login.h b/app/xdm/greeter/Login.h index 3da7fb2fe..7d04a1ace 100644 --- a/app/xdm/greeter/Login.h +++ b/app/xdm/greeter/Login.h @@ -1,4 +1,3 @@ -/* $Xorg: Login.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */ /* Copyright 1988, 1998 The Open Group @@ -26,7 +25,33 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/xdm/greeter/Login.h,v 3.7 2002/10/06 20:42:16 herrb Exp $ */ +/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ /* * xdm - display manager daemon @@ -35,7 +60,7 @@ from The Open Group. #ifndef _XtLogin_h -#define _XtLogin_h +# define _XtLogin_h /*********************************************************************** * @@ -71,6 +96,9 @@ from The Open Group. # define XtNpromptFont "promptFont" # define XtNgreetFont "greetFont" # define XtNfailFont "failFont" +# define XtNpromptFace "promptFace" +# define XtNgreetFace "greetFace" +# define XtNfailFace "failFace" # define XtNfailTimeout "failTimeout" # define XtNsessionArgument "sessionArgument" # define XtNsecureSession "secureSession" @@ -78,29 +106,35 @@ from The Open Group. # define XtNallowNullPasswd "allowNullPasswd" # define XtNallowRootLogin "allowRootLogin" -#ifdef XPM +# define XtNface "face" +# define XtCFace "Face" +# define XtRXftFont "XftFont" +# define XtRXftColor "XftColor" + /* added by Amit Margalit Oct 1996 */ # define XtNhiColor "hiColor" # define XtNshdColor "shdColor" # define XtNframeWidth "frameWidth" +# define XtCFrameWidth "FrameWidth" # define XtNinnerFramesWidth "innerFramesWidth" # define XtNsepWidth "sepWidth" +# ifdef DANCING /* caolan begin */ -#define XtNlastEventTime "lastEventTime" -#define XtCLastEventTime "LastEventTime" +# define XtNlastEventTime "lastEventTime" +# define XtCLastEventTime "LastEventTime" /* caolan end */ +# endif /* DANCING */ -#define XtNuseShape "useShape" -#define XtCUseShape "UseShape" -#define XtNlogoFileName "logoFileName" -#define XtCLogoFileName "LogoFileName" -#define XtNlogoPadding "logoPadding" -#define XtCLogoPadding "LogoPadding" +# ifdef XPM +# define XtNuseShape "useShape" +# define XtCUseShape "UseShape" +# define XtNlogoFileName "logoFileName" +# define XtCLogoFileName "LogoFileName" +# define XtNlogoPadding "logoPadding" +# define XtCLogoPadding "LogoPadding" +# endif /* XPM */ -# define XtCFrameWidth "FrameWidth" - -#endif /* XPM */ # define XtCGreeting "Greeting" # define XtCNamePrompt "NamePrompt" # define XtCPasswdPrompt "PasswdPrompt" @@ -112,26 +146,48 @@ from The Open Group. # define XtCAllowNullPasswd "AllowNullPasswd" # define XtCAllowRootLogin "AllowRootLogin" +# define XtNchangePasswdMessage "changePasswdMessage" +# define XtCChangePasswdMessage "ChangePasswdMessage" + /* notifyDone interface definition */ -#ifdef __OpenBSD__ -#include <sys/param.h> -/* 2.8 (200012) doesn't have _PW_NAME_LEN */ -#if OpenBSD > 200012 -#define HAVE_PW_NAME_LEN -#endif -#endif - -#ifndef HAVE_PW_NAME_LEN -#define NAME_LEN 32 -#define PASSWORD_LEN 32 -#else -#include <pwd.h> -#define NAME_LEN (_PW_NAME_LEN + 2) -#define PASSWORD_LEN (_PASSWORD_LEN + 2) -#endif - -typedef struct _LoginData { +# ifdef __OpenBSD__ +# include <sys/param.h> +# endif + +# include <pwd.h> +# include <limits.h> + +# ifdef USE_PAM +# define NAME_LEN PAM_MAX_RESP_SIZE +# define PASSWORD_LEN PAM_MAX_RESP_SIZE +# endif + +/* Defined to be in <limits.h> by SUSv2 */ +# if !defined(PASSWORD_LEN) && defined(PASS_MAX) +# define PASSWORD_LEN PASS_MAX +# endif + +/* _PW_NAME_LEN is found in <pwd.h> on OpenBSD > 2.8 (200012) */ +# if !defined(NAME_LEN) && defined(_PW_NAME_LEN) +# define NAME_LEN (_PW_NAME_LEN + 2) +# endif + +/* _PASSWORD_LEN appears to come from 4.4BSD-Lite <pwd.h> */ +# if !defined(PASSWORD_LEN) && defined(_PASSWORD_LEN) +# define PASSWORD_LEN (_PASSWORD_LEN + 2) +# endif + +/* Fallbacks if no other definition found */ +# ifndef NAME_LEN +# define NAME_LEN 32 +# endif + +# ifndef PASSWORD_LEN +# define PASSWORD_LEN 32 +# endif + +typedef struct _LoginData { char name[NAME_LEN], passwd[PASSWORD_LEN]; } LoginData; @@ -145,5 +201,27 @@ typedef struct _LoginClassRec *LoginWidgetClass; /* completely defined in Log extern WidgetClass loginWidgetClass; +extern void ErrorMessage(Widget ctx, const char *message, Bool timeout); +extern void ShowChangePasswdMessage(Widget ctx); + +typedef enum { + LOGIN_PROMPT_NOT_SHOWN, /* Neither prompt nor input shown */ + LOGIN_PROMPT_ECHO_ON, /* Both prompt and input shown */ + LOGIN_PROMPT_ECHO_OFF, /* Prompt shown, input accepted but not + shown (bullets may be shown instead) */ + LOGIN_TEXT_INFO /* Prompt shown, no input area */ +} loginPromptState; + +/* Default prompt meanings for simple username/password auth systems */ +# define LOGIN_PROMPT_USERNAME 0 +# define LOGIN_PROMPT_PASSWORD 1 + +extern int SetPrompt(Widget ctx, int promptId, const char *message, + loginPromptState state, Boolean minimumTime); +extern const char *GetPrompt(Widget ctx, int promptId); + +extern int SetValue(Widget ctx, int promptId, char *value); +extern const char *GetValue(Widget ctx, int promptId); + #endif /* _XtLogin_h */ /* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/app/xdm/greeter/LoginP.h b/app/xdm/greeter/LoginP.h index 9fc2640c5..d73a9a16a 100644 --- a/app/xdm/greeter/LoginP.h +++ b/app/xdm/greeter/LoginP.h @@ -1,4 +1,3 @@ -/* $Xorg: LoginP.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */ /* Copyright 1988, 1998 The Open Group @@ -26,7 +25,33 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/xdm/greeter/LoginP.h,v 3.7 2001/01/17 23:45:25 dawes Exp $ */ +/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ /* * xdm - display manager daemon @@ -34,51 +59,72 @@ from The Open Group. */ #ifndef _LoginP_h -#define _LoginP_h +# define _LoginP_h -#include "Login.h" -#include <X11/CoreP.h> -#ifdef XPM -#include <X11/Xlib.h> -#endif /* XPM */ +# include "Login.h" +# include <X11/IntrinsicP.h> +# include <X11/CoreP.h> +# include <X11/Xlib.h> +# ifdef USE_XFT +# include <X11/Xft/Xft.h> +# endif -#define GET_NAME 0 -#define GET_PASSWD 1 -#define DONE 2 +# define INITIALIZING 0 +# define PROMPTING 1 +# define SHOW_MESSAGE 2 +# define DONE 3 typedef void (*LoginFunc)(LoginWidget, LoginData *, int); +typedef struct { + char * promptText; /* Prompt displayed */ + const char * defaultPrompt; /* Default text for prompt */ + char * valueText; /* Value entered for prompt */ + size_t valueTextMax; /* Size of valueText buffer */ + int valueShownStart;/* Amount of string shown if too */ + int valueShownEnd; /* long to fit in field */ + int cursor; /* current cursor position */ + loginPromptState state; +} loginPromptData; + +# define NUM_PROMPTS 2 /* Currently only 2 prompt fields supported */ +# define LAST_PROMPT (NUM_PROMPTS - 1) + /* New fields for the login widget instance record */ typedef struct { +# ifndef USE_XFT Pixel textpixel; /* foreground pixel */ Pixel promptpixel; /* prompt pixel */ Pixel greetpixel; /* greeting pixel */ Pixel failpixel; /* failure pixel */ -#ifdef XPM +# endif Pixel hipixel; /* frame hilite pixel */ Pixel shdpixel; /* shadow frame pixel */ -#endif /* XPM */ GC textGC; /* pointer to GraphicsContext */ GC bgGC; /* pointer to GraphicsContext */ GC xorGC; /* pointer to GraphicsContext */ +# ifndef USE_XFT GC promptGC; GC greetGC; GC failGC; -#ifdef XPM +# endif GC hiGC; /* for hilight part of frame */ GC shdGC; /* for shaded part of frame */ -#endif /* XPM */ char *greeting; /* greeting */ char *unsecure_greet;/* message displayed when insecure */ char *namePrompt; /* name prompt */ char *passwdPrompt; /* password prompt */ - char *fail; /* failure message */ - XFontStruct *font; /* font for text */ + char *failMsg; /* failure message */ + char *fail; /* current error message */ + char *passwdChangeMsg; /* message when passwd expires */ +# ifndef USE_XFT + XFontStruct *textFont; /* font for text */ XFontStruct *promptFont; /* font for prompts */ XFontStruct *greetFont; /* font for greeting */ XFontStruct *failFont; /* font for failure message */ +# endif /* USE_XFT */ int state; /* state */ - int cursor; /* current cursor position */ + int activePrompt; /* which prompt is active */ int failUp; /* failure message displayed */ LoginData data; /* name/passwd */ char *sessionArg; /* argument passed to session */ @@ -90,21 +136,38 @@ typedef struct { Boolean allow_null_passwd; /* allow null password on login */ Boolean allow_root_login; /* allow root login */ XIC xic; /* input method of input context */ -#ifdef XPM + loginPromptData prompts[NUM_PROMPTS]; + time_t msgTimeout; + +# ifdef DANCING /*caolan begin*/ - int lastEventTime; + int lastEventTime; /*caolan end*/ +# endif /* DANCING */ + int outframewidth; /* outer frame thickness */ int inframeswidth; /* inner frames thickness */ int sepwidth; /* width of separator line */ +# ifdef XPM char *logoFileName; unsigned int logoWidth, logoHeight, logoPadding, logoBorderWidth; int logoX, logoY; Window logoWindow; Boolean useShape, logoValid; Pixmap logoPixmap, logoMask; -#endif /* XPM */ +# endif /* XPM */ +# ifdef USE_XFT + XftDraw *draw; + XftFont *textFace; /* font for text */ + XftFont *promptFace; /* font for prompts */ + XftFont *greetFace; /* font for greeting */ + XftFont *failFace; /* font for failure message */ + XftColor textcolor; /* foreground color */ + XftColor promptcolor; /* prompt color */ + XftColor greetcolor; /* greeting color */ + XftColor failcolor; /* failure color */ +# endif } LoginPart; /* Full instance record declaration */ diff --git a/app/xdm/greeter/Makefile.am b/app/xdm/greeter/Makefile.am index d035811d9..70fa5df8f 100644 --- a/app/xdm/greeter/Makefile.am +++ b/app/xdm/greeter/Makefile.am @@ -1,5 +1,3 @@ -# $XdotOrg: app/xdm/greeter/Makefile.am,v $ - if DYNAMIC_GREETER xdmlibdir = $(XDMLIBDIR) @@ -12,7 +10,16 @@ libXdmGreet_la_SOURCES = \ libXdmGreet_la_LIBADD = $(XDMGREET_LIBS) -AM_CFLAGS = $(XDMGREET_CFLAGS) -I$(top_srcdir) +AM_CFLAGS = $(CWARNFLAGS) $(XDMGREET_CFLAGS) -I$(top_srcdir) libXdmGreet_la_LDFLAGS = -module -avoid-version endif + +if LINT +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) $(libXdmGreet_la_SOURCES) + +endif LINT diff --git a/app/xdm/greeter/Makefile.in b/app/xdm/greeter/Makefile.in index 565966a02..fb8a4765b 100644 --- a/app/xdm/greeter/Makefile.in +++ b/app/xdm/greeter/Makefile.in @@ -14,8 +14,6 @@ @SET_MAKE@ -# $XdotOrg: app/xdm/greeter/Makefile.am,v $ - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -102,10 +100,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CHANGELOG_CMD = @CHANGELOG_CMD@ CHOOSER_CFLAGS = @CHOOSER_CFLAGS@ CHOOSER_LIBS = @CHOOSER_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CWARNFLAGS = @CWARNFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ @@ -142,6 +142,7 @@ F77 = @F77@ FFLAGS = @FFLAGS@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GREP = @GREP@ HAS_ARC4_RANDOM_FALSE = @HAS_ARC4_RANDOM_FALSE@ HAS_ARC4_RANDOM_TRUE = @HAS_ARC4_RANDOM_TRUE@ HAS_KERBEROS_FIVE_FALSE = @HAS_KERBEROS_FIVE_FALSE@ @@ -150,6 +151,8 @@ HAS_SECURE_RPC_FALSE = @HAS_SECURE_RPC_FALSE@ HAS_SECURE_RPC_TRUE = @HAS_SECURE_RPC_TRUE@ HAS_XDM_AUTH_FALSE = @HAS_XDM_AUTH_FALSE@ HAS_XDM_AUTH_TRUE = @HAS_XDM_AUTH_TRUE@ +HAVE_AM_SILENT_RULES_FALSE = @HAVE_AM_SILENT_RULES_FALSE@ +HAVE_AM_SILENT_RULES_TRUE = @HAVE_AM_SILENT_RULES_TRUE@ HAVE_MKTEMP_COMMAND_FALSE = @HAVE_MKTEMP_COMMAND_FALSE@ HAVE_MKTEMP_COMMAND_TRUE = @HAVE_MKTEMP_COMMAND_TRUE@ INSTALL_DATA = @INSTALL_DATA@ @@ -197,13 +200,11 @@ SHELL = @SHELL@ SHELL_CMD = @SHELL_CMD@ STRIP = @STRIP@ SU = @SU@ -TMP_XAW_CFLAGS = @TMP_XAW_CFLAGS@ -TMP_XAW_LIBS = @TMP_XAW_LIBS@ USE_XPM_FALSE = @USE_XPM_FALSE@ USE_XPM_TRUE = @USE_XPM_TRUE@ +UTMP_FILE = @UTMP_FILE@ VERSION = @VERSION@ -XAW_USE_XPRINT_FALSE = @XAW_USE_XPRINT_FALSE@ -XAW_USE_XPRINT_TRUE = @XAW_USE_XPRINT_TRUE@ +WTMP_FILE = @WTMP_FILE@ XDMCONFIGDIR = @XDMCONFIGDIR@ XDMGREET_CFLAGS = @XDMGREET_CFLAGS@ XDMGREET_LIBS = @XDMGREET_LIBS@ @@ -213,12 +214,15 @@ XDMPIDDIR = @XDMPIDDIR@ XDMSCRIPTDIR = @XDMSCRIPTDIR@ XDMSHELL_CFLAGS = @XDMSHELL_CFLAGS@ XDMSHELL_LIBS = @XDMSHELL_LIBS@ +XDMXAUTHDIR = @XDMXAUTHDIR@ XDM_BWPIXMAP = @XDM_BWPIXMAP@ XDM_CFLAGS = @XDM_CFLAGS@ XDM_LDFLAGS = @XDM_LDFLAGS@ XDM_LIBS = @XDM_LIBS@ XDM_PIXMAP = @XDM_PIXMAP@ XDM_PIXMAPDIR = @XDM_PIXMAPDIR@ +XDM_PRINT_CFLAGS = @XDM_PRINT_CFLAGS@ +XDM_PRINT_LIBS = @XDM_PRINT_LIBS@ XFT_CFLAGS = @XFT_CFLAGS@ XFT_LIBS = @XFT_LIBS@ XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ @@ -230,18 +234,9 @@ XPM_LIBS = @XPM_LIBS@ XRDB_PROGRAM = @XRDB_PROGRAM@ XT_CFLAGS = @XT_CFLAGS@ XT_LIBS = @XT_LIBS@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_AS = @ac_ct_AS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DLLTOOL = @ac_ct_DLLTOOL@ -ac_ct_DSYMUTIL = @ac_ct_DSYMUTIL@ ac_ct_F77 = @ac_ct_F77@ -ac_ct_NMEDIT = @ac_ct_NMEDIT@ -ac_ct_OBJDUMP = @ac_ct_OBJDUMP@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ -ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ @@ -259,23 +254,31 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ +datarootdir = @datarootdir@ +distcleancheck_listfiles = @distcleancheck_listfiles@ +docdir = @docdir@ +dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ +htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ +psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ @@ -288,10 +291,10 @@ target_alias = @target_alias@ @DYNAMIC_GREETER_TRUE@ verify.c @DYNAMIC_GREETER_TRUE@libXdmGreet_la_LIBADD = $(XDMGREET_LIBS) -@DYNAMIC_GREETER_TRUE@AM_CFLAGS = $(XDMGREET_CFLAGS) -I$(top_srcdir) +@DYNAMIC_GREETER_TRUE@AM_CFLAGS = $(CWARNFLAGS) $(XDMGREET_CFLAGS) -I$(top_srcdir) @DYNAMIC_GREETER_TRUE@libXdmGreet_la_LDFLAGS = -module -avoid-version @LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) +@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) all: all-am diff --git a/app/xdm/greeter/greet.c b/app/xdm/greeter/greet.c index 2bc32e738..17d21c837 100644 --- a/app/xdm/greeter/greet.c +++ b/app/xdm/greeter/greet.c @@ -1,5 +1,3 @@ -/* $Xorg: greet.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */ -/* $XdotOrg: $ */ /* Copyright 1988, 1998 The Open Group @@ -27,7 +25,34 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.16tsi Exp $ */ +/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + /* * xdm - display manager daemon @@ -47,7 +72,7 @@ from The Open Group. #include <X11/XKBlib.h> #ifdef USE_XINERAMA -#include <X11/extensions/Xinerama.h> +# include <X11/extensions/Xinerama.h> #endif #include "dm.h" @@ -55,10 +80,19 @@ from The Open Group. #include "greet.h" #include "Login.h" -#ifdef __OpenBSD__ -#include <syslog.h> +#if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG_H) +# define USE_SYSLOG +# include <syslog.h> +# ifndef LOG_AUTHPRIV +# define LOG_AUTHPRIV LOG_AUTH +# endif +# ifndef LOG_PID +# define LOG_PID 0 +# endif #endif +#include <string.h> + #if defined(SECURE_RPC) && defined(sun) /* Go figure, there's no getdomainname() prototype available */ extern int getdomainname(char *name, size_t len); @@ -71,13 +105,13 @@ extern int getdomainname(char *name, size_t len); int (*__xdm_PingServer)(struct display *d, Display *alternateDpy) = NULL; void (*__xdm_SessionPingFailed)(struct display *d) = NULL; -void (*__xdm_Debug)(char * fmt, ...) = NULL; +void (*__xdm_Debug)(const char * fmt, ...) = NULL; void (*__xdm_RegisterCloseOnFork)(int fd) = NULL; void (*__xdm_SecureDisplay)(struct display *d, Display *dpy) = NULL; void (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy) = NULL; void (*__xdm_ClearCloseOnFork)(int fd) = NULL; void (*__xdm_SetupDisplay)(struct display *d) = NULL; -void (*__xdm_LogError)(char * fmt, ...) = NULL; +void (*__xdm_LogError)(const char * fmt, ...) = NULL; void (*__xdm_SessionExit)(struct display *d, int status, int removeAuth) = NULL; void (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy) = NULL; int (*__xdm_source)(char **environ, char *file) = NULL; @@ -87,43 +121,67 @@ char **(*__xdm_putEnv)(const char *string, char **env) = NULL; char **(*__xdm_parseArgs)(char **argv, char *string) = NULL; void (*__xdm_printEnv)(char **e) = NULL; char **(*__xdm_systemEnv)(struct display *d, char *user, char *home) = NULL; -void (*__xdm_LogOutOfMem)(char * fmt, ...) = NULL; +void (*__xdm_LogOutOfMem)(const char * fmt, ...) = NULL; void (*__xdm_setgrent)(void) = NULL; struct group *(*__xdm_getgrent)(void) = NULL; void (*__xdm_endgrent)(void) = NULL; -#ifdef USESHADOW +# ifdef USESHADOW struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL; +# ifndef QNX4 void (*__xdm_endspent)(void) = NULL; -#endif +# endif /* QNX4 doesn't use endspent */ +# endif struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS) = NULL; -#ifdef linux +# if defined(linux) || defined(__GLIBC__) void (*__xdm_endpwent)(void) = NULL; -#endif +# endif char *(*__xdm_crypt)(CRYPT_ARGS) = NULL; -#ifdef USE_PAM +# ifdef USE_PAM pam_handle_t **(*__xdm_thepamhp)(void) = NULL; -#endif +# endif #endif #ifdef SECURE_RPC -#include <rpc/rpc.h> -#include <rpc/key_prot.h> +# include <rpc/rpc.h> +# include <rpc/key_prot.h> #endif #ifdef K5AUTH -#include <krb5/krb5.h> +# include <krb5/krb5.h> #endif extern Display *dpy; static int done, code; -static char name[128], password[128]; +#ifndef USE_PAM +static char name[NAME_LEN], password[PASSWORD_LEN]; +#endif static Widget toplevel; static Widget login; static XtAppContext context; static XtIntervalId pingTimeout; +#ifdef USE_PAM +static int pamconv(int num_msg, +# ifndef sun + const +# endif + struct pam_message **msg, + struct pam_response **response, void *appdata_ptr); + +# define PAM_ERROR_PRINT(pamfunc, pamh) \ + LogError("%s failure: %s\n", pamfunc, pam_strerror(pamh, pam_error)) + + +struct myconv_data { + struct display *d; + struct greet_info *greet; + char *username_display; +}; +#endif + + /*ARGSUSED*/ static void GreetPingServer ( @@ -150,11 +208,12 @@ GreetDone ( data->name, strlen (data->passwd)); switch (status) { case NOTIFY_OK: +#ifndef USE_PAM strncpy (name, data->name, sizeof(name)); name[sizeof(name)-1] = '\0'; strncpy (password, data->passwd, sizeof(password)); password[sizeof(password)-1] = '\0'; - bzero (data->passwd, PASSWORD_LEN); +#endif code = 0; done = 1; break; @@ -174,6 +233,12 @@ GreetDone ( done = 1; break; } +#ifndef USE_PAM + if (done) { + bzero (data->name, NAME_LEN); + bzero (data->passwd, PASSWORD_LEN); + } +#endif } static Display * @@ -183,7 +248,7 @@ InitGreet (struct display *d) int i; static int argc; Screen *scrn; - static char *argv[] = { "xlogin", 0 }; + static char *argv[] = { "xlogin", NULL }; Display *dpy; #ifdef USE_XINERAMA XineramaScreenInfo *screens; @@ -194,11 +259,11 @@ InitGreet (struct display *d) argc = 1; XtToolkitInitialize (); context = XtCreateApplicationContext(); - dpy = XtOpenDisplay (context, d->name, "xlogin", "Xlogin", 0,0, + dpy = XtOpenDisplay (context, d->name, "xlogin", "Xlogin", NULL, 0, &argc, argv); if (!dpy) - return 0; + return NULL; #ifdef XKB { @@ -316,9 +381,10 @@ Greet (struct display *d, struct greet_info *greet) Debug ("Done dispatch %s\n", d->name); if (code == 0) { +#ifndef USE_PAM char *ptr; unsigned int c,state = WHITESPACE; - + /* * Process the name string to get rid of white spaces. */ @@ -334,6 +400,7 @@ Greet (struct display *d, struct greet_info *greet) greet->name = ptr; greet->password = password; +#endif /* USE_PAM */ XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string)); XtSetArg (arglist[1], XtNallowNullPasswd, (char *) &(greet->allow_null_passwd)); XtSetArg (arglist[2], XtNallowRootLogin, (char *) &(greet->allow_root_login)); @@ -347,19 +414,19 @@ Greet (struct display *d, struct greet_info *greet) static void FailedLogin (struct display *d, struct greet_info *greet) { -#ifdef __OpenBSD__ - syslog(LOG_NOTICE, "LOGIN FAILURE ON %s", - d->name); +#ifdef USE_SYSLOG syslog(LOG_AUTHPRIV|LOG_NOTICE, "LOGIN FAILURE ON %s, %s", d->name, greet->name); #endif DrawFail (login); +#ifndef USE_PAM bzero (greet->name, strlen(greet->name)); bzero (greet->password, strlen(greet->password)); +#endif } - +_X_EXPORT greet_user_rtn GreetUser( struct display *d, Display ** dpy, @@ -395,18 +462,20 @@ greet_user_rtn GreetUser( __xdm_setgrent = dlfuncs->_setgrent; __xdm_getgrent = dlfuncs->_getgrent; __xdm_endgrent = dlfuncs->_endgrent; -#ifdef USESHADOW +# ifdef USESHADOW __xdm_getspnam = dlfuncs->_getspnam; +# ifndef QNX4 __xdm_endspent = dlfuncs->_endspent; -#endif +# endif /* QNX4 doesn't use endspent */ +# endif __xdm_getpwnam = dlfuncs->_getpwnam; -#ifdef linux +# if defined(linux) || defined(__GLIBC__) __xdm_endpwent = dlfuncs->_endpwent; -#endif +# endif __xdm_crypt = dlfuncs->_crypt; -#ifdef USE_PAM +# ifdef USE_PAM __xdm_thepamhp = dlfuncs->_thepamhp; -#endif +# endif #endif *dpy = InitGreet (d); @@ -420,10 +489,122 @@ greet_user_rtn GreetUser( LogError ("Cannot reopen display %s for greet window\n", d->name); exit (RESERVER_DISPLAY); } -#ifdef __OpenBSD__ - openlog("xdm", LOG_ODELAY, LOG_AUTH); +#ifdef USE_SYSLOG + openlog("xdm", LOG_ODELAY|LOG_PID, LOG_AUTHPRIV); #endif + for (;;) { +#ifdef USE_PAM + + /* Run PAM conversation */ + pam_handle_t **pamhp = thepamhp(); + int pam_error; + unsigned int pam_flags = 0; + struct myconv_data pcd = { d, greet, NULL }; + struct pam_conv pc = { pamconv, &pcd }; + const char * pam_fname; + char * username; + const char * login_prompt; + + + SetPrompt(login, 0, NULL, LOGIN_PROMPT_NOT_SHOWN, False); + login_prompt = GetPrompt(login, LOGIN_PROMPT_USERNAME); + SetPrompt(login, 1, NULL, LOGIN_PROMPT_NOT_SHOWN, False); + +# define RUN_AND_CHECK_PAM_ERROR(function, args) \ + do { \ + pam_error = function args; \ + if (pam_error != PAM_SUCCESS) { \ + PAM_ERROR_PRINT(#function, *pamhp); \ + goto pam_done; \ + } \ + } while (0) + + + RUN_AND_CHECK_PAM_ERROR(pam_start, + ("xdm", NULL, &pc, pamhp)); + + /* Set default login prompt to xdm's default from Xresources */ + if (login_prompt != NULL) { + RUN_AND_CHECK_PAM_ERROR(pam_set_item, + (*pamhp, PAM_USER_PROMPT, login_prompt)); + } + + if (d->name[0] != ':') { /* Displaying to remote host */ + char *hostname = strdup(d->name); + + if (hostname == NULL) { + LogOutOfMem("GreetUser"); + } else { + char *colon = strrchr(hostname, ':'); + + if (colon != NULL) + *colon = '\0'; + + RUN_AND_CHECK_PAM_ERROR(pam_set_item, + (*pamhp, PAM_RHOST, hostname)); + free(hostname); + } + } else + RUN_AND_CHECK_PAM_ERROR(pam_set_item, (*pamhp, PAM_TTY, d->name)); + + if (!greet->allow_null_passwd) { + pam_flags |= PAM_DISALLOW_NULL_AUTHTOK; + } + RUN_AND_CHECK_PAM_ERROR(pam_authenticate, + (*pamhp, pam_flags)); + + /* handle expired passwords */ + pam_error = pam_acct_mgmt(*pamhp, pam_flags); + pam_fname = "pam_acct_mgmt"; + if (pam_error == PAM_NEW_AUTHTOK_REQD) { + ShowChangePasswdMessage(login); + do { + pam_error = pam_chauthtok(*pamhp, PAM_CHANGE_EXPIRED_AUTHTOK); + } while ((pam_error == PAM_AUTHTOK_ERR) || + (pam_error == PAM_TRY_AGAIN)); + pam_fname = "pam_chauthtok"; + } + if (pam_error != PAM_SUCCESS) { + PAM_ERROR_PRINT(pam_fname, *pamhp); + goto pam_done; + } + + RUN_AND_CHECK_PAM_ERROR(pam_setcred, + (*pamhp, 0)); + RUN_AND_CHECK_PAM_ERROR(pam_get_item, + (*pamhp, PAM_USER, (void *) &username)); + if (username != NULL) { + Debug("PAM_USER: %s\n", username); + greet->name = username; + greet->password = NULL; + } + + pam_done: + if (code != 0) + { + CloseGreet (d); + SessionExit (d, code, FALSE); + } + if ((pam_error == PAM_SUCCESS) && (Verify (d, greet, verify))) { + SetPrompt (login, 1, "Login Successful", LOGIN_TEXT_INFO, False); + SetValue (login, 1, NULL); + break; + } else { + /* Try to fill in username for failed login error log */ + if (greet->name == NULL) { + if (username == NULL) { + RUN_AND_CHECK_PAM_ERROR(pam_get_item, + (*pamhp, PAM_USER, + (void *) &username)); + } + greet->name = username; + } + FailedLogin (d, greet); + RUN_AND_CHECK_PAM_ERROR(pam_end, + (*pamhp, pam_error)); + } +#else /* not PAM */ /* * Greet user, requesting name/password */ @@ -440,6 +621,7 @@ greet_user_rtn GreetUser( break; else FailedLogin (d, greet); +#endif } DeleteXloginResources (d, *dpy); CloseGreet (d); @@ -466,7 +648,7 @@ greet_user_rtn GreetUser( XHostAddress addr; char netname[MAXNETNAMELEN+1]; char domainname[MAXNETNAMELEN+1]; - + getdomainname(domainname, sizeof domainname); user2netname (netname, verify->uid, domainname); addr.family = FamilyNetname; @@ -490,9 +672,110 @@ greet_user_rtn GreetUser( d->authorizations[i] = Krb5GetAuthFor(14, "MIT-KERBEROS-5", d->name); SaveServerAuthorizations (d, d->authorizations, d->authNum); - } + } #endif } return Greet_Success; } + + +#ifdef USE_PAM +static int pamconv(int num_msg, +# ifndef sun + const +# endif + struct pam_message **msg, + struct pam_response **response, void *appdata_ptr) +{ + int i; + int greetCode; + int status = PAM_SUCCESS; + const char *pam_msg_styles[5] + = { "<invalid pam msg style>", + "PAM_PROMPT_ECHO_OFF", "PAM_PROMPT_ECHO_ON", + "PAM_ERROR_MSG", "PAM_TEXT_INFO" } ; + + struct pam_message *m; + struct pam_response *r; + + struct myconv_data *d = (struct myconv_data *) appdata_ptr; + + pam_handle_t **pamhp = thepamhp(); + + *response = calloc(num_msg, sizeof (struct pam_response)); + if (*response == NULL) + return (PAM_BUF_ERR); + + m = (struct pam_message *)*msg; + r = *response; + + for (i = 0; i < num_msg; i++ , m++ , r++) { + char *username; + int promptId = 0; + loginPromptState pStyle = LOGIN_PROMPT_ECHO_OFF; + + if ((pam_get_item(*pamhp, PAM_USER, (void *) &username) == PAM_SUCCESS) + && (username != NULL) && (*username != '\0')) { + SetPrompt(login, LOGIN_PROMPT_USERNAME, + NULL, LOGIN_TEXT_INFO, False); + SetValue(login, LOGIN_PROMPT_USERNAME, username); + promptId = 1; + } + + Debug("pam_msg: %s (%d): '%s'\n", + ((m->msg_style > 0) && (m->msg_style <= 4)) ? + pam_msg_styles[m->msg_style] : pam_msg_styles[0], + m->msg_style, m->msg); + + switch (m->msg_style) { + case PAM_ERROR_MSG: + ErrorMessage(login, m->msg, True); + break; + + case PAM_TEXT_INFO: + SetPrompt (login, promptId, m->msg, LOGIN_TEXT_INFO, True); + SetValue (login, promptId, NULL); + break; + + case PAM_PROMPT_ECHO_ON: + pStyle = LOGIN_PROMPT_ECHO_ON; + /* FALLTHROUGH */ + case PAM_PROMPT_ECHO_OFF: + SetPrompt (login, promptId, m->msg, pStyle, False); + SetValue (login, promptId, NULL); + greetCode = Greet (d->d, d->greet); + if (greetCode != 0) { + status = PAM_CONV_ERR; + goto pam_error; + } else { + r->resp = strdup(GetValue(login, promptId)); + SetValue(login, promptId, NULL); + if (r->resp == NULL) { + status = PAM_BUF_ERR; + goto pam_error; + } + /* Debug("pam_resp: '%s'\n", r->resp); */ + } + break; + + default: + LogError("Unknown PAM msg_style: %d\n", m->msg_style); + } + } + pam_error: + if (status != PAM_SUCCESS) { + /* free responses */ + r = *response; + for (i = 0; i < num_msg; i++, r++) { + if (r->resp) { + bzero(r->resp, strlen(r->resp)); + free(r->resp); + } + } + free(*response); + *response = NULL; + } + return status; +} +#endif diff --git a/app/xdm/greeter/verify.c b/app/xdm/greeter/verify.c index 13658fa41..7c86ae3fb 100644 --- a/app/xdm/greeter/verify.c +++ b/app/xdm/greeter/verify.c @@ -1,5 +1,3 @@ -/* $Xorg: verify.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */ -/* $XdotOrg: app/xdm/greeter/verify.c,v 1.9 2006/06/03 00:05:24 alanc Exp $ */ /* Copyright 1988, 1998 The Open Group @@ -27,7 +25,6 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/xdm/greeter/verify.c,v 3.26 2003/11/19 04:44:00 dawes Exp $ */ /* * xdm - display manager daemon @@ -58,7 +55,7 @@ from The Open Group. # include <prot.h> #endif -# include "greet.h" +#include "greet.h" #ifdef QNX4 extern char *crypt(const char *, const char *); @@ -84,12 +81,12 @@ static char *envvars[] = { }; #ifdef KERBEROS -#include <sys/param.h> -#include <kerberosIV/krb.h> +# include <sys/param.h> +# include <kerberosIV/krb.h> /* OpenBSD 2.8 needs this. */ -#if defined(OpenBSD) && (OpenBSD <= 200012) -#include <kerberosIV/kafs.h> -#endif +# if defined(OpenBSD) && (OpenBSD <= 200012) +# include <kerberosIV/kafs.h> +# endif static char krbtkfile[MAXPATHLEN]; #endif @@ -182,7 +179,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) #endif /* Build path of the auth script and call it */ snprintf(path, sizeof(path), _PATH_AUTHPROG "%s", style); - auth_call(as, path, style, "-s", "response", greet->name, + auth_call(as, path, style, "-s", "response", greet->name, lc->lc_class, (void *)NULL); authok = auth_getstate(as); @@ -216,12 +213,12 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) } /* - * Shell must be in /etc/shells + * Shell must be in /etc/shells */ for (;;) { s = getusershell(); if (s == NULL) { - /* did not found the shell in /etc/shells + /* did not found the shell in /etc/shells -> failure */ Debug("shell not in /etc/shells\n"); bzero(greet->password, passwd_len); @@ -233,7 +230,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) endusershell(); break; } - } + } #elif defined(USESECUREWARE) /* !USE_BSDAUTH */ /* * This is a global variable and will be referenced in at least session.c @@ -332,16 +329,16 @@ int Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) { struct passwd *p; -#ifndef USE_PAM -#ifdef USESHADOW +# ifndef USE_PAM +# ifdef USESHADOW struct spwd *sp; -#endif +# endif char *user_pass = NULL; -#endif -#ifdef __OpenBSD__ +# endif +# ifdef __OpenBSD__ char *s; struct timeval tp; -#endif +# endif char *shell, *home; char **argv; @@ -357,18 +354,18 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) return 0; } -#if defined(sun) && defined(SVR4) - /* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, +# if defined(sun) && defined(SVR4) + /* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, then root can only login on system console */ -# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login" +# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login" if (p->pw_uid == 0) { char *console = NULL, *tmp = NULL; FILE *fs; if ((fs= fopen(SOLARIS_LOGIN_DEFAULTS, "r")) != NULL) - { + { char str[120]; while (!feof(fs)) { @@ -379,8 +376,8 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) console = strdup((tmp+8)); } fclose(fs); - if ( console != NULL && - (strncmp(console, "/dev/console", 12) == 0) && + if ( console != NULL && + (strncmp(console, "/dev/console", 12) == 0) && (strncmp(d->name,":0",2) != 0) ) { Debug("Not on system console\n"); @@ -394,37 +391,38 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) else { Debug("Could not open %s\n", SOLARIS_LOGIN_DEFAULTS); - } + } } -#endif +# endif -#ifndef USE_PAM /* PAM authentication happened in GreetUser already */ -#ifdef linux +# ifndef USE_PAM /* PAM authentication happened in GreetUser already */ +# ifdef linux if (!strcmp(p->pw_passwd, "!") || !strcmp(p->pw_passwd, "*")) { Debug ("The account is locked, no login allowed.\n"); bzero(greet->password, strlen(greet->password)); return 0; } -#endif +# endif user_pass = p->pw_passwd; -#ifdef KERBEROS +# ifdef KERBEROS if(strcmp(greet->name, "root") != 0){ char name[ANAME_SZ]; char realm[REALM_SZ]; char *q; int ret; - + if(krb_get_lrealm(realm, 1)){ Debug ("Can't get Kerberos realm.\n"); } else { - sprintf(krbtkfile, "%s.%s", TKT_ROOT, d->name); + snprintf(krbtkfile, sizeof(krbktfile), "%s.%s", + TKT_ROOT, d->name); krb_set_tkt_string(krbtkfile); unlink(krbtkfile); - - ret = krb_verify_user(greet->name, "", realm, + + ret = krb_verify_user(greet->name, "", realm, greet->password, 1, "rcmd"); - + if(ret == KSUCCESS){ chown(krbtkfile, p->pw_uid, p->pw_gid); Debug("kerberos verify succeeded\n"); @@ -432,9 +430,9 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) if (k_setpag() == -1) LogError ("setpag() failed for %s\n", greet->name); - + if((ret = k_afsklog(NULL, NULL)) != KSUCCESS) - LogError("Warning %s\n", + LogError("Warning %s\n", krb_get_err_text(ret)); } goto done; @@ -445,24 +443,24 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) } } } -#endif -#ifdef USESHADOW +# endif +# ifdef USESHADOW errno = 0; sp = getspnam(greet->name); if (sp == NULL) { - Debug ("getspnam() failed, errno=%d. Are you root?\n", errno); + Debug ("getspnam() failed: %s\n", _SysErrorMsg (errno)); } else { user_pass = sp->sp_pwdp; } -#ifndef QNX4 +# ifndef QNX4 endspent(); -#endif /* QNX4 doesn't need endspent() to end shadow passwd ops */ -#endif /* USESHADOW */ -#if defined(ultrix) || defined(__ultrix__) +# endif /* QNX4 doesn't need endspent() to end shadow passwd ops */ +# endif /* USESHADOW */ +# if defined(ultrix) || defined(__ultrix__) if (authenticate_user(p, greet->password, NULL) < 0) -#else +# else if (strcmp (crypt (greet->password, user_pass), user_pass)) -#endif +# endif { if(!greet->allow_null_passwd || strlen(p->pw_passwd) > 0) { Debug ("password verify failed\n"); @@ -470,10 +468,10 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) return 0; } /* else: null passwd okay */ } -#ifdef KERBEROS +# ifdef KERBEROS done: -#endif -#ifdef __OpenBSD__ +# endif +# ifdef __OpenBSD__ /* * Only accept root logins if allowRootLogin resource is set */ @@ -483,12 +481,12 @@ done: return 0; } /* - * Shell must be in /etc/shells + * Shell must be in /etc/shells */ for (;;) { s = getusershell(); if (s == NULL) { - /* did not found the shell in /etc/shells + /* did not found the shell in /etc/shells -> failure */ Debug("shell not in /etc/shells\n"); bzero(greet->password, strlen(greet->password)); @@ -500,7 +498,7 @@ done: endusershell(); break; } - } + } /* * Test for expired password */ @@ -518,12 +516,12 @@ done: Debug("account has expired.\n"); bzero(greet->password, strlen(greet->password)); return 0; - } + } } -#endif /* __OpenBSD__ */ +# endif /* __OpenBSD__ */ bzero(user_pass, strlen(user_pass)); /* in case shadow password */ -#endif /* USE_PAM */ +# endif /* USE_PAM */ #endif /* USE_BSDAUTH */ Debug ("verify succeeded\n"); |