Import xdm 1.1.4

This commit is contained in:
matthieu 2007-08-05 19:00:25 +00:00
parent dcd6bea211
commit 9ab55f74d2
37 changed files with 2880 additions and 938 deletions

View File

@ -0,0 +1,23 @@
Original authors credited in source files:
Keith Packard, MIT X Consortium
Jim Fulton, MIT X Consortium
Stephen Gildea, The Open Group
Later enhancements:
Alan Coopersmith, Sun Microsystems:
IPv6 support, Solaris authentication enhancements,
PAM conversation rewrite
Amit Margalit, Caolan McNamara, Ivan Griffin, Matthieu Herrb:
3D decoration & XPM pixmap display in login widget
Dmitry Yu. Bolkhovityanov:
Xinerama support
Matthieu Herrb & OpenBSD Team:
"allowRootLogin", OpenBSD authentication enhancements
Werner Fink, SuSE:
PAM support

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,8 @@ appman_PRE = xdm.man.cpp
appman_DATA = $(appman_PRE:man.cpp=@APP_MAN_SUFFIX@)
CLEANFILES = $(appman_DATA)
EXTRA_DIST = $(appman_PRE)
EXTRA_DIST = $(appman_PRE) ChangeLog
MAINTAINERCLEANFILES = ChangeLog
include $(top_srcdir)/cpprules.in
@ -164,3 +165,22 @@ appdefault_DATA = $(APPDEFAULTFILES)
CLEANFILES += $(APPDEFAULTFILES)
EXTRA_DIST += $(APPDEFAULTFILES:%=%.ad)
if LINT
ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
lint:
$(LINT) $(ALL_LINT_FLAGS) $(xdm_CFLAGS) $(xdm_SOURCES) $(xdm_LDADD)
$(LINT) $(ALL_LINT_FLAGS) $(xdmshell_CFLAGS) $(xdmshell_SOURCES)
$(LINT) $(ALL_LINT_FLAGS) $(chooser_CFLAGS) $(chooser_SOURCES) $(chooser_LDADD)
(cd greeter && $(MAKE) $(AM_MAKEFLAGS) lint)
endif LINT
.PHONY: ChangeLog
ChangeLog:
(GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
dist-hook: ChangeLog

View File

@ -19,4 +19,4 @@ For instance, some packagers/sites may prefer:
--with-xdmconfigdir=/etc/X11/xdm --with-xdmlibdir=$(prefix)/lib/xdm
--with-xdmscriptdir=/etc/X11/xdm
$Id: README,v 1.1.1.1 2006/11/25 20:32:04 matthieu Exp $
$Id: README,v 1.1.1.2 2007/08/05 19:00:25 matthieu Exp $

View File

@ -1,5 +1,5 @@
/*
* $XdotOrg$
* $XdotOrg: app/xdm/access.c,v 1.2 2004/04/23 19:54:42 eich Exp $
* $Xorg: access.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $
*
Copyright 1990, 1998 The Open Group
@ -198,7 +198,7 @@ FreeAccessDatabase (void)
next = d->next;
FreeDisplayEntry (d);
}
database = 0;
database = NULL;
}
#define WORD_LEN 256
@ -310,7 +310,7 @@ tryagain:
void *addr=NULL;
size_t addr_length=0;
#if defined(IPv6) && defined(AF_INET6)
struct addrinfo *ai;
struct addrinfo *ai = NULL;
#else
struct hostent *hostent = gethostbyname (hostOrAlias);
#endif
@ -346,17 +346,26 @@ tryagain:
Debug ("No such host %s\n", hostOrAlias);
LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias);
free ((char *) h);
#if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
#endif
goto tryagain;
}
if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, addr_length))
{
LogOutOfMem ("ReadHostEntry\n");
free ((char *) h);
#if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
#endif
return NULL;
}
memmove( h->entry.hostAddress.data, addr, addr_length);
#if defined(IPv6) && defined(AF_INET6)
freeaddrinfo(ai);
if (ai)
freeaddrinfo(ai);
#endif
}
return h;
@ -430,7 +439,7 @@ ReadDisplayEntry (FILE *file)
int addrtype = 0;
#if defined(IPv6) && defined(AF_INET6)
struct addrinfo *ai;
struct addrinfo *ai = NULL;
if (getaddrinfo(displayOrAlias, NULL, NULL, &ai) == 0) {
addrtype = ai->ai_addr->sa_family;
@ -457,6 +466,10 @@ ReadDisplayEntry (FILE *file)
{
LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias);
free ((char *) d);
#if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
#endif
return NULL;
}
d->type = DISPLAY_ADDRESS;
@ -464,9 +477,17 @@ ReadDisplayEntry (FILE *file)
if (!XdmcpAllocARRAY8 (&display->clientAddress, addr_length))
{
free ((char *) d);
#if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
#endif
return NULL;
}
memmove( display->clientAddress.data, addr, addr_length);
#if defined(IPv6) && defined(AF_INET6)
if (ai)
freeaddrinfo(ai);
#endif
switch (addrtype)
{
#ifdef AF_UNIX

View File

@ -148,7 +148,7 @@ ForgetIndirectClient (
{
IndirectUsersPtr i, prev;
prev = 0;
prev = NULL;
for (i = indirectUsers; i; i = i->next)
{
if (XdmcpARRAY8Equal (clientAddress, &i->client) &&
@ -254,7 +254,7 @@ IndirectChoice (
Time_t now;
now = time ((Time_t*)0);
prev = 0;
prev = NULL;
for (c = choices; c; c = next)
{
next = c->next;
@ -280,7 +280,7 @@ IndirectChoice (
prev = c;
}
}
return 0;
return NULL;
}
static int
@ -339,7 +339,7 @@ RegisterIndirectChoice (
c->next = choices;
choices = c;
}
c->time = time (0);
c->time = time ((Time_t *) 0);
return 1;
}
@ -479,9 +479,9 @@ ProcessChooserSocket (int fd)
buffer.size = sizeof (buf);
buffer.count = len;
buffer.pointer = 0;
clientAddress.data = 0;
clientAddress.data = NULL;
clientAddress.length = 0;
choice.data = 0;
choice.data = NULL;
choice.length = 0;
if (XdmcpReadARRAY8 (&buffer, &clientAddress)) {
if (XdmcpReadCARD16 (&buffer, &connectionType)) {

View File

@ -299,7 +299,7 @@ HostnameCompare (const void *a, const void *b)
static void
RebuildTable (int size)
{
char **newTable = 0;
char **newTable = NULL;
HostName *names;
int i;
@ -399,7 +399,7 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi
new->hostname = *hostname;
*names = new;
new->next = 0;
new->next = NULL;
NameTableSize++;
}
else
@ -474,7 +474,7 @@ EmptyHostnames (void)
DisposeHostname (hosts);
}
NameTableSize = 0;
hostNamedb = 0;
hostNamedb = NULL;
RebuildTable (NameTableSize);
}
@ -502,9 +502,9 @@ ReceivePacket (XtPointer closure, int *source, XtInputId *id)
return;
if (header.version != XDM_PROTOCOL_VERSION)
return;
hostname.data = 0;
status.data = 0;
authenticationName.data = 0;
hostname.data = NULL;
status.data = NULL;
authenticationName.data = NULL;
switch (header.opcode) {
case WILLING:
if (XdmcpReadARRAY8 (&buffer, &authenticationName) &&
@ -742,6 +742,7 @@ RegisterHostname (char *name)
}
}
}
freeaddrinfo(ai);
}
}
#else

View File

@ -1,4 +1,4 @@
# $XdotOrg: app/xdm/config/Makefile.am,v 1.9 2006/03/18 03:43:18 alanc Exp $
# $XdotOrg: $
#
include $(top_srcdir)/cpprules.in
@ -15,26 +15,26 @@ xdmconfig_DATA = \
Xservers
xdmscript_SCRIPTS = \
Xsession
Xreset \
Xsession \
Xstartup
dist_xdmscript_SCRIPTS = \
GiveConsole \
TakeConsole \
Xsetup_0 \
Xstartup \
Xreset \
Xwilling
pixmapdir = $(XDM_PIXMAPDIR)
dist_pixmap_DATA = xorg-bw.xpm xorg.xpm
BUILT_SOURCES = Xservers.ws xdm-config Xresources Xsession
BUILT_SOURCES = Xservers.ws xdm-config Xreset Xresources Xsession Xstartup
CLEANFILES = $(BUILT_SOURCES) Xservers
EXTRA_DIST = Xservers.ws.cpp Xservers.fs \
xdm-config.cpp Xresources.cpp Xsession.cpp
xdm-config.cpp Xreset.cpp Xresources.cpp Xsession.cpp Xstartup.cpp
Xservers: Xservers.$(SERVERSTYPE)
ln -s Xservers.$(SERVERSTYPE) Xservers
@ -50,11 +50,12 @@ XPMDEFINES = -DXPM -DBITMAPDIR=$(XDM_PIXMAPDIR) -DXDM_PIXMAP=$(XDM_PIXMAP) \
MKTEMP_DEFINES = -DMKTEMP_COMMAND=$(MKTEMP_COMMAND)
#endif
CPP_FILES_FLAGS = -DBINDIR=$(bindir) -DDEFAULTVT=$(DEFAULTVT) \
-DXDMDIR=$(XDMLIBDIR) -DXDMLOGDIR=$(XDMLOGDIR) -DXDMPIDDIR=$(XDMPIDDIR) \
-DXDMCONFIGDIR=$(XDMCONFIGDIR) -DXDMSCRIPTDIR=$(XDMSCRIPTDIR) \
-DSU=$(SU) -DCHOOSERPATH=$(XDMLIBDIR)/chooser $(XPMDEFINES) \
-DSHELL_CMD=$(SHELL_CMD) $(MKTEMP_DEFINES)
CPP_FILES_FLAGS = -DBINDIR="$(bindir)" -DDEFAULTVT="$(DEFAULTVT)" \
-DXDMDIR="$(XDMLIBDIR)" -DXDMLOGDIR="$(XDMLOGDIR)" \
-DXDMPIDDIR="$(XDMPIDDIR)" -DXDMCONFIGDIR="$(XDMCONFIGDIR)" \
-DXDMSCRIPTDIR="$(XDMSCRIPTDIR)" -DSU="$(SU)" \
-DCHOOSERPATH="$(XDMLIBDIR)/chooser" $(XPMDEFINES) \
-DSHELL_CMD="$(SHELL_CMD)" $(MKTEMP_DEFINES)
Xservers.ws: $(srcdir)/Xservers.ws.cpp
$(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $(srcdir)/Xservers.ws.cpp | $(CPP_SED_MAGIC) > $@

View File

@ -0,0 +1,5 @@
XCOMM!/bin/sh
XCOMM Deregister a login. (Derived from TakeConsole as follows:)
XCOMM
BINDIR/sessreg -d -w "/var/log/wtmp" -u "/var/run/utmp" \
-x "XDMCONFIGDIR/Xservers" -l $DISPLAY -h "" $USER

View File

@ -10,4 +10,4 @@ XCOMM you can add them here as well. Each X terminal line should
XCOMM look like:
XCOMM XTerminalName:0 foreign
XCOMM
:0 local BINDIR/X DEFAULTVT
:0 local BINDIR/X :0 DEFAULTVT

View File

@ -0,0 +1,5 @@
XCOMM!/bin/sh
XCOMM Register a login (derived from GiveConsole as follows:)
XCOMM
BINDIR/sessreg -a -w "/var/log/wtmp" -u "/var/run/utmp" \
-x "XDMCONFIGDIR/Xservers" -l $DISPLAY -h "" $USER

View File

@ -1,4 +1,4 @@
/* $XdotOrg: app/xdm/daemon.c,v 1.4 2006/03/30 21:14:31 alanc Exp $ */
/* $XdotOrg: app/xdm/daemon.c,v 1.3 2006/03/16 21:46:55 alanc Exp $ */
/* $Xorg: daemon.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
/*

View File

@ -1,3 +1,4 @@
/* $XdotOrg: $ */
/* $Xorg: dm.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $ */
/*
@ -67,7 +68,9 @@ from The Open Group.
# include <sys/stat.h>
# include <errno.h>
# include <X11/Xfuncproto.h>
# include <X11/Xatom.h>
# include <stdarg.h>
# include <stdint.h>
#ifndef F_TLOCK
#ifndef X_NOT_POSIX
@ -87,7 +90,7 @@ static void ScanServers (void);
static void SetAccessFileTime (void);
static void SetConfigFileTime (void);
static void StartDisplays (void);
static void TerminateProcess (int pid, int signal);
static void TerminateProcess (pid_t pid, int signal);
volatile int Rescan;
static long ServersModTime, ConfigModTime, AccessFileModTime;
@ -105,12 +108,13 @@ static SIGVAL ChildNotify (int n);
static int StorePid (void);
static int parent_pid = -1; /* PID of parent xdm process */
static pid_t parent_pid = -1; /* PID of parent xdm process */
int
main (int argc, char **argv)
{
int oldpid, oldumask;
int oldpid;
mode_t oldumask;
char cmdbuf[1024];
/* make sure at least world write access is disabled */
@ -420,7 +424,7 @@ ChildNotify (int n)
void
WaitForChild (void)
{
int pid;
pid_t pid;
struct display *d;
waitType status;
#if !defined(X_NOT_POSIX) && !defined(__UNIXOS2__)
@ -455,11 +459,7 @@ WaitForChild (void)
#else
sigsetmask (omask);
#endif
#ifndef X_NOT_POSIX
while ((pid = waitpid (-1, &status, WNOHANG)) > 0)
#else
while ((pid = wait3 (&status, WNOHANG, (struct rusage *) 0)) > 0)
#endif
#endif
{
Debug ("Manager wait returns pid: %d sig %d core %d code %d\n",
@ -624,10 +624,82 @@ StartDisplays (void)
ForEachDisplay (CheckDisplayStatus);
}
static void
SetWindowPath(struct display *d)
{
/* setting WINDOWPATH for clients */
Atom prop;
Atom actualtype;
int actualformat;
unsigned long nitems;
unsigned long bytes_after;
unsigned char *buf;
const char *windowpath;
char *newwindowpath;
unsigned long num;
char nums[10];
int numn;
prop = XInternAtom(d->dpy, "XFree86_VT", False);
if (prop == None) {
fprintf(stderr, "no XFree86_VT atom\n");
return;
}
if (XGetWindowProperty(d->dpy, DefaultRootWindow(d->dpy), prop, 0, 1,
False, AnyPropertyType, &actualtype, &actualformat,
&nitems, &bytes_after, &buf)) {
fprintf(stderr, "no XFree86_VT property\n");
return;
}
if (nitems != 1) {
fprintf(stderr, "%lu items in XFree86_VT property!\n", nitems);
XFree(buf);
return;
}
switch (actualtype) {
case XA_CARDINAL:
case XA_INTEGER:
case XA_WINDOW:
switch (actualformat) {
case 8:
num = (*(uint8_t *)(void *)buf);
break;
case 16:
num = (*(uint16_t *)(void *)buf);
break;
case 32:
num = (*(uint32_t *)(void *)buf);
break;
default:
fprintf(stderr, "format %d in XFree86_VT property!\n", actualformat);
XFree(buf);
return;
}
break;
default:
fprintf(stderr, "type %lx in XFree86_VT property!\n", actualtype);
XFree(buf);
return;
}
XFree(buf);
windowpath = getenv("WINDOWPATH");
numn = snprintf(nums, sizeof(nums), "%lu", num);
if (!windowpath) {
newwindowpath = malloc(numn + 1);
sprintf(newwindowpath, "%s", nums);
} else {
newwindowpath = malloc(strlen(windowpath) + 1 + numn + 1);
sprintf(newwindowpath, "%s:%s", windowpath, nums);
}
if (d->windowPath)
free(d->windowPath);
d->windowPath = newwindowpath;
}
void
StartDisplay (struct display *d)
{
int pid;
pid_t pid;
Debug ("StartDisplay %s\n", d->name);
LoadServerResources (d);
@ -679,6 +751,7 @@ StartDisplay (struct display *d)
SetAuthorization (d);
if (!WaitForServer (d))
exit (OPENFAILED_DISPLAY);
SetWindowPath(d);
#ifdef XDMCP
if (d->useChooser)
RunChooser (d);
@ -697,7 +770,7 @@ StartDisplay (struct display *d)
}
static void
TerminateProcess (int pid, int signal)
TerminateProcess (pid_t pid, int signal)
{
kill (pid, signal);
#ifdef SIGCONT

View File

@ -1,4 +1,4 @@
/* $XdotOrg: xc/programs/xdm/dm.h,v 1.3 2004/12/15 20:49:08 herrb Exp $ */
/* $XdotOrg: app/xdm/dm.h,v 1.5 2005/11/08 06:33:31 jkj Exp $ */
/* $Xorg: dm.h,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
/*
@ -175,8 +175,8 @@ struct display {
/* display state */
DisplayStatus status; /* current status */
int pid; /* process id of child */
int serverPid; /* process id of server (-1 if none) */
pid_t pid; /* process id of child */
pid_t serverPid; /* process id of server (-1 if none) */
FileState state; /* state during HUP processing */
int startTries; /* current start try */
Time_t lastCrash; /* time of last crash */
@ -242,6 +242,8 @@ struct display {
/* Hack for making "Willing to manage" configurable */
char *willing; /* "Willing to manage" program */
Display *dpy; /* Display */
char *windowPath; /* path to server "window" */
};
#ifdef XDMCP
@ -331,8 +333,8 @@ extern int choiceTimeout; /* chooser choice timeout */
extern struct display *FindDisplayByName (char *name),
*FindDisplayBySessionID (CARD32 sessionID),
*FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber),
*FindDisplayByPid (int pid),
*FindDisplayByServerPid (int serverPid),
*FindDisplayByPid (pid_t pid),
*FindDisplayByServerPid (pid_t serverPid),
*NewDisplay (char *name, char *class);
extern struct protoDisplay *FindProtoDisplay (
@ -488,11 +490,7 @@ extern void ProcessRequestSocket(int fd);
#include <stdlib.h>
#if defined(X_NOT_POSIX) && defined(SIGNALRETURNSINT)
#define SIGVAL int
#else
#define SIGVAL void
#endif
#define SIGVAL RETSIGTYPE
#if defined(X_NOT_POSIX) || defined(__UNIXOS2__) || defined(__NetBSD__) && defined(__sparc__)
#if defined(SYSV) || defined(__UNIXOS2__)

View File

@ -50,7 +50,6 @@ extern void LogError (char * fmt, ...) GCC_PRINTFLIKE(1,2);
extern void LogInfo (char * fmt, ...) GCC_PRINTFLIKE(1,2);
extern void LogOutOfMem (char * fmt, ...) GCC_PRINTFLIKE(1,2);
extern void LogPanic (char * fmt, ...) GCC_PRINTFLIKE(1,2);
extern void Panic (char * mesg);
#endif /* _DM_ERROR_H_ */

View File

@ -65,29 +65,29 @@ FindDisplayByName (char *name)
for (d = displays; d; d = d->next)
if (!strcmp (name, d->name))
return d;
return 0;
return NULL;
}
struct display *
FindDisplayByPid (int pid)
FindDisplayByPid (pid_t pid)
{
struct display *d;
for (d = displays; d; d = d->next)
if (pid == d->pid)
return d;
return 0;
return NULL;
}
struct display *
FindDisplayByServerPid (int serverPid)
FindDisplayByServerPid (pid_t serverPid)
{
struct display *d;
for (d = displays; d; d = d->next)
if (serverPid == d->serverPid)
return d;
return 0;
return NULL;
}
#ifdef XDMCP
@ -100,7 +100,7 @@ FindDisplayBySessionID (CARD32 sessionID)
for (d = displays; d; d = d->next)
if (sessionID == d->sessionID)
return d;
return 0;
return NULL;
}
struct display *
@ -115,7 +115,7 @@ FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber)
{
return d;
}
return 0;
return NULL;
}
#endif /* XDMCP */
@ -129,7 +129,7 @@ RemoveDisplay (struct display *old)
char **x;
int i;
p = 0;
p = NULL;
for (d = displays; d; d = d->next) {
if (d == old) {
if (p)
@ -172,6 +172,7 @@ RemoveDisplay (struct display *old)
IfFree (d->from);
XdmcpDisposeARRAY8 (&d->clientAddr);
#endif
IfFree (d->windowPath);
free ((char *) d);
break;
}
@ -184,17 +185,17 @@ NewDisplay (char *name, char *class)
{
struct display *d;
d = (struct display *) malloc (sizeof (struct display));
d = (struct display *) calloc (1, sizeof (struct display));
if (!d) {
LogOutOfMem ("NewDisplay");
return 0;
return NULL;
}
d->next = displays;
d->name = malloc ((unsigned) (strlen (name) + 1));
if (!d->name) {
LogOutOfMem ("NewDisplay");
free ((char *) d);
return 0;
return NULL;
}
strcpy (d->name, name);
if (class)
@ -204,7 +205,7 @@ NewDisplay (char *name, char *class)
LogOutOfMem ("NewDisplay");
free (d->name);
free ((char *) d);
return 0;
return NULL;
}
strcpy (d->class, class);
}
@ -213,7 +214,7 @@ NewDisplay (char *name, char *class)
d->class = (char *) 0;
}
/* initialize every field to avoid possible problems */
d->argv = 0;
d->argv = NULL;
d->status = notRunning;
d->pid = -1;
d->serverPid = -1;
@ -249,9 +250,9 @@ NewDisplay (char *name, char *class)
d->grabTimeout = 0;
#ifdef XDMCP
d->sessionID = 0;
d->peer = 0;
d->peer = NULL;
d->peerlen = 0;
d->from = 0;
d->from = NULL;
d->fromlen = 0;
d->displayNumber = 0;
d->useChooser = 0;
@ -261,6 +262,9 @@ NewDisplay (char *name, char *class)
d->xdmcpFd = -1;
#endif
d->version = 1; /* registered with The Open Group */
d->willing = NULL;
d->dpy = NULL;
d->windowPath = NULL;
displays = d;
return d;
}

View File

@ -104,17 +104,6 @@ void LogOutOfMem (char * fmt, ...)
fflush (stderr);
}
void Panic (char *mesg)
{
int i;
i = creat ("/dev/console", 0666);
write (i, "panic: ", 7);
write (i, mesg, strlen (mesg));
exit (1);
}
void Debug (char * fmt, ...)
{
char buf[1024];

View File

@ -65,7 +65,7 @@ splitIntoWords (char *s)
char *wordStart;
int nargs;
args = 0;
args = NULL;
nargs = 0;
while (*s)
{
@ -234,7 +234,7 @@ static struct displayMatch {
} displayTypes[] = {
{ "local", { Local, Permanent, FromFile } },
{ "foreign", { Foreign, Permanent, FromFile } },
{ 0, { Local, Permanent, FromFile } },
{ NULL, { Local, Permanent, FromFile } },
};
DisplayType

View File

@ -78,10 +78,12 @@ struct dlfuncs {
void (*_endgrent)(void); /* no longer used */
#ifdef USESHADOW
struct spwd *(*_getspnam)(GETSPNAM_ARGS);
# ifndef QNX4
void (*_endspent)(void);
# endif /* QNX4 doesn't use endspent */
#endif
struct passwd *(*_getpwnam)(GETPWNAM_ARGS);
#ifdef linux
#if defined(linux) || defined(__GLIBC__)
void (*_endpwent)(void);
#endif
char *(*_crypt)(CRYPT_ARGS);
@ -160,10 +162,12 @@ extern struct group *(*__xdm_getgrent)(void);
extern void (*__xdm_endgrent)(void);
#ifdef USESHADOW
extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS);
# ifndef QNX4
extern void (*__xdm_endspent)(void);
# endif /* QNX4 doesn't use endspent */
#endif
extern struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS);
#ifdef linux
#if defined(linux) || defined(__GLIBC__)
extern void (*__xdm_endpwent)(void);
#endif
extern char *(*__xdm_crypt)(CRYPT_ARGS);
@ -199,14 +203,18 @@ extern pam_handle_t **(*__xdm_thepamhp)(void);
#define getgrent (*__xdm_getgrent)
#define endgrent (*__xdm_endgrent)
#ifdef USESHADOW
#define getspnam (*__xdm_getspnam)
#define endspent (*__xdm_endspent)
#endif
#ifdef linux
#define endpwent (*__xdm_endpwent)
# define getspnam (*__xdm_getspnam)
# ifndef QNX4
# define endspent (*__xdm_endspent)
# endif /* QNX4 doesn't use endspent */
#endif
#define getpwnam (*__xdm_getpwnam)
#if defined(linux) || defined(__GLIBC__)
# define endpwent (*__xdm_endpwent)
#endif
#define crypt (*__xdm_crypt)
#define thepamhp (*__xdm_thepamhp)
#ifdef USE_PAM
# define thepamhp (*__xdm_thepamhp)
#endif
#endif /* GREET_LIB */

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
/* $XdotOrg: $ */
/* $Xorg: Login.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/*
@ -26,6 +27,33 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* 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.
*/
/* $XFree86: xc/programs/xdm/greeter/Login.h,v 3.7 2002/10/06 20:42:16 herrb Exp $ */
/*
@ -71,6 +99,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,6 +109,11 @@ from The Open Group.
# define XtNallowNullPasswd "allowNullPasswd"
# define XtNallowRootLogin "allowRootLogin"
# define XtNface "face"
# define XtCFace "Face"
# define XtRXftFont "XftFont"
# define XtRXftColor "XftColor"
#ifdef XPM
/* added by Amit Margalit Oct 1996 */
# define XtNhiColor "hiColor"
@ -112,23 +148,45 @@ 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
# include <sys/param.h>
#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)
#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 {
@ -145,5 +203,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 */

View File

@ -1,3 +1,4 @@
/* $XdotOrg: $ */
/* $Xorg: LoginP.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/*
@ -26,7 +27,34 @@ 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.
*/
/* $XFree86: xc/programs/xdm/greeter/LoginP.h,v 3.8 2001/12/14 20:01:29 dawes Exp $ */
/*
* xdm - display manager daemon
@ -37,23 +65,44 @@ from The Open Group.
#define _LoginP_h
#include "Login.h"
#include <X11/IntrinsicP.h>
#include <X11/CoreP.h>
#ifdef XPM
#include <X11/Xlib.h>
#endif /* XPM */
#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 */
#endif
#ifdef XPM
Pixel hipixel; /* frame hilite pixel */
Pixel shdpixel; /* shadow frame pixel */
@ -61,9 +110,11 @@ typedef struct {
GC textGC; /* pointer to GraphicsContext */
GC bgGC; /* pointer to GraphicsContext */
GC xorGC; /* pointer to GraphicsContext */
#ifndef USE_XFT
GC promptGC;
GC greetGC;
GC failGC;
#endif
#ifdef XPM
GC hiGC; /* for hilight part of frame */
GC shdGC; /* for shaded part of frame */
@ -72,13 +123,17 @@ typedef struct {
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,6 +145,8 @@ 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 */
loginPromptData prompts[NUM_PROMPTS];
time_t msgTimeout;
#ifdef XPM
/*caolan begin*/
int lastEventTime;
@ -105,6 +162,17 @@ typedef struct {
Boolean useShape, logoValid;
Pixmap logoPixmap, logoMask;
#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 */

View File

@ -16,3 +16,12 @@ AM_CFLAGS = $(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) $(AM_CFLAGS)
lint:
$(LINT) $(ALL_LINT_FLAGS) $(libXdmGreet_la_SOURCES)
endif LINT

View File

@ -1,5 +1,5 @@
/* $Xorg: greet.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/* $XdotOrg: $ */
/* $XdotOrg: app/xdm/greeter/greet.c,v 1.5 2006/06/03 01:13:44 alanc Exp $ */
/*
Copyright 1988, 1998 The Open Group
@ -27,6 +27,34 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* 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.
*/
/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.16tsi Exp $ */
/*
@ -93,10 +121,12 @@ struct group *(*__xdm_getgrent)(void) = NULL;
void (*__xdm_endgrent)(void) = NULL;
#ifdef USESHADOW
struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL;
# ifndef QNX4
void (*__xdm_endspent)(void) = NULL;
# 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
char *(*__xdm_crypt)(CRYPT_ARGS) = NULL;
@ -118,12 +148,34 @@ pam_handle_t **(*__xdm_thepamhp)(void) = NULL;
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 +202,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 +227,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 +242,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 +253,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,6 +375,7 @@ 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;
@ -334,6 +394,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));
@ -355,11 +416,13 @@ FailedLogin (struct display *d, struct greet_info *greet)
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,
@ -397,10 +460,12 @@ greet_user_rtn GreetUser(
__xdm_endgrent = dlfuncs->_endgrent;
#ifdef USESHADOW
__xdm_getspnam = dlfuncs->_getspnam;
# ifndef QNX4
__xdm_endspent = dlfuncs->_endspent;
# endif /* QNX4 doesn't use endspent */
#endif
__xdm_getpwnam = dlfuncs->_getpwnam;
#ifdef linux
#if defined(linux) || defined(__GLIBC__)
__xdm_endpwent = dlfuncs->_endpwent;
#endif
__xdm_crypt = dlfuncs->_crypt;
@ -423,7 +488,110 @@ greet_user_rtn GreetUser(
#ifdef __OpenBSD__
openlog("xdm", LOG_ODELAY, LOG_AUTH);
#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 {
RUN_AND_CHECK_PAM_ERROR(pam_end,
(*pamhp, pam_error));
FailedLogin (d, greet);
}
#else /* not PAM */
/*
* Greet user, requesting name/password
*/
@ -440,6 +608,7 @@ greet_user_rtn GreetUser(
break;
else
FailedLogin (d, greet);
#endif
}
DeleteXloginResources (d, *dpy);
CloseGreet (d);
@ -496,3 +665,104 @@ greet_user_rtn GreetUser(
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 = *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

View File

@ -1,5 +1,5 @@
/* $Xorg: verify.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/* $XdotOrg: app/xdm/greeter/verify.c,v 1.8 2006/04/14 20:17:31 alanc Exp $ */
/* $XdotOrg: app/xdm/greeter/verify.c,v 1.9 2006/06/03 00:05:24 alanc Exp $ */
/*
Copyright 1988, 1998 The Open Group
@ -120,77 +120,8 @@ userEnv (struct display *d, int useSystemPath, char *user, char *home, char *she
return env;
}
#ifdef USE_PAM
static char *PAM_password;
static int pam_error;
static int PAM_conv (int num_msg,
#ifdef sun
struct pam_message **msg,
#else
const struct pam_message **msg,
#endif
struct pam_response **resp,
void *appdata_ptr) {
int count = 0, replies = 0;
struct pam_response *reply = NULL;
#define PAM_RESPONSE_SIZE sizeof(struct pam_response)
size_t size = PAM_RESPONSE_SIZE;
#define COPY_STRING(s) (s) ? strdup(s) : (char*)NULL
for (count = 0; count < num_msg; count++) {
switch (msg[count]->msg_style) {
case PAM_PROMPT_ECHO_ON:
/* user name given to PAM already */
return PAM_CONV_ERR;
case PAM_PROMPT_ECHO_OFF:
/* wants password */
if (reply) {
void *r2 = reply;
if (! (reply = realloc(reply, size))) {
free (r2);
return PAM_CONV_ERR;
}
bzero(reply + size - PAM_RESPONSE_SIZE, PAM_RESPONSE_SIZE);
} else {
if (! (reply = (struct pam_response*)malloc(size)))
return PAM_CONV_ERR;
bzero(reply, size);
}
if (!reply)
return PAM_CONV_ERR;
size += PAM_RESPONSE_SIZE;
reply[replies].resp_retcode = PAM_SUCCESS;
reply[replies].resp = COPY_STRING(PAM_password);
/* PAM frees resp */
break;
case PAM_TEXT_INFO:
/* ignore the informational mesage */
break;
default:
/* unknown or PAM_ERROR_MSG */
if (reply) free (reply);
return PAM_CONV_ERR;
}
}
#undef COPY_STRING
if (reply) *resp = reply;
return PAM_SUCCESS;
}
static struct pam_conv PAM_conversation = {
PAM_conv,
NULL
};
#endif /* USE_PAM */
#ifdef USE_BSDAUTH
_X_INTERNAL
int
Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
{
@ -305,6 +236,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
*/
struct smp_user_info *userp = 0;
_X_INTERNAL
int
Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
{
@ -391,13 +323,12 @@ smp_fail:
}
}
#else /* !USE_BSDAUTH && !USESECUREWARE */
_X_INTERNAL
int
Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
{
struct passwd *p;
#ifdef USE_PAM
pam_handle_t **pamhp = thepamhp();
#else
#ifndef USE_PAM
#ifdef USESHADOW
struct spwd *sp;
#endif
@ -417,7 +348,8 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
if (!p || strlen (greet->name) == 0) {
Debug ("getpwnam() failed.\n");
bzero(greet->password, strlen(greet->password));
if (greet->password != NULL)
bzero(greet->password, strlen(greet->password));
return 0;
}
@ -448,11 +380,12 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
(strncmp(d->name,":0",2) != 0) )
{
Debug("Not on system console\n");
bzero(greet->password, strlen(greet->password));
XFree(console);
if (greet->password != NULL)
bzero(greet->password, strlen(greet->password));
free(console);
return 0;
}
XFree(console);
free(console);
}
else
{
@ -461,7 +394,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
}
#endif
#ifndef USE_PAM
#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");
@ -470,7 +403,6 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
}
#endif
user_pass = p->pw_passwd;
#endif
#ifdef KERBEROS
if(strcmp(greet->name, "root") != 0){
char name[ANAME_SZ];
@ -510,7 +442,6 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
}
}
#endif
#ifndef USE_PAM
#ifdef USESHADOW
errno = 0;
sp = getspnam(greet->name);
@ -522,7 +453,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
#ifndef QNX4
endspent();
#endif /* QNX4 doesn't need endspent() to end shadow passwd ops */
#endif
#endif /* USESHADOW */
#if defined(ultrix) || defined(__ultrix__)
if (authenticate_user(p, greet->password, NULL) < 0)
#else
@ -588,40 +519,6 @@ done:
#endif /* __OpenBSD__ */
bzero(user_pass, strlen(user_pass)); /* in case shadow password */
#else /* USE_PAM */
#define PAM_BAIL \
if (pam_error != PAM_SUCCESS) goto pam_failed;
PAM_password = greet->password;
pam_error = pam_start("xdm", greet->name, &PAM_conversation, pamhp);
PAM_BAIL;
pam_error = pam_set_item(*pamhp, PAM_TTY, d->name);
PAM_BAIL;
pam_error = pam_set_item(*pamhp, PAM_RHOST, "");
PAM_BAIL;
pam_error = pam_authenticate(*pamhp, 0);
PAM_BAIL;
pam_error = pam_acct_mgmt(*pamhp, 0);
/* really should do password changing, but it doesn't fit well */
PAM_BAIL;
pam_error = pam_setcred(*pamhp, 0);
PAM_BAIL;
p = getpwnam (greet->name);
endpwent();
if (!p || strlen (greet->name) == 0) {
Debug ("getpwnam() failed.\n");
bzero(greet->password, strlen(greet->password));
return 0;
}
if (pam_error != PAM_SUCCESS) {
pam_failed:
pam_end(*pamhp, PAM_SUCCESS);
*pamhp = NULL;
return 0;
}
#undef PAM_BAIL
#endif /* USE_PAM */
#endif /* USE_BSDAUTH */
@ -632,7 +529,7 @@ done:
verify->gid = p->pw_gid;
home = p->pw_dir;
shell = p->pw_shell;
argv = 0;
argv = NULL;
if (d->session)
argv = parseArgs (argv, d->session);
if (greet->string)

View File

@ -64,9 +64,9 @@ MitGetAuth (unsigned short namelen, char *name)
return (Xauth *) 0;
new->family = FamilyWild;
new->address_length = 0;
new->address = 0;
new->address = NULL;
new->number_length = 0;
new->number = 0;
new->number = NULL;
new->data = (char *) malloc (AUTH_DATA_LEN);
if (!new->data)

View File

@ -170,7 +170,7 @@ Accept (
int fromlen,
CARD16 displayNumber)
{
return 0;
return NULL;
}
/*ARGSUSED*/

View File

@ -142,7 +142,7 @@ DisposeProtoDisplay (pdpy)
{
struct protoDisplay *p, *prev;
prev = 0;
prev = NULL;
for (p = protoDisplays; p; p=p->next)
{
if (p == pdpy)

View File

@ -468,7 +468,7 @@ ReinitResources (void)
LogPanic ("no space for argument realloc\n");
for (argc = 0; argc < originalArgc; argc++)
argv[argc] = originalArgv[argc];
argv[argc] = 0;
argv[argc] = NULL;
if (DmResourceDB)
XrmDestroyDatabase (DmResourceDB);
DmResourceDB = XrmGetStringDatabase ("");

View File

@ -1,3 +1,4 @@
/* $XdotOrg: $ */
/* $Xorg: server.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $ */
/*
@ -48,9 +49,7 @@ from The Open Group.
static int receivedUsr1;
static int serverPause (unsigned t, int serverPid);
static Display *dpy;
static int serverPause (unsigned t, pid_t serverPid);
/* ARGSUSED */
static SIGVAL
@ -78,7 +77,7 @@ StartServerOnce (struct display *d)
char **f;
char **argv;
char arg[1024];
int pid;
pid_t pid;
Debug ("StartServer for %s\n", d->name);
receivedUsr1 = 0;
@ -169,9 +168,9 @@ serverPauseUsr1 (int n)
}
static int
serverPause (unsigned t, int serverPid)
serverPause (unsigned t, pid_t serverPid)
{
int pid;
pid_t pid;
serverPauseRet = 0;
if (!Setjmp (pauseAbort)) {
@ -189,31 +188,16 @@ serverPause (unsigned t, int serverPid)
Debug ("Already received USR1\n");
#endif
for (;;) {
#if defined(SYSV) && defined(X_NOT_POSIX)
/*
* wait() is unsafe. Other Xserver or xdm processes may
* exit at this time and this will remove the wait status.
* This means the main loop will not restart the display.
*/
pid = wait ((waitType *) 0);
#else
if (!receivedUsr1)
#ifndef X_NOT_POSIX
pid = waitpid (serverPid, (int *) 0, 0);
else
pid = waitpid (serverPid, (int *) 0, WNOHANG);
#else
/*
* If you have wait4() but not waitpid(), use that instead
* of wait() and wait3() to make this code safe. See
* above comment.
*/
pid = wait ((waitType *) 0);
else
pid = wait3 ((waitType *) 0, WNOHANG,
(struct rusage *) 0);
#endif /* X_NOT_POSIX */
#endif /* SYSV */
if (pid == serverPid ||
(pid == -1 && errno == ECHILD))
{
@ -221,12 +205,11 @@ serverPause (unsigned t, int serverPid)
serverPauseRet = 1;
break;
}
#if !defined(SYSV) || !defined(X_NOT_POSIX)
if (pid == 0) {
Debug ("Server alive and kicking\n");
break;
}
#endif
}
}
(void) alarm ((unsigned) 0);
@ -319,7 +302,7 @@ WaitForServer (struct display *d)
Debug ("Before XOpenDisplay(%s)\n", d->name);
errno = 0;
(void) XSetIOErrorHandler (openErrorHandler);
dpy = XOpenDisplay (d->name);
d->dpy = XOpenDisplay (d->name);
#ifdef STREAMSCONN
{
/* For some reason, the next XOpenDisplay we do is
@ -335,13 +318,13 @@ WaitForServer (struct display *d)
(void) Signal (SIGALRM, SIG_DFL);
(void) XSetIOErrorHandler ((int (*)(Display *)) 0);
Debug ("After XOpenDisplay(%s)\n", d->name);
if (dpy) {
if (d->dpy) {
#ifdef XDMCP
if (d->displayType.location == Foreign)
GetRemoteAddress (d, ConnectionNumber (dpy));
GetRemoteAddress (d, ConnectionNumber (d->dpy));
#endif
RegisterCloseOnFork (ConnectionNumber (dpy));
(void) fcntl (ConnectionNumber (dpy), F_SETFD, 0);
RegisterCloseOnFork (ConnectionNumber (d->dpy));
(void) fcntl (ConnectionNumber (d->dpy), F_SETFD, 0);
return 1;
} else {
Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
@ -364,8 +347,8 @@ WaitForServer (struct display *d)
void
ResetServer (struct display *d)
{
if (dpy && d->displayType.origin != FromXDMCP)
pseudoReset (dpy);
if (d->dpy && d->displayType.origin != FromXDMCP)
pseudoReset (d->dpy);
}
static Jmp_buf pingTime;
@ -399,7 +382,7 @@ PingServer (struct display *d, Display *alternateDpy)
int oldAlarm;
static Display *aDpy;
aDpy = (alternateDpy != NULL ? alternateDpy : dpy);
aDpy = (alternateDpy != NULL ? alternateDpy : d->dpy);
oldError = XSetIOErrorHandler (PingLostIOErr);
oldAlarm = alarm (0);
oldSig = Signal (SIGALRM, PingLostSig);

View File

@ -1,4 +1,4 @@
/* $XdotOrg: app/xdm/session.c,v 1.6 2006/04/08 00:22:23 alanc Exp $ */
/* $XdotOrg: app/xdm/session.c,v 1.7 2006-06-03 00:05:24 alanc Exp $ */
/* $Xorg: session.c,v 1.8 2001/02/09 02:05:40 xorgcvs Exp $ */
/*
@ -52,6 +52,8 @@ from The Open Group.
#ifdef AIXV3
# include <usersec.h>
#endif
#ifndef USE_PAM /* PAM modules should handle these */
#ifdef SECURE_RPC
# include <rpc/rpc.h>
# include <rpc/key_prot.h>
@ -62,6 +64,7 @@ extern int key_setnet(struct key_netstarg *arg);
#ifdef K5AUTH
# include <krb5/krb5.h>
#endif
#endif /* USE_PAM */
#ifdef __SCO__
#include <prot.h>
@ -168,11 +171,11 @@ static struct dlfuncs dlfuncs = {
static Bool StartClient(
struct verify_info *verify,
struct display *d,
int *pidp,
pid_t *pidp,
char *name,
char *passwd);
static int clientPid;
static pid_t clientPid;
static struct greet_info greet;
static struct verify_info verify;
@ -208,11 +211,11 @@ waitAbort (int n)
#endif
static void
AbortClient (int pid)
AbortClient (pid_t pid)
{
int sig = SIGTERM;
volatile int i;
int retId;
pid_t retId;
for (i = 0; i < 4; i++) {
if (killpg (pid, sig) == -1) {
@ -278,7 +281,7 @@ ErrorHandler(Display *dpy, XErrorEvent *event)
void
ManageSession (struct display *d)
{
static int pid = 0;
static pid_t pid = 0;
Display *dpy;
greet_user_rtn greet_stat;
static GreetUserProc greet_user_proc = NULL;
@ -379,7 +382,7 @@ void
LoadXloginResources (struct display *d)
{
char **args;
char **env = 0;
char **env = NULL;
if (d->resources[0] && access (d->resources, 4) == 0) {
env = systemEnv (d, (char *) 0, (char *) 0);
@ -395,7 +398,7 @@ LoadXloginResources (struct display *d)
void
SetupDisplay (struct display *d)
{
char **env = 0;
char **env = NULL;
if (d->setup && d->setup[0]) {
env = systemEnv (d, (char *) 0, (char *) 0);
@ -473,9 +476,8 @@ void
SessionExit (struct display *d, int status, int removeAuth)
{
#ifdef USE_PAM
pam_handle_t *pamh = thepamh();
#endif
#ifdef USE_PAM
pam_handle_t *pamh = thepamh();
if (pamh) {
/* shutdown PAM session */
pam_close_session(pamh, 0);
@ -490,10 +492,16 @@ SessionExit (struct display *d, int status, int removeAuth)
else
ResetServer (d);
if (removeAuth) {
setgid (verify.gid);
setuid (verify.uid);
if (setgid (verify.gid) == -1) {
LogError( "SessionExit: setgid: %s\n", strerror(errno));
exit(status);
}
if (setuid (verify.uid) == -1) {
LogError( "SessionExit: setuid: %s\n", strerror(errno));
exit(status);
}
RemoveUserAuthorization (d, &verify);
#ifdef K5AUTH
#if defined(K5AUTH) && !defined(USE_PAM) /* PAM modules should handle this */
/* do like "kdestroy" program */
{
krb5_error_code code;
@ -526,13 +534,13 @@ static Bool
StartClient (
struct verify_info *verify,
struct display *d,
int *pidp,
pid_t *pidp,
char *name,
char *passwd)
{
char **f, *home;
char *failsafeArgv[2];
int pid;
pid_t pid;
#ifdef HAS_SETUSERCONTEXT
struct passwd* pwd;
#endif
@ -673,6 +681,7 @@ StartClient (
}
#endif /* AIXV3 */
#ifndef USE_PAM /* PAM modules should handle these */
/*
* for user-based authorization schemes,
* use the password to get the user's credentials.
@ -759,7 +768,14 @@ StartClient (
}
}
#endif /* K5AUTH */
bzero(passwd, strlen(passwd));
#endif /* !USE_PAM */
if (d->windowPath)
verify->userEnviron = setEnv(verify->userEnviron, "WINDOWPATH", d->windowPath);
if (passwd != NULL)
bzero(passwd, strlen(passwd));
SetUserAuthorization (d, verify);
home = getEnv (verify->userEnviron, "HOME");
if (home)
@ -777,17 +793,19 @@ StartClient (
LogError ("Session has no command/arguments\n");
}
failsafeArgv[0] = d->failsafeClient;
failsafeArgv[1] = 0;
failsafeArgv[1] = NULL;
execute (failsafeArgv, verify->userEnviron);
exit (1);
case -1:
bzero(passwd, strlen(passwd));
if (passwd != NULL)
bzero(passwd, strlen(passwd));
Debug ("StartSession, fork failed\n");
LogError ("can't start session on \"%s\", fork failed, errno=%d\n",
d->name, errno);
return 0;
default:
bzero(passwd, strlen(passwd));
if (passwd != NULL)
bzero(passwd, strlen(passwd));
Debug ("StartSession, fork succeeded %d\n", pid);
*pidp = pid;
return 1;
@ -818,7 +836,7 @@ source (char **environ, char *file)
static int
runAndWait (char **args, char **environ)
{
int pid;
pid_t pid;
waitType result;
switch (pid = fork ()) {
@ -891,10 +909,10 @@ execute (char **argv, char **environ)
++optarg;
while (*optarg && isspace (*optarg));
} else
optarg = 0;
optarg = NULL;
} else {
p = "/bin/sh";
optarg = 0;
optarg = NULL;
}
Debug ("Shell script execution: %s (optarg %s)\n",
p, optarg ? optarg : "(null)");
@ -921,7 +939,7 @@ defaultEnv (void)
{
char **env, **exp, *value;
env = 0;
env = NULL;
for (exp = exportList; exp && *exp; ++exp) {
value = getenv (*exp);
if (value)
@ -947,6 +965,8 @@ systemEnv (struct display *d, char *user, char *home)
env = setEnv (env, "SHELL", d->systemShell);
if (d->authFile)
env = setEnv (env, "XAUTHORITY", d->authFile);
if (d->windowPath)
env = setEnv (env, "WINDOWPATH", d->windowPath);
return env;
}

View File

@ -1,4 +1,4 @@
/* $XdotOrg: app/xdm/socket.c,v 1.6 2006/03/11 04:07:00 alanc Exp $ */
/* $XdotOrg: app/xdm/socket.c,v 1.5 2006/03/10 00:48:16 alanc Exp $ */
/* $Xorg: socket.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */
/*

View File

@ -72,7 +72,7 @@ makeEnv (char *name, char *value)
result = malloc ((unsigned) (strlen (name) + strlen (value) + 2));
if (!result) {
LogOutOfMem ("makeEnv");
return 0;
return NULL;
}
sprintf (result, "%s=%s", name, value);
return result;
@ -83,7 +83,7 @@ getEnv (char **e, char *name)
{
int l = strlen (name);
if (!e) return 0;
if (!e) return NULL;
while (*e) {
if ((int)strlen (*e) > l && !strncmp (*e, name, l) &&
@ -91,7 +91,7 @@ getEnv (char **e, char *name)
return (*e) + l + 1;
++e;
}
return 0;
return NULL;
}
char **
@ -130,7 +130,7 @@ setEnv (char **e, char *name, char *value)
return e;
}
new[envsize] = newe;
new[envsize+1] = 0;
new[envsize+1] = NULL;
return new;
}
@ -189,7 +189,7 @@ parseArgs (char **argv, char *string)
argv = (char **) malloc (sizeof (char *));
if (!argv) {
LogOutOfMem ("parseArgs");
return 0;
return NULL;
}
}
word = string;
@ -204,7 +204,7 @@ parseArgs (char **argv, char *string)
free ((char *) argv);
if (save)
free (save);
return 0;
return NULL;
} else {
argv = newargv;
}
@ -218,7 +218,7 @@ parseArgs (char **argv, char *string)
}
++string;
}
argv[i] = 0;
argv[i] = NULL;
return argv;
}
@ -265,14 +265,14 @@ localHostname (void)
SIGVAL (*Signal (int sig, SIGFUNC handler))(int)
{
#if !defined(X_NOT_POSIX) && !defined(__UNIXOS2__)
#ifdef HAVE_SIGACTION
struct sigaction sigact, osigact;
sigact.sa_handler = handler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(sig, &sigact, &osigact);
return osigact.sa_handler;
#else
#else /* __UNIXOS2__ */
return signal(sig, handler);
#endif
}

View File

@ -1,4 +1,4 @@
.\" $XdotOrg: app/xdm/xdm.man.cpp,v 1.5 2005/10/18 02:12:17 alanc Exp $
.\" $XdotOrg: xc/programs/xdm/xdm.man,v 1.3 2004/07/26 22:56:33 herrb Exp $
.\" $Xorg: xdm.man,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $
.\" Copyright 1988, 1994, 1998 The Open Group
.\"
@ -1092,6 +1092,7 @@ the following environment variables are passed:
PATH the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemPath\fP
SHELL the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemShell\fP
XAUTHORITY may be set to an authority file
WINDOWPATH may be set to the "window path" leading to the X server
.fi
.PP
@ -1146,6 +1147,7 @@ the following environment variables are passed:
SHELL the user's default shell (from \fIgetpwnam\fP)
XAUTHORITY may be set to a non-standard authority file
KRB5CCNAME may be set to a Kerberos credentials cache name
WINDOWPATH may be set to the "window path" leading to the X server
.fi
.PP

View File

@ -92,9 +92,9 @@ XdmGetAuthHelper (unsigned short namelen, char *name, int includeRho)
return (Xauth *) 0;
new->family = FamilyWild;
new->address_length = 0;
new->address = 0;
new->address = NULL;
new->number_length = 0;
new->number = 0;
new->number = NULL;
if (includeRho)
new->data_length = 16;
else

View File

@ -1,4 +1,4 @@
/* $XdotOrg: xc/programs/xdm/xdmcp.c,v 1.4 2004/08/07 19:22:01 alanc Exp $ */
/* $XdotOrg: app/xdm/xdmcp.c,v 1.6 2006/06/20 01:50:35 alanc Exp $ */
/* $Xorg: xdmcp.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/*
@ -413,7 +413,7 @@ WaitForSomething (void)
Debug ("WaitForSomething\n");
if (AnyWellKnownSockets () && !ChildReady) {
reads = WellKnownSocketsMask;
nready = select (WellKnownSocketsMax + 1, &reads, 0, 0, 0);
nready = select (WellKnownSocketsMax + 1, &reads, NULL, NULL, NULL);
Debug ("select returns %d. Rescan: %d ChildReady: %d\n",
nready, Rescan, ChildReady);
if (nready > 0)
@ -578,8 +578,11 @@ NetworkAddressToName(
{
if (!strcmp (localhost, hostname))
{
if (!getString (name, 10))
return 0;
if (!getString (name, 10)) {
if (ai)
freeaddrinfo(ai);
return NULL;
}
sprintf (name, ":%d", displayNumber);
}
else
@ -605,15 +608,21 @@ NetworkAddressToName(
}
}
if (!getString (name, strlen (hostname) + 10))
return 0;
if (!getString (name, strlen (hostname) + 10)) {
if (ai)
freeaddrinfo(ai);
return NULL;
}
sprintf (name, "%s:%d", hostname, displayNumber);
}
}
else
{
if (!getString (name, INET6_ADDRSTRLEN + 10))
return 0;
if (!getString (name, INET6_ADDRSTRLEN + 10)) {
if (ai)
freeaddrinfo(ai);
return NULL;
}
if (multiHomed) {
if (connectionType == FamilyInternet) {
data = (CARD8 *)
@ -626,7 +635,9 @@ NetworkAddressToName(
}
if (inet_ntop(type, data, name, INET6_ADDRSTRLEN) == NULL) {
free(name);
return 0;
if (ai)
freeaddrinfo(ai);
return NULL;
}
sprintf(name + strlen(name), ":%d", displayNumber);
}
@ -734,11 +745,11 @@ forward_respond (
Debug ("Forward respond %d\n", length);
clientAddress.length = 0;
clientAddress.data = 0;
clientAddress.data = NULL;
clientPort.length = 0;
clientPort.data = 0;
clientPort.data = NULL;
authenticationNames.length = 0;
authenticationNames.data = 0;
authenticationNames.data = NULL;
if (XdmcpReadARRAY8 (&buffer, &clientAddress) &&
XdmcpReadARRAY8 (&buffer, &clientPort) &&
XdmcpReadARRAYofARRAY8 (&buffer, &authenticationNames))
@ -801,7 +812,7 @@ forward_respond (
in6_addr.sin6_len = sizeof(in6_addr);
#endif
in6_addr.sin6_family = AF_INET6;
memmove(&in6_addr,clientAddress.data,clientAddress.length);
memmove(&in6_addr.sin6_addr,clientAddress.data,clientAddress.length);
memmove((char *) &in6_addr.sin6_port, clientPort.data, 2);
client = (struct sockaddr *) &in6_addr;
clientlen = sizeof (in6_addr);
@ -916,7 +927,7 @@ void init_session_id(void)
* incarnation so we don't say "Alive" to those displays.
* Start with low digits 0 to make debugging easier.
*/
globalSessionID = (time((Time_t)0)&0x7fff) * 16000;
globalSessionID = (time((Time_t *)0)&0x7fff) * 16000;
}
static ARRAY8 outOfMemory = { (CARD16) 13, (CARD8Ptr) "Out of memory" };
@ -938,29 +949,30 @@ request_respond (
ARRAY8 authenticationData;
ARRAYofARRAY8 authorizationNames;
ARRAY8 manufacturerDisplayID;
ARRAY8Ptr reason = 0;
ARRAY8Ptr reason = NULL;
int expectlen;
int i, j;
struct protoDisplay *pdpy;
struct protoDisplay *pdpy = NULL;
ARRAY8 authorizationName, authorizationData;
ARRAY8Ptr connectionAddress;
Debug ("Request respond %d\n", length);
connectionTypes.length = 0;
connectionTypes.data = 0;
connectionTypes.data = NULL;
connectionAddresses.length = 0;
connectionAddresses.data = 0;
connectionAddresses.data = NULL;
authenticationName.length = 0;
authenticationName.data = 0;
authenticationName.data = NULL;
authenticationData.length = 0;
authenticationData.data = 0;
authenticationData.data = NULL;
authorizationNames.length = 0;
authorizationNames.data = 0;
authorizationNames.data = NULL;
authorizationName.length = 0;
authorizationName.data = 0;
authorizationName.data = NULL;
authorizationData.length = 0;
authorizationData.data = 0;
manufacturerDisplayID.data = 0;
authorizationData.data = NULL;
manufacturerDisplayID.length = 0;
manufacturerDisplayID.data = NULL;
if (XdmcpReadCARD16 (&buffer, &displayNumber) &&
XdmcpReadARRAY16 (&buffer, &connectionTypes) &&
XdmcpReadARRAYofARRAY8 (&buffer, &connectionAddresses) &&
@ -990,7 +1002,6 @@ request_respond (
connectionAddresses.length != connectionTypes.length)
{
reason = &noValidAddr;
pdpy = 0;
goto decline;
}
pdpy = FindProtoDisplay ((XdmcpNetaddr) from, fromlen, displayNumber);
@ -1157,7 +1168,7 @@ manage (
CARD16 connectionType;
Debug ("Manage %d\n", length);
displayClass.data = 0;
displayClass.data = NULL;
displayClass.length = 0;
if (XdmcpReadCARD32 (&buffer, &sessionID) &&
XdmcpReadCARD16 (&buffer, &displayNumber) &&
@ -1283,7 +1294,7 @@ manage (
}
d->authorizations[0] = pdpy->fileAuthorization;
d->authNum = 1;
pdpy->fileAuthorization = 0;
pdpy->fileAuthorization = NULL;
}
DisposeProtoDisplay (pdpy);
Debug ("Starting display %s,%s\n", d->name, d->class);
@ -1434,20 +1445,28 @@ NetworkAddressToHostname (
struct addrinfo *ai = NULL, *nai;
if (getaddrinfo(hostent->h_name, NULL, NULL, &ai) == 0) {
for (nai = ai; nai != NULL; nai = nai->ai_next) {
if ((af_type == nai->ai_family) &&
(connectionAddress->length == nai->ai_addrlen) &&
(memcmp(connectionAddress->data,nai->ai_addr,
nai->ai_addrlen) == 0) ) {
if ((af_type == nai->ai_family) && (
((nai->ai_family == AF_INET) &&
(connectionAddress->length == sizeof(struct in_addr)) &&
(memcmp(connectionAddress->data,
&((struct sockaddr_in *)nai->ai_addr)->sin_addr,
connectionAddress->length) == 0)) ||
((nai->ai_family == AF_INET6) &&
(connectionAddress->length == sizeof(struct in6_addr)) &&
(memcmp(connectionAddress->data,
&((struct sockaddr_in6 *)nai->ai_addr)->sin6_addr,
connectionAddress->length) == 0))))
break;
}
}
if (ai == NULL) {
if (nai == NULL) {
inet_ntop(af_type, connectionAddress->data,
dotted, sizeof(dotted));
LogError("Possible DNS spoof attempt %s->%s.", dotted,
LogError("Possible DNS spoof attempt %s->%s.\n", dotted,
hostent->h_name);
hostent = NULL;
} else {
local_name = hostent->h_name;
}
freeaddrinfo(ai);
} else {
@ -1458,7 +1477,7 @@ NetworkAddressToHostname (
if ((hostent = gethostbyname(s))) {
if (memcmp((char*)connectionAddress->data, hostent->h_addr,
hostent->h_length) != 0) {
LogError("Possible DNS spoof attempt.");
LogError("Possible DNS spoof attempt.\n");
hostent = NULL; /* so it enters next if() */
} else {
local_name = hostent->h_name;

View File

@ -71,7 +71,7 @@ static int exec_args (
char *filename,
char **args)
{
int pid;
pid_t pid;
waitType status;
if (!filename) return -1;
@ -183,7 +183,11 @@ main (
#endif
/* make xdm run in a non-setuid environment */
setuid (geteuid());
if (setuid (geteuid()) == -1) {
fprintf(stderr, "%s: cannot setuid (error %d, %s)\r\n",
ProgramName, errno, strerror(errno));
exit(1);
}
/*
* exec /usr/bin/X11/xdm -nodaemon -udpPort 0