summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
commit6c29c43354706a933c0bc73a9c800bdfd1a9a827 (patch)
tree37ab6c9430469a3d73ea08c12cfeda668dcb1a34
parentfa5d4a38a4dae7f24cdf3b8650dd931294c0fdc6 (diff)
-rw-r--r--Chooser.ad4
-rw-r--r--access.c156
-rw-r--r--auth.c372
-rw-r--r--choose.c159
-rw-r--r--chooser.c351
-rw-r--r--config/Xaccess6
-rw-r--r--config/Xservers.ws.cpp2
-rw-r--r--config/xdm-config.cpp26
-rw-r--r--daemon.c114
-rw-r--r--dm.c179
-rw-r--r--dm.h222
-rw-r--r--dpylist.c39
-rw-r--r--error.c124
-rw-r--r--file.c47
-rw-r--r--genauth.c87
-rw-r--r--greet.h143
-rw-r--r--greeter/Login.c800
-rw-r--r--greeter/Login.h39
-rw-r--r--greeter/LoginP.h34
-rw-r--r--greeter/greet.c174
-rw-r--r--greeter/verify.c383
-rw-r--r--krb5auth.c32
-rw-r--r--mitauth.c12
-rw-r--r--netaddr.c37
-rw-r--r--policy.c75
-rw-r--r--protodpy.c35
-rw-r--r--reset.c25
-rw-r--r--resource.c252
-rw-r--r--rpcauth.c15
-rw-r--r--server.c103
-rw-r--r--session.c262
-rw-r--r--socket.c31
-rw-r--r--streams.c3
-rw-r--r--util.c90
-rw-r--r--xdm.man.cpp193
-rw-r--r--xdmauth.c18
-rw-r--r--xdmcp.c403
-rw-r--r--xdmshell.c36
38 files changed, 3319 insertions, 1764 deletions
diff --git a/Chooser.ad b/Chooser.ad
index 4dc4c74..66dcf7f 100644
--- a/Chooser.ad
+++ b/Chooser.ad
@@ -1,3 +1,5 @@
+! $XFree86: xc/programs/xdm/Chooser.ad,v 1.2 2001/04/06 02:16:25 dawes Exp $
+!
*ShapeStyle: Oval
*cursor: left_ptr
*allowShellResize: true
@@ -18,7 +20,7 @@
<BtnDown>: Set() CheckWilling() \n\
<BtnUp>(2): Accept()
*list.defaultColumns: 1
-*list.forceFolumns: true
+*list.forceColumns: true
*box.skipAdjust: true
*cancel.fromHoriz: viewport
diff --git a/access.c b/access.c
index 2328ba6..e6984b1 100644
--- a/access.c
+++ b/access.c
@@ -26,12 +26,15 @@ in this Software without prior written authorization from The Open Group.
* Author: Keith Packard, MIT X Consortium
*/
+/* $XFree86: xc/programs/xdm/access.c,v 3.10 2002/12/10 23:36:43 tsi Exp $ */
+
/*
* Access control for XDMCP - keep a database of allowable display addresses
* and (potentially) a list of hosts to send ForwardQuery packets to
*/
# include "dm.h"
+# include "dm_error.h"
#ifdef XDMCP
@@ -40,19 +43,22 @@ in this Software without prior written authorization from The Open Group.
# include <X11/X.h>
# include <stdio.h>
# include <ctype.h>
-# include <netinet/in.h>
+
+# include "dm_socket.h"
+
# include <netdb.h>
-# include <sys/socket.h>
#define ALIAS_CHARACTER '%'
#define NEGATE_CHARACTER '!'
#define CHOOSER_STRING "CHOOSER"
#define BROADCAST_STRING "BROADCAST"
+#define NOBROADCAST_STRING "NOBROADCAST"
-#define HOST_ALIAS 0
-#define HOST_ADDRESS 1
-#define HOST_BROADCAST 2
-#define HOST_CHOOSER 3
+#define HOST_ALIAS 0
+#define HOST_ADDRESS 1
+#define HOST_BROADCAST 2
+#define HOST_CHOOSER 3
+#define HOST_NOBROADCAST 4
typedef struct _hostEntry {
struct _hostEntry *next;
@@ -71,6 +77,7 @@ typedef struct _displayEntry {
struct _displayEntry *next;
int type;
int notAllowed;
+ int notBroadcast;
int chooser;
union _displayType {
char *aliasName;
@@ -88,7 +95,7 @@ static DisplayEntry *database;
static ARRAY8 localAddress;
ARRAY8Ptr
-getLocalAddress ()
+getLocalAddress (void)
{
static int haveLocalAddress;
@@ -104,8 +111,7 @@ getLocalAddress ()
}
static void
-FreeHostEntry (h)
- HostEntry *h;
+FreeHostEntry (HostEntry *h)
{
switch (h->type) {
case HOST_ALIAS:
@@ -121,8 +127,7 @@ FreeHostEntry (h)
}
static void
-FreeDisplayEntry (d)
- DisplayEntry *d;
+FreeDisplayEntry (DisplayEntry *d)
{
HostEntry *h, *next;
switch (d->type) {
@@ -133,7 +138,7 @@ FreeDisplayEntry (d)
free (d->entry.displayPattern);
break;
case DISPLAY_ADDRESS:
- XdmcpDisposeARRAY8 (&d->entry.displayAddress);
+ XdmcpDisposeARRAY8 (&d->entry.displayAddress.clientAddress);
break;
}
for (h = d->hosts; h; h = next) {
@@ -144,7 +149,7 @@ FreeDisplayEntry (d)
}
static void
-FreeAccessDatabase ()
+FreeAccessDatabase (void)
{
DisplayEntry *d, *next;
@@ -161,9 +166,7 @@ static char wordBuffer[WORD_LEN];
static int nextIsEOF;
static char *
-ReadWord (file, EOFatEOL)
- FILE *file;
- int EOFatEOL;
+ReadWord (FILE *file, int EOFatEOL)
{
int c;
char *wordp;
@@ -176,7 +179,7 @@ ReadWord (file, EOFatEOL)
return NULL;
}
quoted = FALSE;
- for (;;) {
+ for (;wordp - wordBuffer < sizeof(wordBuffer)-2;) {
c = getc (file);
switch (c) {
case '#':
@@ -219,11 +222,11 @@ ReadWord (file, EOFatEOL)
}
quoted = FALSE;
}
+ return NULL;
}
static HostEntry *
-ReadHostEntry (file)
- FILE *file;
+ReadHostEntry (FILE *file)
{
char *hostOrAlias;
HostEntry *h;
@@ -252,6 +255,10 @@ tryagain:
{
h->type = HOST_BROADCAST;
}
+ else if (!strcmp (hostOrAlias, NOBROADCAST_STRING))
+ {
+ h->type = HOST_NOBROADCAST;
+ }
else
{
h->type = HOST_ADDRESS;
@@ -275,8 +282,7 @@ tryagain:
}
static int
-HasGlobCharacters (s)
- char *s;
+HasGlobCharacters (char *s)
{
for (;;)
switch (*s++) {
@@ -289,8 +295,7 @@ HasGlobCharacters (s)
}
static DisplayEntry *
-ReadDisplayEntry (file)
- FILE *file;
+ReadDisplayEntry (FILE *file)
{
char *displayOrAlias;
DisplayEntry *d;
@@ -303,6 +308,7 @@ ReadDisplayEntry (file)
return NULL;
d = (DisplayEntry *) malloc (sizeof (DisplayEntry));
d->notAllowed = 0;
+ d->notBroadcast = 0;
d->chooser = 0;
if (*displayOrAlias == ALIAS_CHARACTER)
{
@@ -379,6 +385,9 @@ ReadDisplayEntry (file)
{
FreeHostEntry (h);
d->chooser = 1;
+ } else if (h->type == HOST_NOBROADCAST) {
+ FreeHostEntry (h);
+ d->notBroadcast = 1;
} else {
*prev = h;
prev = &h->next;
@@ -388,9 +397,8 @@ ReadDisplayEntry (file)
return d;
}
-static
-ReadAccessDatabase (file)
- FILE *file;
+static void
+ReadAccessDatabase (FILE *file)
{
DisplayEntry *d, **prev;
@@ -403,7 +411,8 @@ ReadAccessDatabase (file)
*prev = NULL;
}
-ScanAccessDatabase ()
+int
+ScanAccessDatabase (void)
{
FILE *datafile;
@@ -429,17 +438,25 @@ ScanAccessDatabase ()
#define MAX_DEPTH 32
-static int indirectAlias ();
+static int indirectAlias (
+ char *alias,
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ChooserFunc function,
+ char *closure,
+ int depth,
+ int broadcast);
+
static int
-scanHostlist (h, clientAddress, connectionType, function, closure, depth, broadcast)
- HostEntry *h;
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
- int (*function)();
- char *closure;
- int depth;
- int broadcast;
+scanHostlist (
+ HostEntry *h,
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ChooserFunc function,
+ char *closure,
+ int depth,
+ int broadcast)
{
int haveLocalhost = 0;
@@ -479,8 +496,7 @@ scanHostlist (h, clientAddress, connectionType, function, closure, depth, broadc
/* Returns non-0 iff string is matched by pattern. Does case folding.
*/
static int
-patternMatch (string, pattern)
- char *string, *pattern;
+patternMatch (char *string, char *pattern)
{
int p, s;
@@ -517,15 +533,14 @@ patternMatch (string, pattern)
}
static int
-indirectAlias (alias, clientAddress, connectionType, function, closure, depth,
- broadcast)
- char *alias;
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
- int (*function)();
- char *closure;
- int depth;
- int broadcast;
+indirectAlias (
+ char *alias,
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ChooserFunc function,
+ char *closure,
+ int depth,
+ int broadcast)
{
DisplayEntry *d;
int haveLocalhost = 0;
@@ -545,17 +560,15 @@ indirectAlias (alias, clientAddress, connectionType, function, closure, depth,
return haveLocalhost;
}
-ARRAY8Ptr IndirectChoice ();
-
-int ForEachMatchingIndirectHost (clientAddress, connectionType, function, closure)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
- int (*function)();
- char *closure;
+int ForEachMatchingIndirectHost (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ChooserFunc function,
+ char *closure)
{
int haveLocalhost = 0;
DisplayEntry *d;
- char *clientName = NULL, *NetworkAddressToHostname ();
+ char *clientName = NULL;
for (d = database; d; d = d->next)
{
@@ -604,12 +617,12 @@ int ForEachMatchingIndirectHost (clientAddress, connectionType, function, closur
return haveLocalhost;
}
-int UseChooser (clientAddress, connectionType)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
+int UseChooser (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType)
{
DisplayEntry *d;
- char *clientName = NULL, *NetworkAddressToHostname ();
+ char *clientName = NULL;
for (d = database; d; d = d->next)
{
@@ -648,15 +661,15 @@ int UseChooser (clientAddress, connectionType)
return 0;
}
-void ForEachChooserHost (clientAddress, connectionType, function, closure)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
- int (*function)();
- char *closure;
+void ForEachChooserHost (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ChooserFunc function,
+ char *closure)
{
int haveLocalhost = 0;
DisplayEntry *d;
- char *clientName = NULL, *NetworkAddressToHostname ();
+ char *clientName = NULL;
for (d = database; d; d = d->next)
{
@@ -703,13 +716,13 @@ void ForEachChooserHost (clientAddress, connectionType, function, closure)
* given display client is acceptable if it occurs without a host list.
*/
-int AcceptableDisplayAddress (clientAddress, connectionType, type)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
- xdmOpCode type;
+int AcceptableDisplayAddress (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ xdmOpCode type)
{
DisplayEntry *d;
- char *clientName = NULL, *NetworkAddressToHostname ();
+ char *clientName = NULL;
if (!*accessFile)
return 1;
@@ -742,7 +755,8 @@ int AcceptableDisplayAddress (clientAddress, connectionType, type)
}
if (clientName)
free (clientName);
- return (d != 0) && (d->notAllowed == 0);
+ return (d != 0) && (d->notAllowed == 0)
+ && (type == BROADCAST_QUERY ? d->notBroadcast == 0 : 1);
}
#endif /* XDMCP */
diff --git a/auth.c b/auth.c
index ac92968..e5e57b8 100644
--- a/auth.c
+++ b/auth.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/auth.c,v 3.27 2002/12/10 22:37:17 tsi Exp $ */
/*
* xdm - display manager daemon
@@ -36,86 +37,83 @@ from The Open Group.
* maintain the authorization generation daemon
*/
-#include "dm.h"
#include <X11/X.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include "dm.h"
+#include "dm_auth.h"
+#include "dm_error.h"
+
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
-#include <sys/socket.h>
-#ifndef ESIX
-# include <sys/ioctl.h>
-#endif /* !ESIX */
+#include <sys/ioctl.h>
-#ifdef TCPCONN
-# include <netinet/in.h>
+#if defined(TCPCONN) || defined(STREAMSCONN)
+# include "dm_socket.h"
#endif
#ifdef DNETCONN
# include <netdnet/dn.h>
# include <netdnet/dnetdb.h>
#endif
-#if (defined(_POSIX_SOURCE) && !defined(AIXV3)) || defined(hpux) || defined(USG) || defined(SVR4)
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || (defined(SYSV) && defined(i386))
#define NEED_UTSNAME
#include <sys/utsname.h>
#endif
-#if defined(SYSV) && defined(SYSV386)
+#if defined(SYSV) && defined(i386)
# include <sys/stream.h>
# ifdef ISC
+# include <stropts.h>
# include <sys/sioctl.h>
# endif /* ISC */
-# ifdef ESIX
-# include <lan/net_ioctl.h>
-# endif /* ESIX */
-#endif /* SYSV386 */
+#endif /* i386 */
#ifdef SVR4
# include <netdb.h>
+# ifndef SCO325
# include <sys/sockio.h>
-#ifdef USL
+# endif
# include <sys/stropts.h>
#endif
-#endif
#ifdef __convex__
# include <sync/queue.h>
# include <sync/sema.h>
#endif
+#ifdef __GNU__
+#include <netdb.h>
+#undef SIOCGIFCONF
+#else /* __GNU__ */
#include <net/if.h>
+#endif /* __GNU__ */
-extern int MitInitAuth ();
-extern Xauth *MitGetAuth ();
-
-#ifdef HASXDMAUTH
-extern int XdmInitAuth ();
-extern Xauth *XdmGetAuth ();
-#ifdef XDMCP
-extern void XdmGetXdmcpAuth ();
-#else
-#define XdmGetXdmcpAuth NULL
-#endif
+#if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && defined(SIOCGIFCONF)
+#define SYSV_SIOCGIFCONF
#endif
-#ifdef SECURE_RPC
-extern int SecureRPCInitAuth ();
-extern Xauth *SecureRPCGetAuth ();
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#if (BSD >= 199103)
+#define VARIABLE_IFREQ
+#endif
#endif
-#ifdef K5AUTH
-extern int Krb5InitAuth ();
-extern Xauth *Krb5GetAuth ();
+#ifdef __UNIXOS2__
+#define link rename
+int chown(int a,int b,int c) {}
+#include <io.h>
#endif
struct AuthProtocol {
unsigned short name_length;
char *name;
- int (*InitAuth)();
- Xauth *(*GetAuth)();
- void (*GetXdmcpAuth)();
+ void (*InitAuth)(unsigned short len, char *name);
+ Xauth *(*GetAuth)(unsigned short len, char *name);
+ void (*GetXdmcpAuth)(
+ struct protoDisplay *pdpy,
+ unsigned short authorizationNameLen,
+ char *authorizationName);
int inited;
};
@@ -143,9 +141,7 @@ static struct AuthProtocol AuthProtocols[] = {
#define NUM_AUTHORIZATION (sizeof (AuthProtocols) / sizeof (AuthProtocols[0]))
static struct AuthProtocol *
-findProtocol (name_length, name)
- unsigned short name_length;
- char *name;
+findProtocol (unsigned short name_length, char *name)
{
int i;
@@ -158,9 +154,8 @@ findProtocol (name_length, name)
return (struct AuthProtocol *) 0;
}
-ValidAuthorization (name_length, name)
- unsigned short name_length;
- char *name;
+int
+ValidAuthorization (unsigned short name_length, char *name)
{
if (findProtocol (name_length, name))
return TRUE;
@@ -168,9 +163,7 @@ ValidAuthorization (name_length, name)
}
static Xauth *
-GenerateAuthorization (name_length, name)
-unsigned short name_length;
-char *name;
+GenerateAuthorization (unsigned short name_length, char *name)
{
struct AuthProtocol *a;
Xauth *auth = 0;
@@ -189,7 +182,7 @@ char *name;
auth = (*a->GetAuth) (name_length, name);
if (auth)
{
- Debug ("Got 0x%x (%d %*.*s) ", auth,
+ Debug ("Got %p (%d %*.*s) ", auth,
auth->name_length, auth->name_length,
auth->name_length, auth->name);
for (i = 0; i < (int)auth->data_length; i++)
@@ -208,11 +201,11 @@ char *name;
#ifdef XDMCP
-SetProtoDisplayAuthorization (pdpy,
- authorizationNameLen, authorizationName)
- struct protoDisplay *pdpy;
- unsigned short authorizationNameLen;
- char *authorizationName;
+void
+SetProtoDisplayAuthorization (
+ struct protoDisplay *pdpy,
+ unsigned short authorizationNameLen,
+ char *authorizationName)
{
struct AuthProtocol *a;
Xauth *auth;
@@ -238,7 +231,7 @@ SetProtoDisplayAuthorization (pdpy,
pdpy->xdmcpAuthorization = 0;
}
if (auth)
- Debug ("Got 0x%x (%d %*.*s)\n", auth,
+ Debug ("Got %p (%d %*.*s)\n", auth,
auth->name_length, auth->name_length,
auth->name_length, auth->name);
else
@@ -249,9 +242,7 @@ SetProtoDisplayAuthorization (pdpy,
#endif /* XDMCP */
void
-CleanUpFileName (src, dst, len)
- char *src, *dst;
- int len;
+CleanUpFileName (char *src, char *dst, int len)
{
while (*src) {
if (--len <= 0)
@@ -275,9 +266,8 @@ CleanUpFileName (src, dst, len)
static char authdir1[] = "authdir";
static char authdir2[] = "authfiles";
-static
-MakeServerAuthFile (d)
- struct display *d;
+static int
+MakeServerAuthFile (struct display *d)
{
int len;
#ifdef SYSV
@@ -336,10 +326,11 @@ MakeServerAuthFile (d)
return TRUE;
}
-SaveServerAuthorizations (d, auths, count)
- struct display *d;
- Xauth **auths;
- int count;
+int
+SaveServerAuthorizations (
+ struct display *d,
+ Xauth **auths,
+ int count)
{
FILE *auth_file;
int mask;
@@ -361,7 +352,7 @@ SaveServerAuthorizations (d, auths, count)
}
else
{
- Debug ("File: %s auth: %x\n", d->authFile, auths);
+ Debug ("File: %s auth: %p\n", d->authFile, auths);
ret = TRUE;
for (i = 0; i < count; i++)
{
@@ -387,8 +378,7 @@ SaveServerAuthorizations (d, auths, count)
}
void
-SetLocalAuthorization (d)
- struct display *d;
+SetLocalAuthorization (struct display *d)
{
Xauth *auth, **auths;
int i, j;
@@ -445,8 +435,8 @@ SetLocalAuthorization (d)
* Well, actually we could use SUN-DES-1 because we tell the server
* to allow root in. This is bogus and should be fixed.
*/
-SetAuthorization (d)
- struct display *d;
+void
+SetAuthorization (struct display *d)
{
register Xauth **auth = d->authorizations;
int i;
@@ -464,10 +454,8 @@ SetAuthorization (d)
}
}
-static
-openFiles (name, new_name, oldp, newp)
-char *name, *new_name;
-FILE **oldp, **newp;
+static int
+openFiles (char *name, char *new_name, FILE **oldp, FILE **newp)
{
int mask;
@@ -486,21 +474,17 @@ FILE **oldp, **newp;
return 1;
}
-static
-binaryEqual (a, b, len)
-char *a, *b;
-unsigned short len;
+static int
+binaryEqual (char *a, char *b, unsigned short len)
{
while (len-- > 0)
if (*a++ != *b++)
- return 0;
- return 1;
+ return FALSE;
+ return TRUE;
}
-static
-dumpBytes (len, data)
-unsigned short len;
-char *data;
+static void
+dumpBytes (unsigned short len, char *data)
{
unsigned short i;
@@ -510,9 +494,8 @@ char *data;
Debug ("\n");
}
-static
-dumpAuth (auth)
- Xauth *auth;
+static void
+dumpAuth (Xauth *auth)
{
Debug ("family: %d\n", auth->family);
Debug ("addr: ");
@@ -538,14 +521,14 @@ struct addrList {
static struct addrList *addrs;
-static
-initAddrs ()
+static void
+initAddrs (void)
{
addrs = 0;
}
-static
-doneAddrs ()
+static void
+doneAddrs (void)
{
struct addrList *a, *n;
for (a = addrs; a; a = n) {
@@ -558,11 +541,10 @@ doneAddrs ()
}
}
-static checkEntry ();
+static int checkEntry (Xauth *auth);
static void
-saveEntry (auth)
- Xauth *auth;
+saveEntry (Xauth *auth)
{
struct addrList *new;
@@ -609,9 +591,8 @@ saveEntry (auth)
addrs = new;
}
-static
-checkEntry (auth)
- Xauth *auth;
+static int
+checkEntry (Xauth *auth)
{
struct addrList *a;
@@ -632,10 +613,8 @@ checkEntry (auth)
static int doWrite;
-static
-writeAuth (file, auth)
- FILE *file;
- Xauth *auth;
+static void
+writeAuth (FILE *file, Xauth *auth)
{
if (debugLevel >= 15) { /* normally too verbose */
Debug ("writeAuth: doWrite = %d\n", doWrite);
@@ -645,13 +624,13 @@ writeAuth (file, auth)
XauWriteAuth (file, auth);
}
-static
-writeAddr (family, addr_length, addr, file, auth)
- int family;
- int addr_length;
- char *addr;
- FILE *file;
- Xauth *auth;
+static void
+writeAddr (
+ int family,
+ int addr_length,
+ char *addr,
+ FILE *file,
+ Xauth *auth)
{
auth->family = (unsigned short) family;
auth->address_length = addr_length;
@@ -661,10 +640,8 @@ writeAddr (family, addr_length, addr, file, auth)
saveEntry (auth);
}
-static
-DefineLocal (file, auth)
- FILE *file;
- Xauth *auth;
+static void
+DefineLocal (FILE *file, Xauth *auth)
{
char displayname[100];
char tmp_displayname[100];
@@ -693,11 +670,11 @@ DefineLocal (file, auth)
struct utsname name;
uname(&name);
- strcpy(displayname, name.nodename);
+ snprintf(displayname, sizeof(displayname), "%s", name.nodename);
}
writeAddr (FamilyLocal, strlen (displayname), displayname, file, auth);
- strcpy(tmp_displayname, displayname);
+ snprintf(tmp_displayname, sizeof(tmp_displayname), "%s", displayname);
#endif
#if (!defined(NEED_UTSNAME) || defined (hpux))
@@ -723,13 +700,12 @@ DefineLocal (file, auth)
#endif
}
-#ifdef USL
-/* Deal with different SIOCGIFCONF ioctl semantics on UnixWare */
+#ifdef SYSV_SIOCGIFCONF
+
+/* Deal with different SIOCGIFCONF ioctl semantics on SYSV, SVR4 */
+
static int
-ifioctl (fd, cmd, arg)
- int fd;
- int cmd;
- char *arg;
+ifioctl (int fd, int cmd, char *arg)
{
struct strioctl ioc;
int ret;
@@ -741,6 +717,17 @@ ifioctl (fd, cmd, arg)
{
ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
+#ifdef ISC
+ /* SIOCGIFCONF is somewhat brain damaged on ISC. The argument
+ * buffer must contain the ifconf structure as header. Ifc_req
+ * is also not a pointer but a one element array of ifreq
+ * structures. On return this array is extended by enough
+ * ifreq fields to hold all interfaces. The return buffer length
+ * is placed in the buffer header.
+ */
+ ((struct ifconf *) ioc.ic_dp)->ifc_len =
+ ioc.ic_len - sizeof(struct ifconf);
+#endif
}
else
{
@@ -749,11 +736,46 @@ ifioctl (fd, cmd, arg)
}
ret = ioctl(fd, I_STR, (char *) &ioc);
if (ret >= 0 && cmd == SIOCGIFCONF)
+#ifdef SVR4
((struct ifconf *) arg)->ifc_len = ioc.ic_len;
+#endif
+#ifdef ISC
+ {
+ ((struct ifconf *) arg)->ifc_len =
+ ((struct ifconf *)ioc.ic_dp)->ifc_len;
+ ((struct ifconf *) arg)->ifc_buf =
+ (caddr_t)((struct ifconf *)ioc.ic_dp)->ifc_req;
+ }
+#endif
return(ret);
}
-#endif /* USL */
+#else /* SYSV_SIOCGIFCONF */
+#define ifioctl ioctl
+#endif /* SYSV_SIOCGIFCONF */
+
+#if defined(STREAMSCONN) && !defined(SYSV_SIOCGIFCONF) && !defined(NCR)
+
+#include <tiuser.h>
+
+/* Define this host for access control. Find all the hosts the OS knows about
+ * for this fd and add them to the selfhosts list.
+ * TLI version, written without sufficient documentation.
+ */
+static void
+DefineSelf (int fd, FILE *file, Xauth *auth)
+{
+ struct netbuf netb;
+ char addrret[1024]; /* easier than t_alloc */
+
+ netb.maxlen = sizeof(addrret);
+ netb.buf = addrret;
+ if (t_getname (fd, &netb, LOCALNAME) == -1)
+ t_error ("t_getname");
+ /* what a kludge */
+ writeAddr (FamilyInternet, 4, netb.buf+4, file, auth);
+}
+#else
#ifdef WINTCP /* NCR with Wollongong TCP */
@@ -768,14 +790,11 @@ ifioctl (fd, cmd, arg)
#include <netinet/in.h>
#include <netinet/in_var.h>
-static
-DefineSelf (fd, file, auth)
- int fd;
- FILE *file;
- Xauth *auth;
+static void
+DefineSelf (int fd, FILE *file, Xauth *auth)
{
/*
- * The Wolongong drivers used by NCR SVR4/MP-RAS don't understand the
+ * The Wollongong drivers used by NCR SVR4/MP-RAS don't understand the
* socket IO calls that most other drivers seem to like. Because of
* this, this routine must be special cased for NCR. Eventually,
* this will be cleared up.
@@ -785,7 +804,7 @@ DefineSelf (fd, file, auth)
struct in_ifaddr ifaddr;
struct strioctl str;
unsigned char *addr;
- int family, len, ipfd;
+ int len, ipfd;
if ((ipfd = open ("/dev/ip", O_RDWR, 0 )) < 0)
LogError ("Getting interface configuration");
@@ -828,25 +847,29 @@ DefineSelf (fd, file, auth)
}
close(ipfd);
-
}
#else /* WINTCP */
#ifdef SIOCGIFCONF
+/* Handle variable length ifreq in BNR2 and later */
+#ifdef VARIABLE_IFREQ
+#define ifr_size(p) (sizeof (struct ifreq) + \
+ (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
+ p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
+#else
+#define ifr_size(p) (sizeof (struct ifreq))
+#endif
+
/* Define this host for access control. Find all the hosts the OS knows about
* for this fd and add them to the selfhosts list.
*/
-static
-DefineSelf (fd, file, auth)
- int fd;
- FILE *file;
- Xauth *auth;
+static void
+DefineSelf (int fd, FILE *file, Xauth *auth)
{
- char buf[2048];
+ char buf[2048], *cp, *cplim;
struct ifconf ifc;
- register int n;
int len;
char *addr;
int family;
@@ -854,24 +877,20 @@ DefineSelf (fd, file, auth)
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
-
-#ifdef USL
if (ifioctl (fd, SIOCGIFCONF, (char *) &ifc) < 0)
-#else
- if (ioctl (fd, SIOCGIFCONF, (char *) &ifc) < 0)
-#endif
LogError ("Trouble getting network interface configuration");
- for (ifr = ifc.ifc_req
-#ifdef BSD44SOCKETS
- ; (char *)ifr < ifc.ifc_buf + ifc.ifc_len;
- ifr = (struct ifreq *)((char *)ifr + sizeof (struct ifreq) +
- (ifr->ifr_addr.sa_len > sizeof (ifr->ifr_addr) ?
- ifr->ifr_addr.sa_len - sizeof (ifr->ifr_addr) : 0))
+
+#ifdef ISC
+#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
#else
- , n = ifc.ifc_len / sizeof (struct ifreq); --n >= 0; ifr++
+#define IFC_IFC_REQ ifc.ifc_req
#endif
- )
+
+ cplim = (char *) IFC_IFC_REQ + ifc.ifc_len;
+
+ for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
{
+ ifr = (struct ifreq *) cp;
#ifdef DNETCONN
/*
* this is ugly but SIOCGIFCONF returns decnet addresses in
@@ -884,7 +903,7 @@ DefineSelf (fd, file, auth)
} else
#endif
{
- if (ConvertAddr (&ifr->ifr_addr, &len, &addr) < 0)
+ if (ConvertAddr ((XdmcpNetaddr) &ifr->ifr_addr, &len, &addr) < 0)
continue;
if (len == 0)
{
@@ -917,9 +936,8 @@ DefineSelf (fd, file, auth)
/* Define this host for access control. Find all the hosts the OS knows about
* for this fd and add them to the selfhosts list.
*/
-static
-DefineSelf (fd, file, auth)
- int fd;
+static void
+DefineSelf (int fd, int file, int auth)
{
register int n;
int len;
@@ -957,14 +975,12 @@ DefineSelf (fd, file, auth)
}
#endif /* SIOCGIFCONF else */
-
-#endif /* WINTCP */
+#endif /* WINTCP else */
+#endif /* STREAMSCONN && !SYSV_SIOCGIFCONF else */
-static
-setAuthNumber (auth, name)
- Xauth *auth;
- char *name;
+static void
+setAuthNumber (Xauth *auth, char *name)
{
char *colon;
char *dot, *number;
@@ -991,11 +1007,8 @@ setAuthNumber (auth, name)
}
}
-static
-writeLocalAuth (file, auth, name)
- FILE *file;
- Xauth *auth;
- char *name;
+static void
+writeLocalAuth (FILE *file, Xauth *auth, char *name)
{
int fd;
@@ -1024,12 +1037,7 @@ writeLocalAuth (file, auth, name)
#ifdef XDMCP
static void
-writeRemoteAuth (file, auth, peer, peerlen, name)
- FILE *file;
- Xauth *auth;
- XdmcpNetaddr peer;
- int peerlen;
- char *name;
+writeRemoteAuth (FILE *file, Xauth *auth, XdmcpNetaddr peer, int peerlen, char *name)
{
int family = FamilyLocal;
char *addr;
@@ -1055,19 +1063,16 @@ writeRemoteAuth (file, auth, peer, peerlen, name)
#endif /* XDMCP */
void
-SetUserAuthorization (d, verify)
- struct display *d;
- struct verify_info *verify;
+SetUserAuthorization (struct display *d, struct verify_info *verify)
{
FILE *old, *new;
char home_name[1024], backup_name[1024], new_name[1024];
- char *name;
+ char *name = 0;
char *home;
char *envname = 0;
int lockStatus;
Xauth *entry, **auths;
- int setenv;
- char **setEnv (), *getEnv ();
+ int setenv = 0;
struct stat statb;
int i;
int magicCookie;
@@ -1079,10 +1084,7 @@ SetUserAuthorization (d, verify)
home = getEnv (verify->userEnviron, "HOME");
lockStatus = LOCK_ERROR;
if (home) {
- strcpy (home_name, home);
- if (home[strlen(home) - 1] != '/')
- strcat (home_name, "/");
- strcat (home_name, ".Xauthority");
+ snprintf (home_name, sizeof(home_name), "%s/.Xauthority", home);
Debug ("XauLockAuth %s\n", home_name);
lockStatus = XauLockAuth (home_name, 1, 2, 10);
Debug ("Lock is %d\n", lockStatus);
@@ -1098,7 +1100,7 @@ SetUserAuthorization (d, verify)
}
}
if (lockStatus != LOCK_SUCCESS) {
- sprintf (backup_name, "%s/.XauthXXXXXX", d->userAuthDir);
+ snprintf (backup_name, sizeof(backup_name), "%s/.XauthXXXXXX", d->userAuthDir);
(void) mktemp (backup_name);
lockStatus = XauLockAuth (backup_name, 1, 2, 10);
Debug ("backup lock is %d\n", lockStatus);
@@ -1206,9 +1208,7 @@ SetUserAuthorization (d, verify)
}
void
-RemoveUserAuthorization (d, verify)
- struct display *d;
- struct verify_info *verify;
+RemoveUserAuthorization (struct display *d, struct verify_info *verify)
{
char *home;
Xauth **auths, *entry;
@@ -1217,7 +1217,6 @@ RemoveUserAuthorization (d, verify)
FILE *old, *new;
struct stat statb;
int i;
- char *getEnv ();
if (!(auths = d->authorizations))
return;
@@ -1225,10 +1224,7 @@ RemoveUserAuthorization (d, verify)
if (!home)
return;
Debug ("RemoveUserAuthorization\n");
- strcpy (name, home);
- if (home[strlen(home) - 1] != '/')
- strcat (name, "/");
- strcat (name, ".Xauthority");
+ snprintf(name, sizeof(name), "%s/.Xauthority", home);
Debug ("XauLockAuth %s\n", name);
lockStatus = XauLockAuth (name, 1, 2, 10);
Debug ("Lock is %d\n", lockStatus);
diff --git a/choose.c b/choose.c
index 1e88be7..e4b94d8 100644
--- a/choose.c
+++ b/choose.c
@@ -26,6 +26,8 @@ in this Software without prior written authorization from The Open Group.
* Author: Keith Packard, MIT X Consortium
*/
+/* $XFree86: xc/programs/xdm/choose.c,v 3.15 2001/12/14 20:01:20 dawes Exp $ */
+
/*
* choose.c
*
@@ -33,35 +35,39 @@ in this Software without prior written authorization from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
#ifdef XDMCP
#include <X11/X.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+
+#include "dm_socket.h"
+
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
#include <sys/un.h>
+#else
+#include <un.h>
+#endif
+#endif
+
#include <ctype.h>
#include <errno.h>
+
#if defined(STREAMSCONN)
# include <tiuser.h>
#endif
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#define Time_t long
-extern Time_t time ();
-#else
#include <time.h>
#define Time_t time_t
-#endif
-static
-FormatBytes (data, length, buf, buflen)
- unsigned char *data;
- int length;
- char *buf;
- int buflen;
+static int
+FormatBytes (
+ unsigned char *data,
+ int length,
+ char *buf,
+ int buflen)
{
int i;
static char HexChars[] = "0123456789abcdef";
@@ -77,11 +83,11 @@ FormatBytes (data, length, buf, buflen)
return 1;
}
-static
-FormatARRAY8 (a, buf, buflen)
- ARRAY8Ptr a;
- char *buf;
- int buflen;
+static int
+FormatARRAY8 (
+ ARRAY8Ptr a,
+ char *buf,
+ int buflen)
{
return FormatBytes (a->data, a->length, buf, buflen);
}
@@ -91,10 +97,10 @@ FormatARRAY8 (a, buf, buflen)
Returns 1 if successful, 0 if not.
*/
static int
-ARRAY8ToDottedDecimal (a, buf, buflen)
- ARRAY8Ptr a;
- char *buf;
- int buflen;
+ARRAY8ToDottedDecimal (
+ ARRAY8Ptr a,
+ char *buf,
+ int buflen)
{
if (a->length != 4 || buflen < 20)
return 0;
@@ -111,9 +117,10 @@ typedef struct _IndirectUsers {
static IndirectUsersPtr indirectUsers;
-RememberIndirectClient (clientAddress, connectionType)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
+int
+RememberIndirectClient (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType)
{
IndirectUsersPtr i;
@@ -133,9 +140,10 @@ RememberIndirectClient (clientAddress, connectionType)
return 1;
}
-ForgetIndirectClient (clientAddress, connectionType)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
+void
+ForgetIndirectClient (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType)
{
IndirectUsersPtr i, prev;
@@ -157,9 +165,10 @@ ForgetIndirectClient (clientAddress, connectionType)
}
}
-IsIndirectClient (clientAddress, connectionType)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
+int
+IsIndirectClient (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType)
{
IndirectUsersPtr i;
@@ -170,12 +179,8 @@ IsIndirectClient (clientAddress, connectionType)
return 0;
}
-extern char *NetaddrPort();
-
-static
-FormatChooserArgument (buf, len)
- char *buf;
- int len;
+static int
+FormatChooserArgument (char *buf, int len)
{
unsigned char addr_buf[1024];
int addr_len = sizeof (addr_buf);
@@ -183,7 +188,7 @@ FormatChooserArgument (buf, len)
int result_len = 0;
int netfamily;
- if (GetChooserAddr (addr_buf, &addr_len) == -1)
+ if (GetChooserAddr ((char *)addr_buf, &addr_len) == -1)
{
LogError ("Cannot get return address for chooser socket\n");
Debug ("Cannot get chooser socket address\n");
@@ -195,7 +200,7 @@ FormatChooserArgument (buf, len)
{
char *port;
int portlen;
- ARRAY8Ptr localAddress, getLocalAddress ();
+ ARRAY8Ptr localAddress;
port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen);
result_buf[0] = netfamily >> 8;
@@ -230,9 +235,9 @@ typedef struct _Choices {
static ChoicePtr choices;
ARRAY8Ptr
-IndirectChoice (clientAddress, connectionType)
- ARRAY8Ptr clientAddress;
- CARD16 connectionType;
+IndirectChoice (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType)
{
ChoicePtr c, next, prev;
Time_t now;
@@ -242,10 +247,12 @@ IndirectChoice (clientAddress, connectionType)
for (c = choices; c; c = next)
{
next = c->next;
- Debug ("Choice checking timeout: %d >? %d\n", now - c->time, choiceTimeout);
+ Debug ("Choice checking timeout: %ld >? %d\n",
+ (long)(now - c->time), choiceTimeout);
if (now - c->time > (Time_t)choiceTimeout)
{
- Debug ("Timeout choice %d > %d\n", now - c->time, choiceTimeout);
+ Debug ("Timeout choice %ld > %d\n",
+ (long)(now - c->time), choiceTimeout);
if (prev)
prev->next = next;
else
@@ -266,9 +273,10 @@ IndirectChoice (clientAddress, connectionType)
}
static int
-RegisterIndirectChoice (clientAddress, connectionType, choice)
- ARRAY8Ptr clientAddress, choice;
- CARD16 connectionType;
+RegisterIndirectChoice (
+ ARRAY8Ptr clientAddress,
+ CARD16 connectionType,
+ ARRAY8Ptr choice)
{
ChoicePtr c;
int insert;
@@ -282,8 +290,10 @@ RegisterIndirectChoice (clientAddress, connectionType, choice)
break;
}
}
+#if 0
if (!found)
return 0;
+#endif
insert = 0;
if (!c)
@@ -347,13 +357,13 @@ RemoveIndirectChoice (clientAddress, connectionType)
#endif
/*ARGSUSED*/
-static
-AddChooserHost (connectionType, addr, closure)
- CARD16 connectionType;
- ARRAY8Ptr addr;
- char *closure;
+static void
+AddChooserHost (
+ CARD16 connectionType,
+ ARRAY8Ptr addr,
+ char *closure)
{
- char ***argp, **parseArgs();
+ char ***argp;
char hostbuf[1024];
argp = (char ***) closure;
@@ -368,8 +378,8 @@ AddChooserHost (connectionType, addr, closure)
}
}
-ProcessChooserSocket (fd)
- int fd;
+void
+ProcessChooserSocket (int fd)
{
int client_fd;
char buf[1024];
@@ -426,7 +436,7 @@ ProcessChooserSocket (fd)
return;
}
#else
- client_fd = accept (fd, (struct sockaddr *)buf, &len);
+ client_fd = accept (fd, (struct sockaddr *)buf, (void *)&len);
if (client_fd == -1)
{
LogError ("Cannot accept chooser connection\n");
@@ -451,16 +461,22 @@ ProcessChooserSocket (fd)
clientAddress.length = 0;
choice.data = 0;
choice.length = 0;
- if (XdmcpReadARRAY8 (&buffer, &clientAddress) &&
- XdmcpReadCARD16 (&buffer, &connectionType) &&
- XdmcpReadARRAY8 (&buffer, &choice))
- {
- Debug ("Read from chooser succesfully\n");
- if (!RegisterIndirectChoice (&clientAddress, connectionType, &choice))
- Debug ("Invalid chooser reply\n");
+ if (XdmcpReadARRAY8 (&buffer, &clientAddress)) {
+ if (XdmcpReadCARD16 (&buffer, &connectionType)) {
+ if (XdmcpReadARRAY8 (&buffer, &choice)) {
+ Debug ("Read from chooser succesfully\n");
+ RegisterIndirectChoice (&clientAddress, connectionType, &choice);
+ XdmcpDisposeARRAY8 (&choice);
+ } else {
+ LogError ("Invalid choice response length %d\n", len);
+ }
+ } else {
+ LogError ("Invalid choice response length %d\n", len);
+ }
+ XdmcpDisposeARRAY8 (&clientAddress);
+ } else {
+ LogError ("Invalid choice response length %d\n", len);
}
- XdmcpDisposeARRAY8 (&clientAddress);
- XdmcpDisposeARRAY8 (&choice);
}
else
{
@@ -476,15 +492,19 @@ ProcessChooserSocket (fd)
#endif
}
-RunChooser (d)
- struct display *d;
+void
+RunChooser (struct display *d)
{
- char **args, **parseArgs(), **systemEnv();
+ char **args;
char buf[1024];
char **env;
Debug ("RunChooser %s\n", d->name);
+#ifndef HAS_SETPROCTITLE
SetTitle (d->name, "chooser", (char *) 0);
+#else
+ setproctitle("chooser %s", d->name);
+#endif
LoadXloginResources (d);
args = parseArgs ((char **) 0, d->chooser);
strcpy (buf, "-xdmaddress ");
@@ -506,3 +526,4 @@ RunChooser (d)
}
#endif /* XDMCP */
+
diff --git a/chooser.c b/chooser.c
index 3724691..4e63ee7 100644
--- a/chooser.c
+++ b/chooser.c
@@ -26,6 +26,8 @@ in this Software without prior written authorization from The Open Group.
* Author: Keith Packard, MIT X Consortium
*/
+/* $XFree86: xc/programs/xdm/chooser.c,v 3.24 2001/12/14 20:01:20 dawes Exp $ */
+
/*
* Chooser - display a menu of names and let the user select one
*/
@@ -68,11 +70,28 @@ in this Software without prior written authorization from The Open Group.
#include <stdio.h>
#include <ctype.h>
-#ifdef SVR4
+#ifdef USE_XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
+#if defined(SVR4) && !defined(SCO325)
#include <sys/sockio.h>
#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
+#if defined(SVR4) && defined(PowerMAX_OS)
+#include <sys/stropts.h>
+#endif
+#if defined(SYSV) && defined(i386)
+#include <sys/stream.h>
+#ifdef ISC
+#include <sys/sioctl.h>
+#include <sys/stropts.h>
+#endif
+#endif
+
+#include "dm_socket.h"
+
+#include <arpa/inet.h>
+
#include <sys/ioctl.h>
#ifdef STREAMSCONN
#ifdef WINTCP /* NCR with Wollongong TCP */
@@ -84,6 +103,13 @@ in this Software without prior written authorization from The Open Group.
#include <netdir.h>
#endif
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#if (BSD >= 199103)
+#define VARIABLE_IFREQ
+#endif
+#endif
+
#ifdef XKB
#include <X11/extensions/XKBbells.h>
#endif
@@ -91,7 +117,7 @@ in this Software without prior written authorization from The Open Group.
#define BROADCAST_HOSTNAME "BROADCAST"
#ifndef ishexdigit
-#define ishexdigit(c) (isdigit(c) || 'a' <= (c) && (c) <= 'f')
+#define ishexdigit(c) (isdigit(c) || ('a' <= (c) && (c) <= 'f'))
#endif
#ifdef hpux
@@ -104,14 +130,22 @@ in this Software without prior written authorization from The Open Group.
# include <sync/queue.h>
# include <sync/sema.h>
#endif
+#ifndef __GNU__
# include <net/if.h>
+#endif /* __GNU__ */
#endif /* hpux */
#include <netdb.h>
+static int FromHex (char *s, char *d, int len);
+
Widget toplevel, label, viewport, paned, list, box, cancel, acceptit, ping;
-static void CvtStringToARRAY8();
+static void CvtStringToARRAY8(
+ XrmValuePtr args,
+ Cardinal *num_args,
+ XrmValuePtr fromVal,
+ XrmValuePtr toVal);
static struct _app_resources {
ARRAY8Ptr xdmAddress;
@@ -134,9 +168,9 @@ static XtResource resources[] = {
#undef offset
static XrmOptionDescRec options[] = {
- "-xdmaddress", "*xdmAddress", XrmoptionSepArg, NULL,
- "-clientaddress", "*clientAddress", XrmoptionSepArg, NULL,
- "-connectionType", "*connectionType", XrmoptionSepArg, NULL,
+ { "-xdmaddress", "*xdmAddress", XrmoptionSepArg, NULL },
+ { "-clientaddress", "*clientAddress", XrmoptionSepArg, NULL },
+ { "-connectionType","*connectionType", XrmoptionSepArg, NULL },
};
typedef struct _hostAddr {
@@ -169,20 +203,72 @@ static int pingTry;
static XdmcpBuffer directBuffer, broadcastBuffer;
static XdmcpBuffer buffer;
+#if ((defined(SVR4) && !defined(sun) && !defined(__sgi) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF)
+
+/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
+
+static int
+ifioctl (int fd, int cmd, char *arg)
+{
+ struct strioctl ioc;
+ int ret;
+
+ bzero((char *) &ioc, sizeof(ioc));
+ ioc.ic_cmd = cmd;
+ ioc.ic_timout = 0;
+ if (cmd == SIOCGIFCONF)
+ {
+ ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
+ ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
+#ifdef ISC
+ /* SIOCGIFCONF is somewhat brain damaged on ISC. The argument
+ * buffer must contain the ifconf structure as header. Ifc_req
+ * is also not a pointer but a one element array of ifreq
+ * structures. On return this array is extended by enough
+ * ifreq fields to hold all interfaces. The return buffer length
+ * is placed in the buffer header.
+ */
+ ((struct ifconf *) ioc.ic_dp)->ifc_len =
+ ioc.ic_len - sizeof(struct ifconf);
+#endif
+ }
+ else
+ {
+ ioc.ic_len = sizeof(struct ifreq);
+ ioc.ic_dp = arg;
+ }
+ ret = ioctl(fd, I_STR, (char *) &ioc);
+ if (ret >= 0 && cmd == SIOCGIFCONF)
+#ifdef SVR4
+ ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
+#endif
+#ifdef ISC
+ {
+ ((struct ifconf *) arg)->ifc_len =
+ ((struct ifconf *)ioc.ic_dp)->ifc_len;
+ ((struct ifconf *) arg)->ifc_buf =
+ (caddr_t)((struct ifconf *)ioc.ic_dp)->ifc_req;
+ }
+#endif
+ return(ret);
+}
+#else /* ((SVR4 && !sun && !NCR) || ISC) && SIOCGIFCONF */
+#define ifioctl ioctl
+#endif /* ((SVR4 && !sun) || ISC) && SIOCGIFCONF */
+
+
/* ARGSUSED */
static void
-PingHosts (closure, id)
- XtPointer closure;
- XtIntervalId *id;
+PingHosts (XtPointer closure, XtIntervalId *id)
{
HostAddr *hosts;
for (hosts = hostAddrdb; hosts; hosts = hosts->next)
{
if (hosts->type == QUERY)
- XdmcpFlush (socketFD, &directBuffer, hosts->addr, hosts->addrlen);
+ XdmcpFlush (socketFD, &directBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen);
else
- XdmcpFlush (socketFD, &broadcastBuffer, hosts->addr, hosts->addrlen);
+ XdmcpFlush (socketFD, &broadcastBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen);
}
if (++pingTry < TRIES)
XtAddTimeOut (PING_INTERVAL, PingHosts, (XtPointer) 0);
@@ -192,19 +278,13 @@ char **NameTable;
int NameTableSize;
static int
-HostnameCompare (a, b)
-#ifdef __STDC__
- const void *a, *b;
-#else
- char *a, *b;
-#endif
+HostnameCompare (const void *a, const void *b)
{
return strcmp (*(char **)a, *(char **)b);
}
static void
-RebuildTable (size)
- int size;
+RebuildTable (int size)
{
char **newTable = 0;
HostName *names;
@@ -227,10 +307,7 @@ RebuildTable (size)
}
static int
-AddHostname (hostname, status, addr, willing)
- ARRAY8Ptr hostname, status;
- struct sockaddr *addr;
- int willing;
+AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int willing)
{
HostName *new, **names, *name;
ARRAY8 hostAddr;
@@ -281,7 +358,7 @@ AddHostname (hostname, status, addr, willing)
if (hostent)
{
XdmcpDisposeARRAY8 (hostname);
- host = hostent->h_name;
+ host = (char *)hostent->h_name;
XdmcpAllocARRAY8 (hostname, strlen (host));
memmove( hostname->data, host, hostname->length);
}
@@ -332,8 +409,7 @@ AddHostname (hostname, status, addr, willing)
}
static void
-DisposeHostname (host)
- HostName *host;
+DisposeHostname (HostName *host)
{
XdmcpDisposeARRAY8 (&host->hostname);
XdmcpDisposeARRAY8 (&host->hostaddr);
@@ -342,9 +418,9 @@ DisposeHostname (host)
free ((char *) host);
}
+#if 0
static void
-RemoveHostname (host)
- HostName *host;
+RemoveHostname (HostName *host)
{
HostName **prev, *hosts;
@@ -362,9 +438,10 @@ RemoveHostname (host)
NameTableSize--;
RebuildTable (NameTableSize);
}
+#endif
static void
-EmptyHostnames ()
+EmptyHostnames (void)
{
HostName *hosts, *next;
@@ -380,10 +457,7 @@ EmptyHostnames ()
/* ARGSUSED */
static void
-ReceivePacket (closure, source, id)
- XtPointer closure;
- int *source;
- XtInputId *id;
+ReceivePacket (XtPointer closure, int *source, XtInputId *id)
{
XdmcpHeader header;
ARRAY8 authenticationName;
@@ -394,7 +468,7 @@ ReceivePacket (closure, source, id)
int addrlen;
addrlen = sizeof (addr);
- if (!XdmcpFill (socketFD, &buffer, &addr, &addrlen))
+ if (!XdmcpFill (socketFD, &buffer, (XdmcpNetaddr) &addr, &addrlen))
return;
if (!XdmcpReadHeader (&buffer, &header))
return;
@@ -441,10 +515,7 @@ ReceivePacket (closure, source, id)
}
static void
-RegisterHostaddr (addr, len, type)
- struct sockaddr *addr;
- int len;
- xdmOpCode type;
+RegisterHostaddr (struct sockaddr *addr, int len, xdmOpCode type)
{
HostAddr *host, **prev;
@@ -473,17 +544,26 @@ RegisterHostaddr (addr, len, type)
* addresses on the local host.
*/
+#if !defined(__GNU__)
+
+/* Handle variable length ifreq in BNR2 and later */
+#ifdef VARIABLE_IFREQ
+#define ifr_size(p) (sizeof (struct ifreq) + \
+ (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
+ p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
+#else
+#define ifr_size(p) (sizeof (struct ifreq))
+#endif
+
static void
-RegisterHostname (name)
- char *name;
+RegisterHostname (char *name)
{
struct hostent *hostent;
struct sockaddr_in in_addr;
struct ifconf ifc;
register struct ifreq *ifr;
struct sockaddr broad_addr;
- char buf[2048];
- int n;
+ char buf[2048], *cp, *cplim;
if (!strcmp (name, BROADCAST_HOSTNAME))
{
@@ -491,6 +571,7 @@ RegisterHostname (name)
int ipfd;
struct ifconf *ifcp;
struct strioctl ioc;
+ int n;
ifcp = (struct ifconf *)buf;
ifcp->ifc_buf = buf+4;
@@ -514,27 +595,29 @@ RegisterHostname (name)
return;
}
- for (ifr = ifcp->ifc_req,
-n = ifcp->ifc_len / sizeof (struct ifreq);
+ for (ifr = ifcp->ifc_req, n = ifcp->ifc_len / sizeof (struct ifreq);
--n >= 0;
ifr++)
#else /* WINTCP */
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
- if (ioctl (socketFD, (int) SIOCGIFCONF, (char *) &ifc) < 0)
+ if (ifioctl (socketFD, (int) SIOCGIFCONF, (char *) &ifc) < 0)
return;
- for (ifr = ifc.ifc_req
-#ifdef BSD44SOCKETS
- ; (char *)ifr < ifc.ifc_buf + ifc.ifc_len;
- ifr = (struct ifreq *)((char *)ifr + sizeof (struct ifreq) +
- (ifr->ifr_addr.sa_len > sizeof (ifr->ifr_addr) ?
- ifr->ifr_addr.sa_len - sizeof (ifr->ifr_addr) : 0))
+
+#ifdef ISC
+#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
#else
- , n = ifc.ifc_len / sizeof (struct ifreq); --n >= 0; ifr++
+#define IFC_IFC_REQ ifc.ifc_req
#endif
- )
+
+ cplim = (char *) IFC_IFC_REQ + ifc.ifc_len;
+
+ for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
#endif /* WINTCP */
{
+#ifndef WINTCP
+ ifr = (struct ifreq *) cp;
+#endif
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
@@ -554,7 +637,7 @@ n = ifcp->ifc_len / sizeof (struct ifreq);
if (ioctl (ipfd, I_STR, (char *) &ioc) != -1 &&
#else /* WINTCP */
- if (ioctl (socketFD, SIOCGIFFLAGS, (char *) &broad_req) != -1 &&
+ if (ifioctl (socketFD, SIOCGIFFLAGS, (char *) &broad_req) != -1 &&
#endif /* WINTCP */
(broad_req.ifr_flags & IFF_BROADCAST) &&
(broad_req.ifr_flags & IFF_UP)
@@ -569,7 +652,7 @@ n = ifcp->ifc_len / sizeof (struct ifreq);
if (ioctl (ipfd, I_STR, (char *) &ioc) != -1)
#else /* WINTCP */
- if (ioctl (socketFD, SIOCGIFBRDADDR, &broad_req) != -1)
+ if (ifioctl (socketFD, SIOCGIFBRDADDR, &broad_req) != -1)
#endif /* WINTCP */
broad_addr = broad_req.ifr_addr;
else
@@ -618,13 +701,54 @@ n = ifcp->ifc_len / sizeof (struct ifreq);
QUERY);
}
}
+#else /* __GNU__ */
+static void
+RegisterHostname (char *name)
+{
+ struct hostent *hostent;
+ struct sockaddr_in in_addr;
+
+ if (!strcmp (name, BROADCAST_HOSTNAME))
+ {
+ in_addr.sin_addr.s_addr= htonl(0xFFFFFFFF);
+ in_addr.sin_port = htons (XDM_UDP_PORT);
+ RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
+ BROADCAST_QUERY);
+ }
+ else
+ {
+
+ /* address as hex string, e.g., "12180022" (depreciated) */
+ if (strlen(name) == 8 &&
+ FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0)
+ {
+ in_addr.sin_family = AF_INET;
+ }
+ /* Per RFC 1123, check first for IP address in dotted-decimal form */
+ else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1)
+ in_addr.sin_family = AF_INET;
+ else
+ {
+ hostent = gethostbyname (name);
+ if (!hostent)
+ return;
+ if (hostent->h_addrtype != AF_INET || hostent->h_length != 4)
+ return;
+ in_addr.sin_family = hostent->h_addrtype;
+ memmove( &in_addr.sin_addr, hostent->h_addr, 4);
+ }
+ in_addr.sin_port = htons (XDM_UDP_PORT);
+ RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
+ QUERY);
+ }
+}
+#endif /* __GNU__ */
static ARRAYofARRAY8 AuthenticationNames;
+#if 0
static void
-RegisterAuthenticationName (name, namelen)
- char *name;
- int namelen;
+RegisterAuthenticationName (char *name, int namelen)
{
ARRAY8Ptr authName;
if (!XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
@@ -635,10 +759,10 @@ RegisterAuthenticationName (name, namelen)
return;
memmove( authName->data, name, namelen);
}
+#endif
-int
-InitXDMCP (argv)
- char **argv;
+static int
+InitXDMCP (char **argv)
{
int soopts = 1;
XdmcpHeader header;
@@ -661,11 +785,13 @@ InitXDMCP (argv)
XdmcpWriteARRAYofARRAY8 (&directBuffer, &AuthenticationNames);
#if defined(STREAMSCONN)
if ((socketFD = t_open ("/dev/udp", O_RDWR, 0)) < 0)
- return 0;
- if (t_bind( socketFD, NULL, NULL ) < 0) {
+ return 0;
+
+ if (t_bind( socketFD, NULL, NULL ) < 0)
+ {
t_close(socketFD);
return 0;
- }
+ }
/*
* This part of the code looks contrived. It will actually fit in nicely
@@ -674,18 +800,20 @@ InitXDMCP (argv)
{
struct netconfig *nconf;
- if( (nconf=getnetconfigent("udp")) == NULL ) {
+ if( (nconf=getnetconfigent("udp")) == NULL )
+ {
t_unbind(socketFD);
t_close(socketFD);
return 0;
- }
+ }
- if( netdir_options(nconf, ND_SET_BROADCAST, socketFD, NULL) ) {
+ if( netdir_options(nconf, ND_SET_BROADCAST, socketFD, NULL) )
+ {
freenetconfigent(nconf);
t_unbind(socketFD);
t_close(socketFD);
return 0;
- }
+ }
freenetconfigent(nconf);
}
@@ -693,11 +821,13 @@ InitXDMCP (argv)
if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
return 0;
#endif
+#ifndef STREAMSCONN
#ifdef SO_BROADCAST
soopts = 1;
if (setsockopt (socketFD, SOL_SOCKET, SO_BROADCAST, (char *)&soopts, sizeof (soopts)) < 0)
perror ("setsockopt");
#endif
+#endif
XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket,
(XtPointer) 0);
@@ -712,15 +842,14 @@ InitXDMCP (argv)
}
static void
-Choose (h)
- HostName *h;
+Choose (HostName *h)
{
if (app_resources.xdmAddress)
{
struct sockaddr_in in_addr;
- struct sockaddr *addr;
+ struct sockaddr *addr = NULL;
int family;
- int len;
+ int len = 0;
int fd;
char buf[1024];
XdmcpBuffer buffer;
@@ -823,11 +952,7 @@ Choose (h)
/* ARGSUSED */
static void
-DoAccept (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DoAccept (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
XawListReturnStruct *r;
HostName *h;
@@ -852,11 +977,7 @@ DoAccept (w, event, params, num_params)
/* ARGSUSED */
static void
-DoCheckWilling (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DoCheckWilling (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
XawListReturnStruct *r;
HostName *h;
@@ -872,22 +993,14 @@ DoCheckWilling (w, event, params, num_params)
/* ARGSUSED */
static void
-DoCancel (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DoCancel (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
exit (OBEYSESS_DISPLAY);
}
/* ARGSUSED */
static void
-DoPing (w, event, params, num_params)
- Widget w;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DoPing (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
EmptyHostnames ();
pingTry = 0;
@@ -895,19 +1008,23 @@ DoPing (w, event, params, num_params)
}
static XtActionsRec app_actions[] = {
- "Accept", DoAccept,
- "Cancel", DoCancel,
- "CheckWilling", DoCheckWilling,
- "Ping", DoPing,
+ { "Accept", DoAccept },
+ { "Cancel", DoCancel },
+ { "CheckWilling", DoCheckWilling },
+ { "Ping", DoPing },
};
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
Arg position[3];
Dimension width, height;
Position x, y;
+#ifdef USE_XINERAMA
+ XineramaScreenInfo *screens;
+ int s_num;
+#endif
+
toplevel = XtInitialize (argv[0], "Chooser", options, XtNumber(options), &argc, argv);
@@ -935,8 +1052,23 @@ main (argc, argv)
XtSetArg (position[0], XtNwidth, &width);
XtSetArg (position[1], XtNheight, &height);
XtGetValues (toplevel, position, (Cardinal) 2);
- x = (Position)(WidthOfScreen (XtScreen (toplevel)) - width) / 2;
- y = (Position)(HeightOfScreen (XtScreen (toplevel)) - height) / 3;
+#ifdef USE_XINERAMA
+ if (
+ XineramaIsActive(XtDisplay(toplevel)) &&
+ (screens = XineramaQueryScreens(XtDisplay(toplevel), &s_num)) != NULL
+ )
+ {
+ x = (Position)(screens[0].x_org + (screens[0].width - width) / 2);
+ y = (Position)(screens[0].y_org + (screens[0].height - height) / 3);
+
+ XFree(screens);
+ }
+ else
+#endif
+ {
+ x = (Position)(WidthOfScreen (XtScreen (toplevel)) - width) / 2;
+ y = (Position)(HeightOfScreen (XtScreen (toplevel)) - height) / 3;
+ }
XtSetArg (position[0], XtNx, x);
XtSetArg (position[1], XtNy, y);
XtSetValues (toplevel, position, (Cardinal) 2);
@@ -954,10 +1086,8 @@ main (argc, argv)
/* Converts the hex string s of length len into the byte array d.
Returns 0 if s was a legal hex string, 1 otherwise.
*/
-int
-FromHex (s, d, len)
- char *s, *d;
- int len;
+static int
+FromHex (char *s, char *d, int len)
{
int t;
int ret = len&1; /* odd-length hex strings are illegal */
@@ -981,11 +1111,7 @@ FromHex (s, d, len)
/*ARGSUSED*/
static void
-CvtStringToARRAY8 (args, num_args, fromVal, toVal)
- XrmValuePtr args;
- Cardinal *num_args;
- XrmValuePtr fromVal;
- XrmValuePtr toVal;
+CvtStringToARRAY8 (XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal)
{
static ARRAY8Ptr dest;
char *s;
@@ -1003,3 +1129,4 @@ CvtStringToARRAY8 (args, num_args, fromVal, toVal)
toVal->addr = (caddr_t) &dest;
toVal->size = sizeof (ARRAY8Ptr);
}
+
diff --git a/config/Xaccess b/config/Xaccess
index b41c4c3..c83cc18 100644
--- a/config/Xaccess
+++ b/config/Xaccess
@@ -1,5 +1,7 @@
# $Xorg: Xaccess,v 1.3 2000/08/17 19:54:17 cpqbld Exp $
#
+# $XFree86: xc/programs/xdm/config/Xaccess,v 1.3 2001/01/17 23:45:24 dawes Exp $
+#
# Access control file for XDMCP connections
#
# To control Direct and Broadcast access:
@@ -37,7 +39,7 @@
# right hand sides can match.
#
-* #any host can get a login window
+#* #any host can get a login window
#
# To hardwire a specific terminal to a specific host, you can
@@ -55,7 +57,7 @@
# so this may not work in all environments.
#
-* CHOOSER BROADCAST #any indirect host can get a chooser
+#* CHOOSER BROADCAST #any indirect host can get a chooser
#
# If you'd prefer to configure the set of hosts each terminal sees,
diff --git a/config/Xservers.ws.cpp b/config/Xservers.ws.cpp
index 6153daf..0041178 100644
--- a/config/Xservers.ws.cpp
+++ b/config/Xservers.ws.cpp
@@ -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
+:0 local BINDIR/X DEFAULTVT
diff --git a/config/xdm-config.cpp b/config/xdm-config.cpp
index 0f81104..b83ccb7 100644
--- a/config/xdm-config.cpp
+++ b/config/xdm-config.cpp
@@ -1,14 +1,20 @@
! $Xorg: xdm-conf.cpp,v 1.3 2000/08/17 19:54:17 cpqbld Exp $
-DisplayManager.errorLogFile: XDMDIR/xdm-errors
-DisplayManager.pidFile: XDMDIR/xdm-pid
+!
+!
+!
+!
+! $XFree86: xc/programs/xdm/config/xdm-conf.cpp,v 1.10 2002/11/30 19:11:32 herrb Exp $
+!
+DisplayManager.errorLogFile: XDMLOGDIR/xdm.log
+DisplayManager.pidFile: XDMPIDDIR/xdm.pid
DisplayManager.keyFile: XDMDIR/xdm-keys
DisplayManager.servers: XDMDIR/Xservers
DisplayManager.accessFile: XDMDIR/Xaccess
+DisplayManager.willing: SU nobody -c XDMDIR/Xwilling
! All displays should use authorization, but we cannot be sure
-! X terminals will be configured that way, so by default
-! use authorization only for local displays :0, :1, etc.
-DisplayManager._0.authorize: true
-DisplayManager._1.authorize: true
+! X terminals may not be configured that way, so they will require
+! individual resource settings.
+DisplayManager*authorize: true
! The following three resources set up display :0 as the console.
DisplayManager._0.setup: XDMDIR/Xsetup_0
DisplayManager._0.startup: XDMDIR/GiveConsole
@@ -16,4 +22,10 @@ DisplayManager._0.reset: XDMDIR/TakeConsole
!
DisplayManager*resources: XDMDIR/Xresources
DisplayManager*session: XDMDIR/Xsession
-DisplayManager*authComplain: false
+DisplayManager*authComplain: true
+#ifdef XPM
+DisplayManager*loginmoveInterval: 10
+#endif /* XPM */
+! SECURITY: do not listen for XDMCP or Chooser requests
+! Comment out this line if you want to manage X terminals with xdm
+DisplayManager.requestPort: 0
diff --git a/daemon.c b/daemon.c
index 937240c..8bfa0de 100644
--- a/daemon.c
+++ b/daemon.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/daemon.c,v 3.20 2002/12/04 16:53:39 tsi Exp $ */
/*
* xdm - display manager daemon
@@ -33,35 +34,42 @@ from The Open Group.
*/
#include <X11/Xos.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef __GLIBC__
+# if defined(__osf__) || \
+ defined(__GNU__) || \
+ defined(__CYGWIN__) || \
+ defined(linux)
+# define setpgrp setpgid
+# endif
+#endif
-#if defined(SVR4) || defined(USG)
-#include <termios.h>
+#if defined(SVR4) || defined(USG) || defined(__GLIBC__)
+# include <termios.h>
#else
-#include <sys/ioctl.h>
-#endif
-#if defined(__osf__) || defined(linux)
-#define setpgrp setpgid
+# include <sys/ioctl.h>
#endif
#ifdef hpux
-#include <sys/ptyio.h>
-#endif
-#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+# include <sys/ptyio.h>
#endif
-#include <sys/types.h>
+
#ifdef X_NOT_POSIX
-#define Pid_t int
+# define Pid_t int
#else
-#define Pid_t pid_t
+# define Pid_t pid_t
#endif
-extern void exit ();
+#include "dm.h"
+#include "dm_error.h"
-BecomeOrphan ()
+void
+BecomeOrphan (void)
{
Pid_t child_id;
- int stat;
/*
* fork so that the process goes into the background automatically. Also
@@ -72,70 +80,81 @@ BecomeOrphan ()
* killed when the init script that's running xdm exits.
*/
- child_id = fork();
+ child_id = fork ();
switch (child_id) {
case 0:
/* child */
break;
case -1:
/* error */
- LogError("daemon fork failed, errno = %d\n", errno);
+ LogError ("daemon fork failed, errno = %d\n", errno);
break;
- default:
+ default: {
/* parent */
-#if defined(SVR4)
- stat = setpgid(child_id, child_id);
- /* This gets error EPERM. Why? */
+#if defined(CSRG_BASED) || defined(SYSV) || defined(SVR4) || defined(__QNXNTO__) || defined(__GLIBC__)
+#if defined(SVR4) || defined(__QNXNTO__)
+ /* This gets error EPERM. Why? */
+ int stat = setpgid(child_id, child_id);
+#elif defined(SYSV)
+ /* don't know how to set child's process group */
+ int stat = 0;
+#elif defined(__GLIBC__)
+ int stat = setpgrp ();
#else
-#if defined(SYSV)
- stat = 0; /* don't know how to set child's process group */
-#else
- stat = setpgrp(child_id, child_id);
- if (stat != 0)
- LogError("setting process grp for daemon failed, errno = %d\n",
- errno);
-#endif
+ int stat = setpgrp (child_id, child_id);
#endif
+ if (stat != 0)
+ LogError ("setting process group for daemon failed: %s\n",
+ strerror(errno));
+#endif /* ! (CSRG_BASED || SYSV || SVR4 || __QNXNTO__ || __GLIBC__) */
+ }
exit (0);
}
}
-BecomeDaemon ()
+void
+BecomeDaemon (void)
{
- register int i;
-
/*
* Close standard file descriptors and get rid of controlling tty
*/
-#if defined(SYSV) || defined(SVR4)
- setpgrp ();
+ /* If our C library has the daemon() function, just use it. */
+#if defined(__GLIBC__) || defined(CSRG_BASED)
+ daemon (0, 0);
#else
- setpgrp (0, getpid());
-#endif
+ int i;
+
+# if defined(SYSV) || defined(SVR4) || defined(__QNXNTO__)
+ setpgrp ();
+# else
+ setpgrp (0, getpid ());
+# endif
- close (0);
+ close (0);
close (1);
close (2);
-#if !((defined(SYSV) || defined(SVR4)) && defined(i386))
+# if !defined(__UNIXOS2__) && !defined(__CYGWIN__)
+# if !((defined(SYSV) || defined(SVR4)) && defined(i386))
if ((i = open ("/dev/tty", O_RDWR)) >= 0) { /* did open succeed? */
-#if defined(USG) && defined(TCCLRCTTY)
+# if defined(USG) && defined(TCCLRCTTY)
int zero = 0;
(void) ioctl (i, TCCLRCTTY, &zero);
-#else
-#if (defined(SYSV) || defined(SVR4)) && defined(TIOCTTY)
+# else
+# if (defined(SYSV) || defined(SVR4)) && defined(TIOCTTY)
int zero = 0;
(void) ioctl (i, TIOCTTY, &zero);
-#else
+# else
(void) ioctl (i, TIOCNOTTY, (char *) 0); /* detach, BSD style */
-#endif
-#endif
+# endif
+# endif
(void) close (i);
}
-#endif /* !i386 */
+# endif /* !((SYSV || SVR4) && i386) */
+# endif /* !__UNIXOS2__ && !__CYGWIN__*/
/*
* Set up the standard file descriptors.
@@ -143,4 +162,5 @@ BecomeDaemon ()
(void) open ("/", O_RDONLY); /* root inode already in core */
(void) dup2 (0, 1);
(void) dup2 (0, 2);
+#endif
}
diff --git a/dm.c b/dm.c
index 4cdbbc0..09834e6 100644
--- a/dm.c
+++ b/dm.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/dm.c,v 3.21 2002/12/07 20:31:04 herrb Exp $ */
/*
* xdm - display manager daemon
@@ -35,6 +36,8 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_auth.h"
+# include "dm_error.h"
# include <stdio.h>
#ifdef X_POSIX_C_SOURCE
@@ -50,6 +53,9 @@ from The Open Group.
#undef _POSIX_SOURCE
#endif
#endif
+#ifdef __NetBSD__
+#include <sys/param.h>
+#endif
#ifndef sigmask
#define sigmask(m) (1 << ((m - 1)))
@@ -58,13 +64,7 @@ from The Open Group.
# include <sys/stat.h>
# include <errno.h>
# include <X11/Xfuncproto.h>
-#if NeedVarargsPrototypes
-# include <stdarg.h>
-# define Va_start(a,b) va_start(a,b)
-#else
-# include <varargs.h>
-# define Va_start(a,b) va_start(a)
-#endif
+# include <stdarg.h>
#ifndef F_TLOCK
#ifndef X_NOT_POSIX
@@ -72,23 +72,22 @@ from The Open Group.
#endif
#endif
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
-
-#ifdef SVR4
+#if defined(SVR4) && !defined(SCO)
extern FILE *fdopen();
#endif
-static void RescanServers ();
-static void ScanServers ();
+static SIGVAL StopAll (int n), RescanNotify (int n);
+static void RescanServers (void);
+static void RestartDisplay (struct display *d, int forceReserver);
+static void ScanServers (void);
+static void SetAccessFileTime (void);
+static void SetConfigFileTime (void);
+static void StartDisplays (void);
+static void TerminateProcess (int pid, int signal);
+
int Rescan;
static long ServersModTime, ConfigModTime, AccessFileModTime;
-static SIGVAL StopAll (), RescanNotify ();
-void StopDisplay ();
-static void RestartDisplay ();
-static void StartDisplays ();
int nofork_session = 0;
@@ -98,14 +97,15 @@ static int TitleLen;
#endif
#ifndef UNRELIABLE_SIGNALS
-static SIGVAL ChildNotify ();
+static SIGVAL ChildNotify (int n);
#endif
+static int StorePid (void);
+
static int parent_pid = -1; /* PID of parent xdm process */
-main (argc, argv)
-int argc;
-char **argv;
+int
+main (int argc, char **argv)
{
int oldpid, oldumask;
char cmdbuf[1024];
@@ -153,7 +153,8 @@ char **argv;
if (nofork_session == 0) {
/* Clean up any old Authorization files */
- sprintf(cmdbuf, "/bin/rm -f %s/authdir/authfiles/A*", authDir);
+ /* AUD: all good? */
+ snprintf(cmdbuf, sizeof(cmdbuf), "/bin/rm -f %s/authdir/authfiles/A*", authDir);
system(cmdbuf);
}
@@ -207,18 +208,20 @@ char **argv;
/* ARGSUSED */
static SIGVAL
-RescanNotify (n)
- int n;
+RescanNotify (int n)
{
+ int olderrno = errno;
+
Debug ("Caught SIGHUP\n");
Rescan = 1;
#ifdef SIGNALS_RESET_WHEN_CAUGHT
(void) Signal (SIGHUP, RescanNotify);
#endif
+ errno = olderrno;
}
static void
-ScanServers ()
+ScanServers (void)
{
char lineBuf[10240];
int len;
@@ -260,14 +263,13 @@ ScanServers ()
}
static void
-MarkDisplay (d)
-struct display *d;
+MarkDisplay (struct display *d)
{
d->state = MissingEntry;
}
static void
-RescanServers ()
+RescanServers (void)
{
Debug ("rescanning servers\n");
LogInfo ("Rescanning both config and servers files\n");
@@ -283,7 +285,8 @@ RescanServers ()
StartDisplays ();
}
-SetConfigFileTime ()
+static void
+SetConfigFileTime (void)
{
struct stat statb;
@@ -291,7 +294,8 @@ SetConfigFileTime ()
ConfigModTime = statb.st_mtime;
}
-SetAccessFileTime ()
+static void
+SetAccessFileTime (void)
{
struct stat statb;
@@ -299,8 +303,8 @@ SetAccessFileTime ()
AccessFileModTime = statb.st_mtime;
}
-static
-RescanIfMod ()
+static void
+RescanIfMod (void)
{
struct stat statb;
@@ -346,9 +350,10 @@ RescanIfMod ()
/* ARGSUSED */
static SIGVAL
-StopAll (n)
- int n;
+StopAll (int n)
{
+ int olderrno = errno;
+
if (parent_pid != getpid())
{
/*
@@ -361,6 +366,7 @@ StopAll (n)
Debug ("Child xdm caught SIGTERM before it remove that signal.\n");
(void) Signal (n, SIG_DFL);
TerminateProcess (getpid(), SIGTERM);
+ errno = olderrno;
return;
}
Debug ("Shutting down entire manager\n");
@@ -373,6 +379,7 @@ StopAll (n)
(void) Signal (SIGTERM, StopAll);
(void) Signal (SIGINT, StopAll);
#endif
+ errno = olderrno;
}
/*
@@ -385,19 +392,25 @@ int ChildReady;
#ifndef UNRELIABLE_SIGNALS
/* ARGSUSED */
static SIGVAL
-ChildNotify (n)
- int n;
+ChildNotify (int n)
{
+ int olderrno = errno;
+
ChildReady = 1;
+#ifdef ISC
+ (void) Signal (SIGCHLD, ChildNotify);
+#endif
+ errno = olderrno;
}
#endif
-WaitForChild ()
+void
+WaitForChild (void)
{
int pid;
struct display *d;
waitType status;
-#ifndef X_NOT_POSIX
+#if !defined(X_NOT_POSIX) && !defined(__UNIXOS2__)
sigset_t mask, omask;
#else
int omask;
@@ -412,10 +425,11 @@ WaitForChild ()
sigaddset(&mask, SIGCHLD);
sigaddset(&mask, SIGHUP);
sigprocmask(SIG_BLOCK, &mask, &omask);
+ Debug ("signals blocked\n");
#else
omask = sigblock (sigmask (SIGCHLD) | sigmask (SIGHUP));
-#endif
Debug ("signals blocked, mask was 0x%x\n", omask);
+#endif
if (!ChildReady && !Rescan)
#ifndef X_NOT_POSIX
sigsuspend(&omask);
@@ -493,13 +507,30 @@ WaitForChild ()
StopDisplay(d);
else
RestartDisplay (d, TRUE);
+ {
+ Time_t Time;
+ time(&Time);
+ Debug("time %i %i\n",Time,d->lastCrash);
+ if (d->lastCrash &&
+ ((Time - d->lastCrash) < XDM_BROKEN_INTERVAL)) {
+ Debug("Server crash frequency too high:"
+ " removing display %s\n",d->name);
+ LogError("Server crash rate too high:"
+ " removing display %s\n",d->name);
+ RemoveDisplay (d);
+ } else
+ d->lastCrash = Time;
+ }
break;
case waitCompose (SIGTERM,0,0):
- d->startTries = 0;
- Debug ("Display exited on SIGTERM\n");
- if (d->displayType.origin == FromXDMCP || d->status == zombie)
+ Debug ("Display exited on SIGTERM, try %d of %d\n",
+ d->startTries, d->startAttempts);
+ if (d->displayType.origin == FromXDMCP ||
+ d->status == zombie ||
+ ++d->startTries >= d->startAttempts) {
+ LogError ("Display %s is being disabled\n", d->name);
StopDisplay(d);
- else
+ } else
RestartDisplay (d, TRUE);
break;
case REMANAGE_DISPLAY:
@@ -531,13 +562,13 @@ WaitForChild ()
d->status = notRunning;
break;
case running:
- Debug ("Server for display %s terminated unexpectedly, status %d\n", d->name, waitVal (status));
+ Debug ("Server for display %s terminated unexpectedly, status %d %d\n", d->name, waitVal (status), status);
LogError ("Server for display %s terminated unexpectedly: %d\n", d->name, waitVal (status));
if (d->pid != -1)
{
Debug ("Terminating session pid %d\n", d->pid);
TerminateProcess (d->pid, SIGTERM);
- }
+ }
break;
case notRunning:
Debug ("Server exited for notRunning session on display %s\n", d->name);
@@ -553,8 +584,7 @@ WaitForChild ()
}
static void
-CheckDisplayStatus (d)
-struct display *d;
+CheckDisplayStatus (struct display *d)
{
if (d->displayType.origin == FromFile)
{
@@ -573,14 +603,13 @@ struct display *d;
}
static void
-StartDisplays ()
+StartDisplays (void)
{
ForEachDisplay (CheckDisplayStatus);
}
void
-StartDisplay (d)
-struct display *d;
+StartDisplay (struct display *d)
{
int pid;
@@ -651,7 +680,8 @@ struct display *d;
}
}
-TerminateProcess (pid, signal)
+static void
+TerminateProcess (int pid, int signal)
{
kill (pid, signal);
#ifdef SIGCONT
@@ -664,8 +694,7 @@ TerminateProcess (pid, signal)
*/
void
-StopDisplay (d)
- struct display *d;
+StopDisplay (struct display *d)
{
if (d->serverPid != -1)
d->status = zombie; /* be careful about race conditions */
@@ -682,9 +711,7 @@ StopDisplay (d)
*/
static void
-RestartDisplay (d, forceReserver)
- struct display *d;
- int forceReserver;
+RestartDisplay (struct display *d, int forceReserver)
{
if (d->serverPid != -1 && (forceReserver || d->terminateServer))
{
@@ -700,16 +727,16 @@ RestartDisplay (d, forceReserver)
static FD_TYPE CloseMask;
static int max;
-RegisterCloseOnFork (fd)
-int fd;
+void
+RegisterCloseOnFork (int fd)
{
FD_SET (fd, &CloseMask);
if (fd > max)
max = fd;
}
-ClearCloseOnFork (fd)
-int fd;
+void
+ClearCloseOnFork (int fd)
{
FD_CLR (fd, &CloseMask);
if (fd == max) {
@@ -720,13 +747,16 @@ int fd;
}
}
-CloseOnFork ()
+void
+CloseOnFork (void)
{
int fd;
for (fd = 0; fd <= max; fd++)
if (FD_ISSET (fd, &CloseMask))
+ {
close (fd);
+ }
FD_ZERO (&CloseMask);
max = 0;
}
@@ -734,12 +764,13 @@ CloseOnFork ()
static int pidFd;
static FILE *pidFilePtr;
-StorePid ()
+static int
+StorePid (void)
{
int oldpid;
if (pidFile[0] != '\0') {
- pidFd = open (pidFile, 2);
+ pidFd = open (pidFile, O_RDWR);
if (pidFd == -1 && errno == ENOENT)
pidFd = open (pidFile, O_RDWR|O_CREAT, 0666);
if (pidFd == -1 || !(pidFilePtr = fdopen (pidFd, "r+")))
@@ -788,14 +819,16 @@ StorePid ()
#endif
#endif
}
- fprintf (pidFilePtr, "%5d\n", getpid ());
+ fprintf (pidFilePtr, "%5ld\n", (long)getpid ());
(void) fflush (pidFilePtr);
RegisterCloseOnFork (pidFd);
}
return 0;
}
-UnlockPidFile ()
+#if 0
+void
+UnlockPidFile (void)
{
if (lockPidFile)
#ifdef F_SETLK
@@ -816,15 +849,10 @@ UnlockPidFile ()
close (pidFd);
fclose (pidFilePtr);
}
-
-#if NeedVarargsPrototypes
-SetTitle (char *name, ...)
-#else
-/*VARARGS*/
-SetTitle (name, va_alist)
-char *name;
-va_dcl
#endif
+
+#ifndef HAS_SETPROCTITLE
+void SetTitle (char *name, ...)
{
#ifndef NOXDMTITLE
char *p = Title;
@@ -832,7 +860,7 @@ va_dcl
char *s;
va_list args;
- Va_start(args,name);
+ va_start(args,name);
*p++ = '-';
--left;
s = name;
@@ -853,3 +881,4 @@ va_dcl
va_end(args);
#endif
}
+#endif
diff --git a/dm.h b/dm.h
index 801ceab..1df6f88 100644
--- a/dm.h
+++ b/dm.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/dm.h,v 3.29 2002/05/31 18:46:10 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -36,25 +37,26 @@ from The Open Group.
* public interfaces for greet/verify functionality
*/
+#ifndef _DM_H_
+#define _DM_H_ 1
+
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
#include <X11/Xmd.h>
#include <X11/Xauth.h>
+#include <X11/Intrinsic.h>
#if defined(X_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
#include <setjmp.h>
#include <limits.h>
#undef _POSIX_C_SOURCE
-#elif defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
-#include <setjmp.h>
-#include <limits.h>
#else
-#define _POSIX_SOURCE
#include <setjmp.h>
#include <limits.h>
-#undef _POSIX_SOURCE
#endif
+#include <time.h>
+#define Time_t time_t
/* If XDMCP symbol defined, compile to run XDMCP protocol */
@@ -73,6 +75,10 @@ from The Open Group.
#include <sys/wait.h>
#else
#define _POSIX_SOURCE
+#ifdef SCO325
+#include <sys/procset.h>
+#include <sys/siginfo.h>
+#endif
#include <sys/wait.h>
#undef _POSIX_SOURCE
#endif
@@ -95,6 +101,21 @@ typedef union wait waitType;
#endif
#endif /* X_NOT_POSIX */
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#endif
+
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#ifdef HAS_SETUSERCONTEXT
+#include <login_cap.h>
+#include <pwd.h>
+#ifdef USE_BSDAUTH
+#include <bsd_auth.h>
+#endif
+#endif
+#endif
+
# define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code))
# define waitVal(w) waitCompose(waitSig(w), waitCore(w), waitCode(w))
@@ -135,7 +156,7 @@ typedef struct displayType {
# define FromFile 1
# define FromXDMCP 0
-extern DisplayType parseDisplayType ();
+extern DisplayType parseDisplayType (char *string, int *usedDefault);
typedef enum fileState { NewEntry, OldEntry, MissingEntry } FileState;
@@ -153,7 +174,7 @@ struct display {
int 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 */
#ifdef XDMCP
/* XDMCP state */
CARD32 sessionID; /* ID of active session */
@@ -212,12 +233,16 @@ struct display {
int version; /* to keep dynamic greeter clued in */
/* add new fields only after here. And preferably at the end. */
+
+ /* Hack for making "Willing to manage" configurable */
+ char *willing; /* "Willing to manage" program */
};
#ifdef XDMCP
#define PROTO_TIMEOUT (30 * 60) /* 30 minutes should be long enough */
-
+#define XDM_BROKEN_INTERVAL (120) /* server crashing more than once within */
+ /* two minutes is assumed to be broken! */
struct protoDisplay {
struct protoDisplay *next;
XdmcpNetaddr address; /* UDP address */
@@ -242,15 +267,19 @@ struct greet_info {
char *passwd; /* binary compat with DEC */
int version; /* for dynamic greeter to see */
/* add new fields below this line, and preferably at the end */
+ Boolean allow_null_passwd; /* allow null password on login */
+ Boolean allow_root_login; /* allow direct root login */
};
/* setgroups is not covered by POSIX, arg type varies */
-#if defined(SYSV) || defined(SVR4) || defined(__osf__) || defined(linux)
+#if defined(SYSV) || defined(SVR4) || defined(__osf__) || defined(linux) || defined(__GNU__)
#define GID_T gid_t
#else
#define GID_T int
#endif
+typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure);
+
struct verify_info {
int uid; /* user id */
int gid; /* group id */
@@ -291,38 +320,153 @@ extern char *accessFile;
extern char **exportList;
extern char *randomFile;
extern char *greeterLib;
+extern char *willing;
extern int choiceTimeout; /* chooser choice timeout */
-extern struct display *FindDisplayByName (),
- *FindDisplayBySessionID (),
- *FindDisplayByAddress (),
- *FindDisplayByPid (),
- *FindDisplayByServerPid (),
- *NewDisplay ();
+extern struct display *FindDisplayByName (char *name),
+ *FindDisplayBySessionID (CARD32 sessionID),
+ *FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber),
+ *FindDisplayByPid (int pid),
+ *FindDisplayByServerPid (int serverPid),
+ *NewDisplay (char *name, char *class);
+
+extern struct protoDisplay *FindProtoDisplay (
+ XdmcpNetaddr address,
+ int addrlen,
+ CARD16 displayNumber);
+extern struct protoDisplay *NewProtoDisplay (
+ XdmcpNetaddr address,
+ int addrlen,
+ CARD16 displayNumber,
+ CARD16 connectionType,
+ ARRAY8Ptr connectionAddress,
+ CARD32 sessionID);
+
+/* in Login.c */
+extern void DrawFail (Widget ctx);
+
+/* in access.c */
+extern ARRAY8Ptr getLocalAddress (void);
+extern int AcceptableDisplayAddress (ARRAY8Ptr clientAddress, CARD16 connectionType, xdmOpCode type);
+extern int ForEachMatchingIndirectHost (ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure);
+extern int ScanAccessDatabase (void);
+extern int UseChooser (ARRAY8Ptr clientAddress, CARD16 connectionType);
+extern void ForEachChooserHost (ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure);
+
+/* in choose.c */
+extern ARRAY8Ptr IndirectChoice (ARRAY8Ptr clientAddress, CARD16 connectionType);
+extern int IsIndirectClient (ARRAY8Ptr clientAddress, CARD16 connectionType);
+extern int RememberIndirectClient (ARRAY8Ptr clientAddress, CARD16 connectionType);
+extern void ForgetIndirectClient ( ARRAY8Ptr clientAddress, CARD16 connectionType);
+extern void ProcessChooserSocket (int fd);
+
+/* in chooser.c */
+extern void RunChooser (struct display *d);
+
+/* in daemon.c */
+extern void BecomeDaemon (void);
+extern void BecomeOrphan (void);
-extern struct protoDisplay *FindProtoDisplay (),
- *NewProtoDisplay ();
-
-extern char *localHostname ();
+/* in dm.c */
+extern void CloseOnFork (void);
+extern void RegisterCloseOnFork (int fd);
+extern void StartDisplay (struct display *d);
+#ifndef HAS_SETPROCTITLE
+extern void SetTitle (char *name, ...);
+#endif
-/* in xdmcp.c */
-extern void init_session_id();
-extern void registerHostname();
+/* in dpylist.c */
+extern int AnyDisplaysLeft (void);
+extern void ForEachDisplay (void (*f)(struct display *));
+extern void RemoveDisplay (struct display *old);
-/* in dm.c */
-extern void StartDisplay();
+/* in file.c */
+extern void ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable);
-/* in session.c */
-extern void execute();
+/* in netaddr.c */
+extern char *NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp);
+extern char *NetaddrPort(XdmcpNetaddr netaddrp, int *lenp);
+extern int ConvertAddr (XdmcpNetaddr saddr, int *len, char **addr);
+extern int NetaddrFamily (XdmcpNetaddr netaddrp);
+extern int addressEqual (XdmcpNetaddr a1, int len1, XdmcpNetaddr a2, int len2);
-/* in auth.c */
-extern void SetLocalAuthorization();
-extern void SetUserAuthorization();
-extern void RemoveUserAuthorization();
-extern void CleanUpFileName();
+/* in policy.c */
+#if 0
+extern ARRAY8Ptr Accept (/* struct sockaddr *from, int fromlen, CARD16 displayNumber */);
+#endif
+extern ARRAY8Ptr ChooseAuthentication (ARRAYofARRAY8Ptr authenticationNames);
+extern int CheckAuthentication (struct protoDisplay *pdpy, ARRAY8Ptr displayID, ARRAY8Ptr name, ARRAY8Ptr data);
+extern int SelectAuthorizationTypeIndex (ARRAY8Ptr authenticationName, ARRAYofARRAY8Ptr authorizationNames);
+extern int SelectConnectionTypeIndex (ARRAY16Ptr connectionTypes, ARRAYofARRAY8Ptr connectionAddresses);
+extern int Willing (ARRAY8Ptr addr, CARD16 connectionType, ARRAY8Ptr authenticationName, ARRAY8Ptr status, xdmOpCode type);
/* in protodpy.c */
-extern void DisposeProtoDisplay();
+extern void DisposeProtoDisplay(struct protoDisplay *pdpy);
+
+/* in reset.c */
+extern void pseudoReset (Display *dpy);
+
+/* in resource.c */
+extern void InitResources (int argc, char **argv);
+extern void LoadDMResources (void);
+extern void LoadServerResources (struct display *d);
+extern void LoadSessionResources (struct display *d);
+extern void ReinitResources (void);
+
+/* in session.c */
+#ifdef USE_PAM
+extern pam_handle_t **thepamhp(void);
+extern pam_handle_t *thepamh(void);
+#endif
+extern char **defaultEnv (void);
+extern char **systemEnv (struct display *d, char *user, char *home);
+extern int PingServer(struct display *d, Display *alternateDpy);
+extern int source (char **environ, char *file);
+extern void ClearCloseOnFork (int fd);
+extern void DeleteXloginResources (struct display *d, Display *dpy);
+extern void LoadXloginResources (struct display *d);
+extern void ManageSession (struct display *d);
+extern void SecureDisplay (struct display *d, Display *dpy);
+extern void SessionExit (struct display *d, int status, int removeAuth);
+extern void SessionPingFailed (struct display *d);
+extern void SetupDisplay (struct display *d);
+extern void UnsecureDisplay (struct display *d, Display *dpy);
+extern void execute(char **argv, char **environ);
+
+/* server.c */
+extern char *_SysErrorMsg (int n);
+extern int StartServer (struct display *d);
+extern int WaitForServer (struct display *d);
+extern void ResetServer (struct display *d);
+
+/* socket.c */
+extern int GetChooserAddr (char *addr, int *lenp);
+extern void CreateWellKnownSockets (void);
+
+/* in util.c */
+extern char *localHostname (void);
+extern char **parseArgs (char **argv, char *string);
+extern char **setEnv (char **e, char *name, char *value);
+extern char **putEnv(const char *string, char **env);
+extern char *getEnv (char **e, char *name);
+extern void CleanUpChild (void);
+extern void freeArgs (char **argv);
+extern void freeEnv (char **env);
+extern void printEnv (char **e);
+
+/* in verify.c */
+extern int Verify (struct display *d, struct greet_info *greet, struct verify_info *verify);
+
+/* in xdmcp.c */
+extern char *NetworkAddressToHostname (CARD16 connectionType, ARRAY8Ptr connectionAddress);
+extern int AnyWellKnownSockets (void);
+extern void DestroyWellKnownSockets (void);
+extern void SendFailed (struct display *d, char *reason);
+extern void StopDisplay (struct display *d);
+extern void WaitForChild (void);
+extern void WaitForSomething (void);
+extern void init_session_id(void);
+extern void registerHostname(char *name, int namelen);
/*
* CloseOnFork flags
@@ -331,11 +475,7 @@ extern void DisposeProtoDisplay();
# define CLOSE_ALWAYS 0
# define LEAVE_FOR_DISPLAY 1
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#else
-char *malloc(), *realloc();
-#endif
#if defined(X_NOT_POSIX) && defined(SIGNALRETURNSINT)
#define SIGVAL int
@@ -343,8 +483,8 @@ char *malloc(), *realloc();
#define SIGVAL void
#endif
-#ifdef X_NOT_POSIX
-#ifdef SYSV
+#if defined(X_NOT_POSIX) || defined(__UNIXOS2__) || defined(__NetBSD__) && defined(__sparc__)
+#if defined(SYSV) || defined(__UNIXOS2__)
#define SIGNALS_RESET_WHEN_CAUGHT
#define UNRELIABLE_SIGNALS
#endif
@@ -357,4 +497,8 @@ char *malloc(), *realloc();
#define Jmp_buf sigjmp_buf
#endif
-SIGVAL (*Signal())();
+typedef SIGVAL (*SIGFUNC)(int);
+
+SIGVAL (*Signal(int, SIGFUNC Handler))(int);
+
+#endif /* _DM_H_ */
diff --git a/dpylist.c b/dpylist.c
index 6dcaafa..cbd8009 100644
--- a/dpylist.c
+++ b/dpylist.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/dpylist.c,v 1.5 2001/12/14 20:01:21 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,16 +36,18 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
static struct display *displays;
-AnyDisplaysLeft ()
+int
+AnyDisplaysLeft (void)
{
return displays != (struct display *) 0;
}
-ForEachDisplay (f)
- void (*f)();
+void
+ForEachDisplay (void (*f)(struct display *))
{
struct display *d, *next;
@@ -55,8 +58,7 @@ ForEachDisplay (f)
}
struct display *
-FindDisplayByName (name)
-char *name;
+FindDisplayByName (char *name)
{
struct display *d;
@@ -67,8 +69,7 @@ char *name;
}
struct display *
-FindDisplayByPid (pid)
-int pid;
+FindDisplayByPid (int pid)
{
struct display *d;
@@ -79,8 +80,7 @@ int pid;
}
struct display *
-FindDisplayByServerPid (serverPid)
-int serverPid;
+FindDisplayByServerPid (int serverPid)
{
struct display *d;
@@ -93,8 +93,7 @@ int serverPid;
#ifdef XDMCP
struct display *
-FindDisplayBySessionID (sessionID)
- CARD32 sessionID;
+FindDisplayBySessionID (CARD32 sessionID)
{
struct display *d;
@@ -105,10 +104,7 @@ FindDisplayBySessionID (sessionID)
}
struct display *
-FindDisplayByAddress (addr, addrlen, displayNumber)
- XdmcpNetaddr addr;
- int addrlen;
- CARD16 displayNumber;
+FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber)
{
struct display *d;
@@ -126,8 +122,8 @@ FindDisplayByAddress (addr, addrlen, displayNumber)
#define IfFree(x) if (x) free ((char *) x)
-RemoveDisplay (old)
-struct display *old;
+void
+RemoveDisplay (struct display *old)
{
struct display *d, *p;
char **x;
@@ -184,9 +180,7 @@ struct display *old;
}
struct display *
-NewDisplay (name, class)
-char *name;
-char *class;
+NewDisplay (char *name, char *class)
{
struct display *d;
@@ -250,6 +244,7 @@ char *class;
d->openTimeout = 0;
d->startAttempts = 0;
d->startTries = 0;
+ d->lastCrash = 0;
d->terminateServer = 0;
d->grabTimeout = 0;
#ifdef XDMCP
@@ -268,7 +263,3 @@ char *class;
displays = d;
return d;
}
-
-
-
-
diff --git a/error.c b/error.c
index f80468f..6c53ec6 100644
--- a/error.c
+++ b/error.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/error.c,v 1.7 2002/10/09 16:38:20 tsi Exp $ */
/*
* xdm - display manager daemon
@@ -37,114 +38,73 @@ from The Open Group.
* we generally do not have a terminal to talk to
*/
-# include "dm.h"
# include <stdio.h>
-#if NeedVarargsPrototypes
# include <stdarg.h>
-#else
-/* this type needs to be big enough to contain int or pointer */
-typedef long Fmtarg_t;
-#endif
-
-/*VARARGS1*/
-LogInfo(
-#if NeedVarargsPrototypes
- char * fmt, ...)
-#else
- fmt, arg1, arg2, arg3, arg4, arg5, arg6)
- char *fmt;
- Fmtarg_t arg1, arg2, arg3, arg4, arg5, arg6;
-#endif
+
+# include "dm.h"
+# include "dm_error.h"
+
+#define WRITES(fd, buf) write(fd, buf, strlen(buf))
+
+void LogInfo(char * fmt, ...)
{
- fprintf (stderr, "xdm info (pid %d): ", getpid());
-#if NeedVarargsPrototypes
+ char buf[1024];
+
+ snprintf(buf, sizeof buf, "xdm info (pid %ld): ", (long)getpid());
+ WRITES(STDERR_FILENO, buf);
{
va_list args;
va_start(args, fmt);
- vfprintf (stderr, fmt, args);
+ vsnprintf (buf, sizeof buf, fmt, args);
va_end(args);
}
-#else
- fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
- fflush (stderr);
+ WRITES(STDERR_FILENO, buf);
}
-/*VARARGS1*/
-LogError (
-#if NeedVarargsPrototypes
- char * fmt, ...)
-#else
- fmt, arg1, arg2, arg3, arg4, arg5, arg6)
- char *fmt;
- Fmtarg_t arg1, arg2, arg3, arg4, arg5, arg6;
-#endif
+void LogError (char * fmt, ...)
{
- fprintf (stderr, "xdm error (pid %d): ", getpid());
-#if NeedVarargsPrototypes
+ char buf[1024];
+
+ snprintf (buf, sizeof buf, "xdm error (pid %ld): ", (long)getpid());
+ WRITES(STDERR_FILENO, buf);
{
va_list args;
va_start(args, fmt);
- vfprintf (stderr, fmt, args);
+ vsnprintf (buf, sizeof buf, fmt, args);
va_end(args);
}
-#else
- fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
- fflush (stderr);
+ WRITES(STDERR_FILENO, buf);
}
-/*VARARGS1*/
-LogPanic (
-#if NeedVarargsPrototypes
- char * fmt, ...)
-#else
- fmt, arg1, arg2, arg3, arg4, arg5, arg6)
- char *fmt;
- Fmtarg_t arg1, arg2, arg3, arg4, arg5, arg6;
-#endif
+void LogPanic (char * fmt, ...)
{
- fprintf (stderr, "xdm panic (pid %d): ", getpid());
-#if NeedVarargsPrototypes
+ char buf[1024];
+
+ snprintf (buf, sizeof buf, "xdm panic (pid %ld): ", (long)getpid());
+ WRITES(STDERR_FILENO, buf);
{
va_list args;
va_start(args, fmt);
- vfprintf (stderr, fmt, args);
+ vsnprintf (buf, sizeof buf, fmt, args);
va_end(args);
}
-#else
- fprintf (fmt, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
- fflush (stderr);
- exit (1);
+ WRITES(STDERR_FILENO, buf);
+ _exit (1);
}
-/*VARARGS1*/
-LogOutOfMem (
-#if NeedVarargsPrototypes
- char * fmt, ...)
-#else
- fmt, arg1, arg2, arg3, arg4, arg5, arg6)
- char *fmt;
- Fmtarg_t arg1, arg2, arg3, arg4, arg5, arg6;
-#endif
+void LogOutOfMem (char * fmt, ...)
{
fprintf (stderr, "xdm: out of memory in routine ");
-#if NeedVarargsPrototypes
{
va_list args;
va_start(args, fmt);
vfprintf (stderr, fmt, args);
va_end(args);
}
-#else
- fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
fflush (stderr);
}
-Panic (mesg)
-char *mesg;
+void Panic (char *mesg)
{
int i;
@@ -155,31 +115,21 @@ char *mesg;
}
-/*VARARGS1*/
-Debug (
-#if NeedVarargsPrototypes
- char * fmt, ...)
-#else
- fmt, arg1, arg2, arg3, arg4, arg5, arg6)
- char *fmt;
- Fmtarg_t arg1, arg2, arg3, arg4, arg5, arg6;
-#endif
+void Debug (char * fmt, ...)
{
+ char buf[1024];
+
if (debugLevel > 0)
{
-#if NeedVarargsPrototypes
va_list args;
va_start(args, fmt);
- vprintf (fmt, args);
+ vsnprintf (buf, sizeof buf, fmt, args);
va_end(args);
-#else
- printf (fmt, arg1, arg2, arg3, arg4, arg5, arg6);
-#endif
- fflush (stdout);
+ WRITES(STDOUT_FILENO, buf);
}
}
-InitErrorLog ()
+void InitErrorLog (void)
{
int i;
if (errorLogFile[0]) {
diff --git a/file.c b/file.c
index 547b739..49b2217 100644
--- a/file.c
+++ b/file.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/file.c,v 1.6 2001/12/14 20:01:21 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,10 +36,12 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
+
# include <ctype.h>
-DisplayTypeMatch (d1, d2)
-DisplayType d1, d2;
+static int
+DisplayTypeMatch (DisplayType d1, DisplayType d2)
{
return d1.location == d2.location &&
d1.lifetime == d2.lifetime &&
@@ -46,8 +49,7 @@ DisplayType d1, d2;
}
static void
-freeArgs (args)
- char **args;
+freeFileArgs (char **args)
{
char **a;
@@ -57,8 +59,7 @@ freeArgs (args)
}
static char **
-splitIntoWords (s)
- char *s;
+splitIntoWords (char *s)
{
char **args, **newargs;
char *wordStart;
@@ -87,7 +88,7 @@ splitIntoWords (s)
(nargs+2)*sizeof (char *));
if (!newargs)
{
- freeArgs (args);
+ freeFileArgs (args);
return NULL;
}
args = newargs;
@@ -95,7 +96,7 @@ splitIntoWords (s)
args[nargs] = malloc (s - wordStart + 1);
if (!args[nargs])
{
- freeArgs (args);
+ freeFileArgs (args);
return NULL;
}
strncpy (args[nargs], wordStart, s - wordStart);
@@ -107,8 +108,7 @@ splitIntoWords (s)
}
static char **
-copyArgs (args)
- char **args;
+copyArgs (char **args)
{
char **a, **new, **n;
@@ -127,9 +127,8 @@ copyArgs (args)
return new;
}
-freeSomeArgs (args, n)
- char **args;
- int n;
+static void
+freeSomeArgs (char **args, int n)
{
char **a;
@@ -139,10 +138,8 @@ freeSomeArgs (args, n)
free ((char *) args);
}
-ParseDisplay (source, acceptableTypes, numAcceptable)
-char *source;
-DisplayType *acceptableTypes;
-int numAcceptable;
+void
+ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable)
{
char **args, **argv, **a;
char *name, *class, *type;
@@ -156,14 +153,14 @@ int numAcceptable;
if (!args[0])
{
LogError ("Missing display name in servers file\n");
- freeArgs (args);
+ freeFileArgs (args);
return;
}
name = args[0];
if (!args[1])
{
LogError ("Missing display type for %s\n", args[0]);
- freeArgs (args);
+ freeFileArgs (args);
return;
}
displayType = parseDisplayType (args[1], &usedDefault);
@@ -215,7 +212,7 @@ int numAcceptable;
}
}
Debug ("Found existing display: %s %s %s", d->name, d->class , type);
- freeArgs (d->argv);
+ freeFileArgs (d->argv);
}
else
{
@@ -235,15 +232,13 @@ static struct displayMatch {
char *name;
DisplayType type;
} displayTypes[] = {
- "local", { Local, Permanent, FromFile },
- "foreign", { Foreign, Permanent, FromFile },
- 0, { Local, Permanent, FromFile },
+ { "local", { Local, Permanent, FromFile } },
+ { "foreign", { Foreign, Permanent, FromFile } },
+ { 0, { Local, Permanent, FromFile } },
};
DisplayType
-parseDisplayType (string, usedDefault)
- char *string;
- int *usedDefault;
+parseDisplayType (char *string, int *usedDefault)
{
struct displayMatch *d;
diff --git a/genauth.c b/genauth.c
index a4f8ced..0568e6f 100644
--- a/genauth.c
+++ b/genauth.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/genauth.c,v 3.15 2002/10/06 18:12:29 herrb Exp $ */
/*
* xdm - display manager daemon
@@ -34,18 +35,15 @@ from The Open Group.
# include <X11/Xauth.h>
# include <X11/Xos.h>
+
# include "dm.h"
+# include "dm_auth.h"
+# include "dm_error.h"
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-#define Time_t long
-extern Time_t time ();
-extern int errno;
-#else
#include <time.h>
#define Time_t time_t
-#endif
static unsigned char key[8];
@@ -57,10 +55,8 @@ typedef struct auth_ks_struct { auth_cblock _; } auth_wrapper_schedule[16];
extern void _XdmcpWrapperToOddParity();
-static
-longtochars (l, c)
- long l;
- unsigned char *c;
+static void
+longtochars (long l, unsigned char *c)
{
c[0] = (l >> 24) & 0xff;
c[1] = (l >> 16) & 0xff;
@@ -72,10 +68,9 @@ longtochars (l, c)
# define FILE_LIMIT 1024 /* no more than this many buffers */
+#if !defined(ARC4_RANDOM) && !defined(DEV_RANDOM)
static int
-sumFile (name, sum)
-char *name;
-long sum[2];
+sumFile (char *name, long sum[2])
{
long buf[1024*2];
int cnt;
@@ -85,7 +80,7 @@ long sum[2];
int i;
int ret_status = 0;
- fd = open (name, 0);
+ fd = open (name, O_RDONLY);
if (fd < 0) {
LogError("Cannot open randomFile \"%s\", errno = %d\n", name, errno);
return 0;
@@ -109,12 +104,37 @@ long sum[2];
close (fd);
return ret_status;
}
+#endif
#ifdef HASXDMAUTH
-
-static
-InitXdmcpWrapper ()
+static void
+InitXdmcpWrapper (void)
{
+
+#ifdef ARC4_RANDOM
+ u_int32_t sum[2];
+
+ sum[0] = arc4random();
+ sum[1] = arc4random();
+ *(u_char *)sum = 0;
+
+ _XdmcpWrapperToOddParity(sum, key);
+
+#elif defined(DEV_RANDOM)
+ int fd;
+ unsigned char tmpkey[8];
+
+ if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) {
+ if (read(fd, tmpkey, 8) == 8) {
+ tmpkey[0] = 0;
+ _XdmcpWrapperToOddParity(tmpkey, key);
+ close(fd);
+ return;
+ } else {
+ close(fd);
+ }
+ }
+#else
long sum[2];
unsigned char tmpkey[8];
@@ -126,6 +146,7 @@ InitXdmcpWrapper ()
longtochars (sum[1], tmpkey+4);
tmpkey[0] = 0;
_XdmcpWrapperToOddParity (tmpkey, key);
+#endif
}
#endif
@@ -138,23 +159,21 @@ InitXdmcpWrapper ()
static unsigned long int next = 1;
static int
-xdm_rand()
+xdm_rand(void)
{
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
static void
-xdm_srand(seed)
- unsigned int seed;
+xdm_srand(unsigned int seed)
{
next = seed;
}
#endif /* no HASXDMAUTH */
-GenerateAuthData (auth, len)
-char *auth;
-int len;
+void
+GenerateAuthData (char *auth, int len)
{
long ldata[2];
@@ -168,7 +187,9 @@ int len;
}
#else
{
+#ifndef __UNIXOS2__
long time ();
+#endif
ldata[0] = time ((long *) 0);
ldata[1] = getpid ();
@@ -193,8 +214,8 @@ int len;
for (i = 0; i < len; i++) {
auth[i] = 0;
for (bit = 1; bit < 256; bit <<= 1) {
- _XdmcpAuthDoIt (data, data, schedule, 1);
- if (data[0] + data[1] & 0x4)
+ _XdmcpAuthDoIt (data, data, schedule, 1);
+ if ((data[0] + data[1]) & 0x4)
auth[i] |= bit;
}
}
@@ -207,9 +228,25 @@ int len;
static long localkey[2] = {0,0};
if ( (localkey[0] == 0) && (localkey[1] == 0) ) {
+#ifdef ARC4_RANDOM
+ localkey[0] = arc4random();
+ localkey[1] = arc4random();
+#elif defined(DEV_RANDOM)
+ int fd;
+
+ if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) {
+ if (read(fd, (char *)localkey, 8) != 8) {
+ localkey[0] = 1;
+ }
+ close(fd);
+ } else {
+ localkey[0] = 1;
+ }
+#else
if (!sumFile (randomFile, localkey)) {
localkey[0] = 1; /* To keep from continually calling sumFile() */
}
+#endif
}
seed = (ldata[0]+localkey[0]) + ((ldata[1]+localkey[1]) << 16);
diff --git a/greet.h b/greet.h
index a45d971..e826d40 100644
--- a/greet.h
+++ b/greet.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/greet.h,v 1.8 2001/12/14 20:01:22 dawes Exp $ */
/*
* greet.h - interface to xdm's dynamically-loadable modular greeter
@@ -33,34 +34,60 @@ from The Open Group.
#include <X11/Xlib.h>
+/*
+ * Do this rather than break a build over a const-mismatch
+ */
+#if defined(__linux__) || defined(CSRG_BASED)
+#define CRYPT_ARGS const char *s1, const char *s2
+#define GETSPNAM_ARGS const char *name
+#define GETPWNAM_ARGS const char *name
+#else
+#define CRYPT_ARGS /*unknown*/
+#define GETSPNAM_ARGS /*unknown*/
+#define GETPWNAM_ARGS /*unknown*/
+#endif
+
+#if defined(__FreeBSD__) || defined(__bsdi__) || defined(__osf__)
+#define SETGRENT_TYPE int
+#else
+#define SETGRENT_TYPE void
+#endif
+
struct dlfuncs {
- int (*_PingServer)();
- int (*_SessionPingFailed)();
- int (*_Debug)();
- int (*_RegisterCloseOnFork)();
- int (*_SecureDisplay)();
- int (*_UnsecureDisplay)();
- int (*_ClearCloseOnFork)();
- int (*_SetupDisplay)();
- int (*_LogError)();
- int (*_SessionExit)();
- int (*_DeleteXloginResources)();
- int (*_source)();
- char **(*_defaultEnv)();
- char **(*_setEnv)();
- char **(*_parseArgs)();
- int (*_printEnv)();
- char **(*_systemEnv)();
- int (*_LogOutOfMem)();
- void (*_setgrent)(); /* no longer used */
- struct group *(*_getgrent)(); /* no longer used */
- void (*_endgrent)(); /* no longer used */
+ int (*_PingServer)(struct display *d, Display *alternateDpy);
+ void (*_SessionPingFailed)(struct display *d);
+ void (*_Debug)(char * fmt, ...);
+ void (*_RegisterCloseOnFork)(int fd);
+ void (*_SecureDisplay)(struct display *d, Display *dpy);
+ void (*_UnsecureDisplay)(struct display *d, Display *dpy);
+ void (*_ClearCloseOnFork)(int fd);
+ void (*_SetupDisplay)(struct display *d);
+ void (*_LogError)(char * fmt, ...);
+ void (*_SessionExit)(struct display *d, int status, int removeAuth);
+ void (*_DeleteXloginResources)(struct display *d, Display *dpy);
+ int (*_source)(char **environ, char *file);
+ char **(*_defaultEnv)(void);
+ char **(*_setEnv)(char **e, char *name, char *value);
+ char **(*_putEnv)(const char *string, char **env);
+ char **(*_parseArgs)(char **argv, char *string);
+ void (*_printEnv)(char **e);
+ char **(*_systemEnv)(struct display *d, char *user, char *home);
+ void (*_LogOutOfMem)(char * fmt, ...);
+ SETGRENT_TYPE (*_setgrent)(void); /* no longer used */
+ struct group *(*_getgrent)(void); /* no longer used */
+ void (*_endgrent)(void); /* no longer used */
#ifdef USESHADOW
- struct spwd *(*_getspnam)();
- void (*_endspent)();
+ struct spwd *(*_getspnam)(GETSPNAM_ARGS);
+ void (*_endspent)(void);
+#endif
+ struct passwd *(*_getpwnam)(GETPWNAM_ARGS);
+#ifdef linux
+ void (*_endpwent)(void);
+#endif
+ char *(*_crypt)(CRYPT_ARGS);
+#ifdef USE_PAM
+ pam_handle_t **(*_thepamhp)(void);
#endif
- struct passwd *(*_getpwnam)();
- char *(*_crypt)();
};
/*
@@ -123,33 +150,40 @@ typedef greet_user_rtn (*GreetUserProc)(
* called, with the pointer values passed as a paramter.
*/
-extern int (*__xdm_PingServer)();
-extern int (*__xdm_SessionPingFailed)();
-extern int (*__xdm_Debug)();
-extern int (*__xdm_RegisterCloseOnFork)();
-extern int (*__xdm_SecureDisplay)();
-extern int (*__xdm_UnsecureDisplay)();
-extern int (*__xdm_ClearCloseOnFork)();
-extern int (*__xdm_SetupDisplay)();
-extern int (*__xdm_LogError)();
-extern int (*__xdm_SessionExit)();
-extern int (*__xdm_DeleteXloginResources)();
-extern int (*__xdm_source)();
-extern char **(*__xdm_defaultEnv)();
-extern char **(*__xdm_setEnv)();
-extern char **(*__xdm_parseArgs)();
-extern int (*__xdm_printEnv)();
-extern char **(*__xdm_systemEnv)();
-extern int (*__xdm_LogOutOfMem)();
-extern void (*__xdm_setgrent)();
-extern struct group *(*__xdm_getgrent)();
-extern void (*__xdm_endgrent)();
+extern int (*__xdm_PingServer)(struct display *d, Display *alternateDpy);
+extern void (*__xdm_SessionPingFailed)(struct display *d);
+extern void (*__xdm_Debug)(char * fmt, ...);
+extern void (*__xdm_RegisterCloseOnFork)(int fd);
+extern void (*__xdm_SecureDisplay)(struct display *d, Display *dpy);
+extern void (*__xdm_UnsecureDisplay)(struct display *d, Display *dpy);
+extern void (*__xdm_ClearCloseOnFork)(int fd);
+extern void (*__xdm_SetupDisplay)(struct display *d);
+extern void (*__xdm_LogError)(char * fmt, ...);
+extern void (*__xdm_SessionExit)(struct display *d, int status, int removeAuth);
+extern void (*__xdm_DeleteXloginResources)(struct display *d, Display *dpy);
+extern int (*__xdm_source)(char **environ, char *file);
+extern char **(*__xdm_defaultEnv)(void);
+extern char **(*__xdm_setEnv)(char **e, char *name, char *value);
+extern char **(*__xdm_putEnv)(const char *string, char **env);
+extern char **(*__xdm_parseArgs)(char **argv, char *string);
+extern void (*__xdm_printEnv)(char **e);
+extern char **(*__xdm_systemEnv)(struct display *d, char *user, char *home);
+extern void (*__xdm_LogOutOfMem)(char * fmt, ...);
+extern void (*__xdm_setgrent)(void);
+extern struct group *(*__xdm_getgrent)(void);
+extern void (*__xdm_endgrent)(void);
#ifdef USESHADOW
-extern struct spwd *(*__xdm_getspnam)();
-extern void (*__xdm_endspent)();
+extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS);
+extern void (*__xdm_endspent)(void);
+#endif
+extern struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS);
+#ifdef linux
+extern void (*__xdm_endpwent)(void);
+#endif
+extern char *(*__xdm_crypt)(CRYPT_ARGS);
+#ifdef USE_PAM
+extern pam_handle_t **(*__xdm_thepamhp)(void);
#endif
-extern struct passwd *(*__xdm_getpwnam)();
-extern char *(*__xdm_crypt)();
/*
* Force the shared library to call through the function pointer
@@ -167,9 +201,10 @@ extern char *(*__xdm_crypt)();
#define LogError (*__xdm_LogError)
#define SessionExit (*__xdm_SessionExit)
#define DeleteXloginResources (*__xdm_DeleteXloginResources)
-#define source (*__xdm_source)
+#define source (*__xdm_source)
#define defaultEnv (*__xdm_defaultEnv)
-#define setEnv (*__xdm_setEnv)
+#define setEnv (*__xdm_setEnv)
+#define putEnv (*__xdm_putEnv)
#define parseArgs (*__xdm_parseArgs)
#define printEnv (*__xdm_printEnv)
#define systemEnv (*__xdm_systemEnv)
@@ -181,7 +216,11 @@ extern char *(*__xdm_crypt)();
#define getspnam (*__xdm_getspnam)
#define endspent (*__xdm_endspent)
#endif
+#ifdef linux
+#define endpwent (*__xdm_endpwent)
+#endif
#define getpwnam (*__xdm_getpwnam)
#define crypt (*__xdm_crypt)
+#define thepamhp (*__xdm_thepamhp)
#endif /* GREET_LIB */
diff --git a/greeter/Login.c b/greeter/Login.c
index 7650774..df91b0d 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/greeter/Login.c,v 3.16 2002/10/06 20:42:16 herrb Exp $ */
/*
* xdm - display manager daemon
@@ -37,17 +38,40 @@ from The Open Group.
# include <X11/IntrinsicP.h>
# include <X11/StringDefs.h>
# include <X11/keysym.h>
+# include <X11/DECkeysym.h>
# include <X11/Xfuncs.h>
# include <stdio.h>
+#ifdef XPM
+# include <time.h>
+#endif /* XPM */
# 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 <X11/cursorfont.h>
+#endif /* XPM */
+
+#ifdef USE_XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
+static void RedrawFail (LoginWidget w);
+static void ResetLogin (LoginWidget w);
+static void failTimeout (XtPointer client_data, XtIntervalId * id);
+
#define offset(field) XtOffsetOf(LoginRec, login.field)
#define goffset(field) XtOffsetOf(WidgetRec, core.field)
+
static XtResource resources[] = {
{XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
goffset(width), XtRImmediate, (XtPointer) 0},
@@ -65,6 +89,37 @@ static XtResource resources[] = {
offset(greetpixel), XtRString, XtDefaultForeground},
{XtNfailColor, XtCForeground, XtRPixel, sizeof (Pixel),
offset(failpixel), XtRString, XtDefaultForeground},
+
+#ifdef XPM
+/* added by Caolan McNamara */
+ {XtNlastEventTime, XtCLastEventTime, XtRInt , sizeof (int),
+ offset(lastEventTime), XtRImmediate, (XtPointer)0},
+/* end (caolan) */
+
+/* added by Ivan Griffin (ivan.griffin@ul.ie) */
+ {XtNlogoFileName, XtCLogoFileName, XtRString, sizeof(char*),
+ offset(logoFileName), XtRImmediate, (XtPointer)0},
+ {XtNuseShape, XtCUseShape, XtRBoolean, sizeof(Boolean),
+ offset(useShape), XtRImmediate, (XtPointer) True},
+ {XtNlogoPadding, XtCLogoPadding, XtRInt, sizeof(int),
+ offset(logoPadding), XtRImmediate, (XtPointer) 5},
+/* end (ivan) */
+
+
+/* added by Amit Margalit */
+ {XtNhiColor, XtCForeground, XtRPixel, sizeof (Pixel),
+ offset(hipixel), XtRString, XtDefaultForeground},
+ {XtNshdColor, XtCForeground, XtRPixel, sizeof (Pixel),
+ offset(shdpixel), XtRString, XtDefaultForeground},
+ {XtNframeWidth, XtCFrameWidth, XtRInt, sizeof(int),
+ offset(outframewidth), XtRImmediate, (XtPointer) 1},
+ {XtNinnerFramesWidth, XtCFrameWidth, XtRInt, sizeof(int),
+ offset(inframeswidth), XtRImmediate, (XtPointer) 1},
+ {XtNsepWidth, XtCFrameWidth, XtRInt, sizeof(int),
+ offset(sepwidth), XtRImmediate, (XtPointer) 1},
+/* end (amit) */
+#endif /* XPM */
+
{XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
offset (font), XtRString, "*-new century schoolbook-medium-r-normal-*-180-*"},
{XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
@@ -92,7 +147,11 @@ static XtResource resources[] = {
{XtNsecureSession, XtCSecureSession, XtRBoolean, sizeof (Boolean),
offset(secure_session), XtRImmediate, False },
{XtNallowAccess, XtCAllowAccess, XtRBoolean, sizeof (Boolean),
- offset(allow_access), XtRImmediate, False }
+ offset(allow_access), XtRImmediate, False },
+ {XtNallowNullPasswd, XtCAllowNullPasswd, XtRBoolean, sizeof (Boolean),
+ offset(allow_null_passwd), XtRImmediate, False},
+ {XtNallowRootLogin, XtCAllowRootLogin, XtRBoolean, sizeof(Boolean),
+ offset(allow_root_login), XtRImmediate, (XtPointer) True}
};
#undef offset
@@ -113,22 +172,43 @@ static XtResource resources[] = {
# define Y_INC(w) max (TEXT_Y_INC(w), PROMPT_Y_INC(w))
+#ifndef XPM
# define LOGIN_PROMPT_W(w) (XTextWidth (w->login.promptFont,\
w->login.namePrompt,\
strlen (w->login.namePrompt)))
+#else
+# define LOGIN_PROMPT_W(w) (XTextWidth (w->login.promptFont,\
+ w->login.namePrompt,\
+ strlen (w->login.namePrompt)) + \
+ w->login.inframeswidth)
+#endif /* XPM */
+#ifndef XPM
# define PASS_PROMPT_W(w) (XTextWidth (w->login.promptFont,\
w->login.passwdPrompt,\
strlen (w->login.passwdPrompt)))
+#else
+# define PASS_PROMPT_W(w) (XTextWidth (w->login.promptFont,\
+ w->login.passwdPrompt,\
+ strlen (w->login.passwdPrompt)) + \
+ w->login.inframeswidth)
+#endif /* XPM */
# define PROMPT_W(w) (max(LOGIN_PROMPT_W(w), PASS_PROMPT_W(w)))
# 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 - XTextWidth (w->login.greetFont,\
GREETING(w), strlen (GREETING(w)))) / 2)
# define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0)
+#ifndef XPM
# define GREET_W(w) (max (XTextWidth (w->login.greetFont,\
w->login.greeting, strlen (w->login.greeting)), \
XTextWidth (w->login.greetFont,\
w->login.unsecure_greet, strlen (w->login.unsecure_greet))))
+#else
+# define GREET_W(w) (max (XTextWidth (w->login.greetFont,\
+ w->login.greeting, strlen (w->login.greeting)), \
+ XTextWidth (w->login.greetFont,\
+ w->login.unsecure_greet, strlen (w->login.unsecure_greet)))) + w->login.logoWidth + (2*w->login.logoPadding)
+#endif /* XPM */
# define LOGIN_X(w) (2 * PROMPT_X_INC(w))
# define LOGIN_Y(w) (GREET_Y(w) + GREET_Y_INC(w) +\
w->login.greetFont->max_bounds.ascent + Y_INC(w))
@@ -136,7 +216,11 @@ static XtResource resources[] = {
# define LOGIN_H(w) (3 * Y_INC(w) / 2)
# define LOGIN_TEXT_X(w)(LOGIN_X(w) + PROMPT_W(w))
# define PASS_X(w) (LOGIN_X(w))
+#ifndef XPM
# define PASS_Y(w) (LOGIN_Y(w) + 8 * Y_INC(w) / 5)
+#else
+# define PASS_Y(w) (LOGIN_Y(w) + 10 * Y_INC(w) / 5)
+#endif /* XPM */
# define PASS_W(w) (LOGIN_W(w))
# define PASS_H(w) (LOGIN_H(w))
# define PASS_TEXT_X(w) (PASS_X(w) + PROMPT_W(w))
@@ -144,24 +228,25 @@ static XtResource resources[] = {
w->login.fail, strlen (w->login.fail))) / 2)
# define FAIL_Y(w) (PASS_Y(w) + 2 * FAIL_Y_INC (w) +\
w->login.failFont->max_bounds.ascent)
+#ifndef XPM
# define FAIL_W(w) (XTextWidth (w->login.failFont,\
w->login.fail, strlen (w->login.fail)))
+#else
+# define FAIL_W(w) (XTextWidth (w->login.failFont,\
+ w->login.fail, strlen (w->login.fail))) + w->login.logoWidth + (2*w->login.logoPadding)
+#endif /* XPM */
# define PAD_X(w) (2 * (LOGIN_X(w) + max (GREET_X_INC(w), FAIL_X_INC(w))))
# define PAD_Y(w) (max (max (Y_INC(w), GREET_Y_INC(w)),\
FAIL_Y_INC(w)))
-static void Initialize(), Realize(), Destroy(), Redisplay();
-static Boolean SetValues();
-static void draw_it ();
-
-static int max (a,b) { return a > b ? a : b; }
+#ifndef max
+static int max (int a, int b) { return a > b ? a : b; }
+#endif
static void
-EraseName (w, cursor)
- LoginWidget w;
- int cursor;
+EraseName (LoginWidget w, int cursor)
{
int x;
@@ -173,9 +258,7 @@ EraseName (w, cursor)
}
static void
-DrawName (w, cursor)
- LoginWidget w;
- int cursor;
+DrawName (LoginWidget w, int cursor)
{
int x;
@@ -184,12 +267,16 @@ DrawName (w, cursor)
x += XTextWidth (w->login.font, w->login.data.name, cursor);
XDrawString (XtDisplay(w), XtWindow (w), w->login.textGC, x, LOGIN_Y(w),
w->login.data.name + cursor, strlen (w->login.data.name + cursor));
+
+#ifdef XPM
+ /*as good a place as any Caolan begin*/
+ w->login.lastEventTime = time(NULL);
+ /*as good a place as any Caolan end*/
+#endif /* XPM */
}
static void
-realizeCursor (w, gc)
- LoginWidget w;
- GC gc;
+realizeCursor (LoginWidget w, GC gc)
{
int x, y;
int height, width;
@@ -213,12 +300,31 @@ realizeCursor (w, gc)
return;
}
XFillRectangle (XtDisplay (w), XtWindow (w), gc,
+#ifndef XPM
x, y - w->login.font->max_bounds.ascent, width, height);
+#else
+ x, y+1 - w->login.font->max_bounds.ascent, width, height-1);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x-1 , y - w->login.font->max_bounds.ascent);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x+1 , y - w->login.font->max_bounds.ascent);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x-1 , y - w->login.font->max_bounds.ascent+height);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x+1 , y - w->login.font->max_bounds.ascent+height);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x-2 , y - w->login.font->max_bounds.ascent);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x+2 , y - w->login.font->max_bounds.ascent);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x-2 , y - w->login.font->max_bounds.ascent+height);
+ XDrawPoint (XtDisplay (w), XtWindow (w), gc,
+ x+2 , y - w->login.font->max_bounds.ascent+height);
+#endif /* XPM */
}
static void
-EraseFail (w)
- LoginWidget w;
+EraseFail (LoginWidget w)
{
int x = FAIL_X(w);
int y = FAIL_Y(w);
@@ -234,31 +340,26 @@ EraseFail (w)
}
static void
-XorCursor (w)
- LoginWidget w;
+XorCursor (LoginWidget w)
{
realizeCursor (w, w->login.xorGC);
}
static void
-RemoveFail (w)
- LoginWidget w;
+RemoveFail (LoginWidget w)
{
if (w->login.failUp)
EraseFail (w);
}
static void
-EraseCursor (w)
- LoginWidget (w);
+EraseCursor (LoginWidget w)
{
realizeCursor (w, w->login.bgGC);
}
/*ARGSUSED*/
-void failTimeout (client_data, id)
- XtPointer client_data;
- XtIntervalId * id;
+static void failTimeout (XtPointer client_data, XtIntervalId * id)
{
LoginWidget w = (LoginWidget)client_data;
@@ -266,8 +367,8 @@ void failTimeout (client_data, id)
EraseFail (w);
}
-DrawFail (ctx)
- Widget ctx;
+void
+DrawFail (Widget ctx)
{
LoginWidget w;
@@ -285,8 +386,8 @@ DrawFail (ctx)
}
}
-RedrawFail (w)
- LoginWidget w;
+static void
+RedrawFail (LoginWidget w)
{
int x = FAIL_X(w);
int y = FAIL_Y(w);
@@ -298,13 +399,101 @@ RedrawFail (w)
}
static void
-draw_it (w)
- LoginWidget w;
+draw_it (LoginWidget w)
{
+#ifdef XPM
+ int i,in_frame_x,in_login_y,in_pass_y,in_width,in_height;
+ int gr_line_x, gr_line_y, gr_line_w;
+#endif /* XPM */
+
EraseCursor (w);
+
+#ifdef XPM
+ if( (w->login.outframewidth) < 1 )
+ w->login.outframewidth = 1;
+ for(i=1;i<=(w->login.outframewidth);i++)
+ {
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ i-1,i-1,w->core.width-i,i-1);
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ i-1,i-1,i-1,w->core.height-i);
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ w->core.width-i,i-1,w->core.width-i,w->core.height-i);
+ 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 + w->login.logoPadding;
+ gr_line_y = GREET_Y(w) + GREET_Y_INC(w);
+ gr_line_w = w->core.width - 2*(w->login.outframewidth) -
+ (w->login.logoWidth + 3*(w->login.logoPadding));
+
+ for(i=1;i<=(w->login.sepwidth);i++)
+ {
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ gr_line_x, gr_line_y + i-1,
+ gr_line_x+gr_line_w, gr_line_y + i-1);
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ gr_line_x, gr_line_y + 2*(w->login.inframeswidth) -i,
+ gr_line_x+gr_line_w, gr_line_y + 2*(w->login.inframeswidth) -i);
+ }
+
+ in_frame_x = LOGIN_TEXT_X(w) - w->login.inframeswidth - 3;
+ in_login_y = LOGIN_Y(w) - w->login.inframeswidth - 1 - TEXT_Y_INC(w);
+ in_pass_y = PASS_Y(w) - w->login.inframeswidth - 1 - TEXT_Y_INC(w);
+
+ in_width = LOGIN_W(w) - PROMPT_W(w) -
+ (w->login.logoWidth + 2*(w->login.logoPadding));
+ in_height = LOGIN_H(w) + w->login.inframeswidth + 2;
+
+ for(i=1;i<=(w->login.inframeswidth);i++)
+ {
+ /* Make top/left sides */
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ in_frame_x + i-1, in_login_y + i-1,
+ in_frame_x + in_width-i, in_login_y + i-1);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ in_frame_x + i-1, in_login_y + i-1,
+ in_frame_x + i-1, in_login_y + in_height-i);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ in_frame_x + in_width-i, in_login_y + i-1,
+ in_frame_x + in_width-i, in_login_y + in_height-i);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ in_frame_x + i-1, in_login_y + in_height-i,
+ in_frame_x + in_width-i, in_login_y + in_height-i);
+
+ /* Make bottom/right sides */
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ in_frame_x + i-1, in_pass_y + i-1,
+ in_frame_x + in_width-i, in_pass_y + i-1);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC,
+ in_frame_x + i-1, in_pass_y + i-1,
+ in_frame_x + i-1, in_pass_y + in_height-i);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ in_frame_x + in_width-i, in_pass_y + i-1,
+ in_frame_x + in_width-i, in_pass_y + in_height-i);
+
+ XDrawLine(XtDisplay (w), XtWindow (w), w->login.hiGC,
+ in_frame_x + i-1, in_pass_y + in_height-i,
+ in_frame_x + in_width-i, in_pass_y + in_height-i);
+ }
+#endif /* XPM */
+
if (GREETING(w)[0])
XDrawString (XtDisplay (w), XtWindow (w), w->login.greetGC,
+#ifndef XPM
GREET_X(w), GREET_Y(w),
+#else
+ GREET_X(w) -
+ ((w->login.logoWidth/2) + w->login.logoPadding),
+ GREET_Y(w),
+#endif /* XPM */
GREETING(w), strlen (GREETING(w)));
XDrawString (XtDisplay (w), XtWindow (w), w->login.promptGC,
LOGIN_X(w), LOGIN_Y(w),
@@ -333,11 +522,7 @@ draw_it (w)
/*ARGSUSED*/
static void
-DeleteBackwardChar (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DeleteBackwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -363,11 +548,7 @@ DeleteBackwardChar (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-DeleteForwardChar (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+DeleteForwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -394,11 +575,11 @@ DeleteForwardChar (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-MoveBackwardChar (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+MoveBackwardChar (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -411,11 +592,11 @@ MoveBackwardChar (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-MoveForwardChar (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+MoveForwardChar (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -436,11 +617,11 @@ MoveForwardChar (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-MoveToBegining (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+MoveToBegining (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -452,11 +633,11 @@ MoveToBegining (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-MoveToEnd (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+MoveToEnd (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -475,11 +656,11 @@ MoveToEnd (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-EraseToEndOfLine (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+EraseToEndOfLine (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -499,11 +680,11 @@ EraseToEndOfLine (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-EraseLine (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+EraseLine (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
MoveToBegining (ctxw, event, params, num_params);
EraseToEndOfLine (ctxw, event, params, num_params);
@@ -511,11 +692,11 @@ EraseLine (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-FinishField (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+FinishField (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -535,13 +716,36 @@ FinishField (ctxw, event, params, num_params)
XorCursor (ctx);
}
+#ifdef XPM
/*ARGSUSED*/
static void
-AllowAccess (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+TabField(Widget ctxw, XEvent *event, String *params, Cardinal *num_params)
+{
+ LoginWidget ctx = (LoginWidget)ctxw;
+
+ XorCursor (ctx);
+ RemoveFail (ctx);
+ switch (ctx->login.state) {
+ case GET_NAME:
+ ctx->login.state = GET_PASSWD;
+ ctx->login.cursor = 0;
+ break;
+ case GET_PASSWD:
+ ctx->login.state = GET_NAME;
+ ctx->login.cursor = 0;
+ break;
+ }
+ XorCursor (ctx);
+}
+#endif /* XPM */
+
+/*ARGSUSED*/
+static void
+AllowAccess (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
Arg arglist[1];
@@ -556,11 +760,11 @@ AllowAccess (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-SetSessionArgument (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+SetSessionArgument (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -579,11 +783,11 @@ SetSessionArgument (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-RestartSession (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+RestartSession (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -597,11 +801,11 @@ RestartSession (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-AbortSession (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+AbortSession (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -615,11 +819,11 @@ AbortSession (ctxw, event, params, num_params)
/*ARGSUSED*/
static void
-AbortDisplay (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+AbortDisplay (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
@@ -631,8 +835,8 @@ AbortDisplay (ctxw, event, params, num_params)
XorCursor (ctx);
}
-ResetLogin (w)
- LoginWidget w;
+static void
+ResetLogin (LoginWidget w)
{
EraseName (w, 0);
w->login.cursor = 0;
@@ -641,30 +845,138 @@ ResetLogin (w)
w->login.state = GET_NAME;
}
+static void
+InitI18N(Widget ctxw)
+{
+ LoginWidget ctx = (LoginWidget)ctxw;
+ XIM xim = (XIM) NULL;
+ char *p;
+
+ ctx->login.xic = (XIC) NULL;
+
+ if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
+ xim = XOpenIM(XtDisplay(ctx), NULL, NULL, NULL);
+
+ if (!xim) {
+ LogError("Failed to open input method\n");
+ return;
+ }
+
+ ctx->login.xic = XCreateIC(xim,
+ XNInputStyle, (XIMPreeditNothing|XIMStatusNothing),
+ XNClientWindow, ctx->core.window,
+ XNFocusWindow, ctx->core.window, NULL);
+
+ if (!ctx->login.xic) {
+ LogError("Failed to create input context\n");
+ XCloseIM(xim);
+ }
+ return;
+}
+
/* ARGSUSED */
static void
-InsertChar (ctxw, event, params, num_params)
- Widget ctxw;
- XEvent *event;
- String *params;
- Cardinal *num_params;
+InsertChar (
+ Widget ctxw,
+ XEvent *event,
+ String *params,
+ Cardinal *num_params)
{
LoginWidget ctx = (LoginWidget)ctxw;
char strbuf[128];
+#ifndef XPM
int len;
-
- len = XLookupString (&event->xkey, strbuf, sizeof (strbuf), 0, 0);
+#else
+ int len,pixels;
+#endif /* XPM */
+ KeySym keysym = 0;
+
+ if (ctx->login.xic) {
+ static Status status;
+ len = XmbLookupString(ctx->login.xic, &event->xkey, strbuf,
+ sizeof (strbuf), &keysym, &status);
+ } else {
+ static XComposeStatus compose_status = {NULL, 0};
+ len = XLookupString (&event->xkey, strbuf, sizeof (strbuf),
+ &keysym, &compose_status);
+ }
strbuf[len] = '\0';
+
+#ifdef XPM
+ pixels = 3 + ctx->login.font->max_bounds.width * len +
+ XTextWidth(ctx->login.font,
+ ctx->login.data.name,
+ strlen(ctx->login.data.name));
+ /* pixels to be added */
+#endif /* XPM */
+
+ /*
+ * Note: You can override this default key handling
+ * by the settings in the translation table
+ * loginActionsTable at the end of this file.
+ */
+ switch (keysym) {
+ case XK_Return:
+ case XK_KP_Enter:
+ case XK_Linefeed:
+ case XK_Execute:
+ FinishField(ctxw, event, params, num_params);
+ return;
+ case XK_BackSpace:
+ DeleteBackwardChar(ctxw, event, params, num_params);
+ return;
+ case XK_Delete:
+ case XK_KP_Delete:
+ case DXK_Remove:
+ /* Sorry, it's not a telex machine, it's a terminal */
+ DeleteForwardChar(ctxw, event, params, num_params);
+ return;
+ case XK_Left:
+ case XK_KP_Left:
+ MoveBackwardChar(ctxw, event, params, num_params);
+ return;
+ case XK_Right:
+ case XK_KP_Right:
+ MoveForwardChar(ctxw, event, params, num_params);
+ return;
+ case XK_End:
+ case XK_KP_End:
+ MoveToEnd(ctxw, event, params, num_params);
+ return;
+ case XK_Home:
+ case XK_KP_Home:
+ MoveToBegining(ctxw, event, params, num_params);
+ return;
+ default:
+ if (len == 0) {
+ if (!IsModifierKey(keysym)) /* it's not a modifier */
+ XBell(XtDisplay(ctxw), 60);
+ return;
+ } else
+ break;
+ }
+
switch (ctx->login.state) {
case GET_NAME:
+#ifndef XPM
if (len + (int)strlen(ctx->login.data.name) >= NAME_LEN - 1)
+#else
+ if (
+ (len + (int)strlen(ctx->login.data.name) >= NAME_LEN - 1)/* &&
+ (pixels <= LOGIN_W(ctx) - PROMPT_W(ctx))*/
+ )
+#endif /* XPM */
len = NAME_LEN - strlen(ctx->login.data.name) - 2;
case GET_PASSWD:
- if (len + (int)strlen(ctx->login.data.passwd) >= NAME_LEN - 1)
- len = NAME_LEN - strlen(ctx->login.data.passwd) - 2;
+ if (len + (int)strlen(ctx->login.data.passwd) >= PASSWORD_LEN - 1)
+ len = PASSWORD_LEN - strlen(ctx->login.data.passwd) - 2;
}
+#ifndef XPM
if (len == 0)
+#else
+ if (len == 0 || pixels >= LOGIN_W(ctx) - PROMPT_W(ctx))
+#endif /* XPM */
return;
XorCursor (ctx);
RemoveFail (ctx);
@@ -684,22 +996,45 @@ InsertChar (ctxw, event, params, num_params)
strlen (ctx->login.data.passwd + ctx->login.cursor) + 1);
memmove( ctx->login.data.passwd + ctx->login.cursor, strbuf, len);
ctx->login.cursor += len;
+
+#ifdef XPM
+ /*as good a place as any Caolan begin*/
+ ctx->login.lastEventTime = time(NULL);
+ /*as good a place as any Caolan end*/
+#endif /* XPM */
break;
}
XorCursor (ctx);
}
/* ARGSUSED */
-static void Initialize (greq, gnew, args, num_args)
- Widget greq, gnew;
- ArgList args;
- Cardinal *num_args;
+static void Initialize (
+ Widget greq,
+ Widget gnew,
+ ArgList args,
+ Cardinal *num_args)
{
LoginWidget w = (LoginWidget)gnew;
XtGCMask valuemask, xvaluemask;
XGCValues myXGCV;
Arg position[2];
Position x, y;
+#ifdef USE_XINERAMA
+ XineramaScreenInfo *screens;
+ int s_num;
+#endif
+
+#ifdef XPM
+ myXGCV.foreground = w->login.hipixel;
+ myXGCV.background = w->core.background_pixel;
+ valuemask = GCForeground | GCBackground;
+ w->login.hiGC = XtGetGC(gnew, valuemask, &myXGCV);
+
+ myXGCV.foreground = w->login.shdpixel;
+ myXGCV.background = w->core.background_pixel;
+ valuemask = GCForeground | GCBackground;
+ w->login.shdGC = XtGetGC(gnew, valuemask, &myXGCV);
+#endif /* XPM */
myXGCV.foreground = w->login.textpixel;
myXGCV.background = w->core.background_pixel;
@@ -756,6 +1091,55 @@ static void Initialize (greq, gnew, args, num_args)
myXGCV.font = w->login.failFont->fid;
w->login.failGC = XtGetGC (gnew, xvaluemask, &myXGCV);
+#ifdef XPM
+ w->login.logoValid = False;
+
+ if (NULL != w->login.logoFileName)
+ {
+ XpmAttributes myAttributes = { 0 };
+ Window tmpWindow = { 0 };
+ struct stat myBuffer = { 0 };
+ unsigned int myPixmapDepth = 0;
+
+ if (0 != stat(w->login.logoFileName, &myBuffer))
+ {
+ LogError("Unable to stat() pixmap file %s\n",
+ w->login.logoFileName);
+ w->login.logoValid = False;
+ goto SkipXpmLoad;
+ }
+ else
+
+ myAttributes.valuemask |= XpmReturnPixels;
+ myAttributes.valuemask |= XpmReturnExtensions;
+
+ XpmReadFileToPixmap(XtDisplay(w), /* display */
+ RootWindowOfScreen(XtScreen(w)), /* window */
+ w->login.logoFileName, /* XPM filename */
+ &(w->login.logoPixmap), /* pixmap */
+ &(w->login.logoMask), /* pixmap mask */
+ &myAttributes); /* XPM attributes */
+ w->login.logoValid = True;
+
+ XGetGeometry(XtDisplay(w), w->login.logoPixmap,
+ &tmpWindow,
+ &(w->login.logoX),
+ &(w->login.logoY),
+ &(w->login.logoWidth),
+ &(w->login.logoHeight),
+ &(w->login.logoBorderWidth),
+ &myPixmapDepth);
+ } else {
+ w->login.logoX = 0;
+ w->login.logoY = 0;
+ w->login.logoWidth = 0;
+ w->login.logoHeight = 0;
+ w->login.logoBorderWidth = 0;
+ }
+
+
+SkipXpmLoad:
+#endif /* XPM */
w->login.data.name[0] = '\0';
w->login.data.passwd[0] = '\0';
w->login.state = GET_NAME;
@@ -767,55 +1151,148 @@ static void Initialize (greq, gnew, args, num_args)
int fy = FAIL_Y(w);
int pady = PAD_Y(w);
+#ifndef XPM
w->core.height = fy + pady; /* for stupid compilers */
+#else
+/* w->core.height = fy + pady; * for stupid compilers */
+
+ w->core.height = max(fy + pady,
+ (w->login.logoHeight + (2*w->login.logoPadding)) + pady);
+
+#endif /* XPM */
+ }
+#ifdef USE_XINERAMA
+ if (
+ XineramaIsActive(XtDisplay(w)) &&
+ (screens = XineramaQueryScreens(XtDisplay(w), &s_num)) != NULL
+ )
+ {
+ if ((x = w->core.x) == -1)
+ 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
+#endif
+ {
+ if ((x = w->core.x) == -1)
+ x = (int)(XWidthOfScreen (XtScreen (w)) - w->core.width) / 2;
+ if ((y = w->core.y) == -1)
+ y = (int)(XHeightOfScreen (XtScreen (w)) - w->core.height) / 3;
}
- if ((x = w->core.x) == -1)
- x = (int)(XWidthOfScreen (XtScreen (w)) - w->core.width) / 2;
- if ((y = w->core.y) == -1)
- y = (int)(XHeightOfScreen (XtScreen (w)) - w->core.height) / 3;
XtSetArg (position[0], XtNx, x);
XtSetArg (position[1], XtNy, y);
XtSetValues (XtParent (w), position, (Cardinal) 2);
}
-static void Realize (gw, valueMask, attrs)
- Widget gw;
- XtValueMask *valueMask;
- XSetWindowAttributes *attrs;
+static void Realize (
+ Widget gw,
+ XtValueMask *valueMask,
+ XSetWindowAttributes *attrs)
{
+#ifdef XPM
+ LoginWidget w = (LoginWidget) gw;
+ Cursor cursor;
+#endif /* XPM */
XtCreateWindow( gw, (unsigned)InputOutput, (Visual *)CopyFromParent,
*valueMask, attrs );
+ InitI18N(gw);
+#ifdef XPM
+ cursor = XCreateFontCursor(XtDisplay(gw), XC_left_ptr);
+ XDefineCursor(XtDisplay(gw), XtWindow(gw), cursor);
+
+ /*
+ * Check if Pixmap was valid
+ */
+ if (True == w->login.logoValid)
+ {
+ /*
+ * Create pixmap window
+ */
+ {
+ unsigned long valueMask = CWBackPixel | CWBackPixmap;
+ XSetWindowAttributes windowAttributes = { 0 };
+
+ windowAttributes.background_pixel = w->core.background_pixel;
+ windowAttributes.background_pixmap = None;
+
+ w->login.logoWindow = XCreateWindow(XtDisplay(w),
+ XtWindow(w),
+ w->core.width - w->login.outframewidth -
+ w->login.logoWidth - w->login.logoPadding,
+ (w->core.height - w->login.logoHeight) /2,
+ w->login.logoWidth, w->login.logoHeight, 0,
+ CopyFromParent, InputOutput, CopyFromParent,
+ valueMask, &windowAttributes);
+ }
+
+ /*
+ * check if we can use shape extension
+ */
+ if (True == w->login.useShape)
+ {
+ int foo, bar;
+
+ if (XShapeQueryExtension(XtDisplay(w), &foo, &bar) == TRUE)
+ {
+ XShapeCombineMask(XtDisplay(w), w->login.logoWindow,
+ ShapeBounding, w->login.logoX, w->login.logoY,
+ w->login.logoMask, ShapeSet);
+ }
+ }
+
+ XSetWindowBackgroundPixmap(XtDisplay(w), w->login.logoWindow,
+ w->login.logoPixmap);
+ XMapWindow(XtDisplay(w), w->login.logoWindow);
+ }
+#endif /* XPM */
}
-static void Destroy (gw)
- Widget gw;
+static void Destroy (Widget gw)
{
LoginWidget w = (LoginWidget)gw;
bzero (w->login.data.name, NAME_LEN);
- bzero (w->login.data.passwd, NAME_LEN);
+ bzero (w->login.data.passwd, PASSWORD_LEN);
XtReleaseGC(gw, w->login.textGC);
XtReleaseGC(gw, w->login.bgGC);
XtReleaseGC(gw, w->login.xorGC);
XtReleaseGC(gw, w->login.promptGC);
XtReleaseGC(gw, w->login.greetGC);
XtReleaseGC(gw, w->login.failGC);
+#ifdef XPM
+ XtReleaseGC(gw, w->login.hiGC);
+ XtReleaseGC(gw, w->login.shdGC);
+
+ if (True == w->login.logoValid)
+ {
+ if (w->login.logoPixmap != 0)
+ XFreePixmap(XtDisplay(w), w->login.logoPixmap);
+
+ if (w->login.logoMask != 0)
+ XFreePixmap(XtDisplay(w), w->login.logoMask);
+ }
+#endif /* XPM */
}
/* ARGSUSED */
-static void Redisplay(gw, event, region)
- Widget gw;
- XEvent *event;
- Region region;
+static void Redisplay(
+ Widget gw,
+ XEvent *event,
+ Region region)
{
draw_it ((LoginWidget) gw);
}
/*ARGSUSED*/
-static Boolean SetValues (current, request, new, args, num_args)
- Widget current, request, new;
- ArgList args;
- Cardinal *num_args;
+static Boolean SetValues (
+ Widget current,
+ Widget request,
+ Widget new,
+ ArgList args,
+ Cardinal *num_args)
{
LoginWidget currentL, newL;
@@ -827,24 +1304,32 @@ static Boolean SetValues (current, request, new, args, num_args)
}
char defaultLoginTranslations [] =
-"\
-Ctrl<Key>H: delete-previous-character() \n\
-Ctrl<Key>D: delete-character() \n\
-Ctrl<Key>B: move-backward-character() \n\
-Ctrl<Key>F: move-forward-character() \n\
-Ctrl<Key>A: move-to-begining() \n\
-Ctrl<Key>E: move-to-end() \n\
-Ctrl<Key>K: erase-to-end-of-line() \n\
-Ctrl<Key>U: erase-line() \n\
-Ctrl<Key>X: erase-line() \n\
-Ctrl<Key>C: restart-session() \n\
-Ctrl<Key>\\\\: abort-session() \n\
-:Ctrl<Key>plus: allow-all-access() \n\
-<Key>BackSpace: delete-previous-character() \n\
-<Key>Delete: delete-previous-character() \n\
-<Key>Return: finish-field() \n\
-<Key>: insert-char() \
-";
+"Ctrl<Key>H: delete-previous-character() \n"
+"Ctrl<Key>D: delete-character() \n"
+"Ctrl<Key>B: move-backward-character() \n"
+"Ctrl<Key>F: move-forward-character() \n"
+"Ctrl<Key>A: move-to-begining() \n"
+"Ctrl<Key>E: move-to-end() \n"
+"Ctrl<Key>K: erase-to-end-of-line() \n"
+"Ctrl<Key>U: erase-line() \n"
+"Ctrl<Key>X: erase-line() \n"
+"Ctrl<Key>C: restart-session() \n"
+"Ctrl<Key>\\\\: abort-session() \n"
+":Ctrl<Key>plus: allow-all-access() \n"
+"<Key>BackSpace: delete-previous-character() \n"
+#ifdef linux
+"<Key>Delete: delete-character() \n"
+#else
+"<Key>Delete: delete-previous-character() \n"
+#endif
+"<Key>Return: finish-field() \n"
+#ifndef XPM
+"<KeyPress>: insert-char()"
+#else
+"<Key>Tab: tab-field() \n"
+"<KeyPress>: insert-char()"
+#endif /* XPM */
+;
XtActionsRec loginActionsTable [] = {
{"delete-previous-character", DeleteBackwardChar},
@@ -856,6 +1341,9 @@ XtActionsRec loginActionsTable [] = {
{"erase-to-end-of-line", EraseToEndOfLine},
{"erase-line", EraseLine},
{"finish-field", FinishField},
+#ifdef XPM
+ {"tab-field", TabField},
+#endif /* XPM */
{"abort-session", AbortSession},
{"abort-display", AbortDisplay},
{"restart-session", RestartSession},
@@ -889,7 +1377,11 @@ LoginClassRec loginClassRec = {
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
+#ifndef XPM
/* set_values_almost */ NULL,
+#else
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+#endif /* XPM */
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
diff --git a/greeter/Login.h b/greeter/Login.h
index d2b88f4..08578f3 100644
--- a/greeter/Login.h
+++ b/greeter/Login.h
@@ -26,6 +26,7 @@ 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 $ */
/*
* xdm - display manager daemon
@@ -74,7 +75,32 @@ from The Open Group.
# define XtNsessionArgument "sessionArgument"
# define XtNsecureSession "secureSession"
# define XtNallowAccess "allowAccess"
-
+# define XtNallowNullPasswd "allowNullPasswd"
+# define XtNallowRootLogin "allowRootLogin"
+
+#ifdef XPM
+/* added by Amit Margalit Oct 1996 */
+# define XtNhiColor "hiColor"
+# define XtNshdColor "shdColor"
+# define XtNframeWidth "frameWidth"
+# define XtNinnerFramesWidth "innerFramesWidth"
+# define XtNsepWidth "sepWidth"
+
+/* caolan begin */
+#define XtNlastEventTime "lastEventTime"
+#define XtCLastEventTime "LastEventTime"
+/* caolan end */
+
+#define XtNuseShape "useShape"
+#define XtCUseShape "UseShape"
+#define XtNlogoFileName "logoFileName"
+#define XtCLogoFileName "LogoFileName"
+#define XtNlogoPadding "logoPadding"
+#define XtCLogoPadding "LogoPadding"
+
+# define XtCFrameWidth "FrameWidth"
+
+#endif /* XPM */
# define XtCGreeting "Greeting"
# define XtCNamePrompt "NamePrompt"
# define XtCPasswdPrompt "PasswdPrompt"
@@ -83,13 +109,22 @@ from The Open Group.
# define XtCSessionArgument "SessionArgument"
# define XtCSecureSession "SecureSession"
# define XtCAllowAccess "AllowAccess"
+# define XtCAllowNullPasswd "AllowNullPasswd"
+# define XtCAllowRootLogin "AllowRootLogin"
/* notifyDone interface definition */
+#ifndef __OpenBSD__
#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 {
- char name[NAME_LEN], passwd[NAME_LEN];
+ char name[NAME_LEN], passwd[PASSWORD_LEN];
} LoginData;
# define NOTIFY_OK 0
diff --git a/greeter/LoginP.h b/greeter/LoginP.h
index 8a8f467..0f88d79 100644
--- a/greeter/LoginP.h
+++ b/greeter/LoginP.h
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/greeter/LoginP.h,v 3.8 2001/12/14 20:01:29 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -37,23 +38,36 @@ from The Open Group.
#include "Login.h"
#include <X11/CoreP.h>
+#ifdef XPM
+#include <X11/Xlib.h>
+#endif /* XPM */
#define GET_NAME 0
#define GET_PASSWD 1
#define DONE 2
+typedef void (*LoginFunc)(LoginWidget, LoginData *, int);
+
/* New fields for the login widget instance record */
typedef struct {
Pixel textpixel; /* foreground pixel */
Pixel promptpixel; /* prompt pixel */
Pixel greetpixel; /* greeting pixel */
Pixel failpixel; /* failure pixel */
+#ifdef XPM
+ 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 */
GC promptGC;
GC greetGC;
GC failGC;
+#ifdef XPM
+ 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 */
@@ -68,11 +82,29 @@ typedef struct {
int failUp; /* failure message displayed */
LoginData data; /* name/passwd */
char *sessionArg; /* argument passed to session */
- void (*notify_done)();/* proc to call when done */
+ LoginFunc notify_done; /* proc to call when done */
int failTimeout; /* seconds til drop fail msg */
XtIntervalId interval_id; /* drop fail message note */
Boolean secure_session; /* session is secured */
Boolean allow_access; /* disable access control on login */
+ 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
+ /*caolan begin*/
+ int lastEventTime;
+ /*caolan end*/
+ int outframewidth; /* outer frame thickness */
+ int inframeswidth; /* inner frames thickness */
+ int sepwidth; /* width of separator line */
+
+ char *logoFileName;
+ unsigned int logoWidth, logoHeight, logoPadding, logoBorderWidth;
+ int logoX, logoY;
+ Window logoWindow;
+ Boolean useShape, logoValid;
+ Pixmap logoPixmap, logoMask;
+#endif /* XPM */
} LoginPart;
/* Full instance record declaration */
diff --git a/greeter/greet.c b/greeter/greet.c
index 93c64a6..5af88e8 100644
--- a/greeter/greet.c
+++ b/greeter/greet.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.16 2002/10/06 20:42:16 herrb Exp $ */
/*
* xdm - display manager daemon
@@ -40,42 +41,63 @@ from The Open Group.
#include <X11/Shell.h>
#include <X11/XKBlib.h>
+#ifdef USE_XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
#include "dm.h"
+#include "dm_error.h"
#include "greet.h"
#include "Login.h"
-#if GREET_LIB
+#ifdef __OpenBSD__
+#include <syslog.h>
+#endif
+
+#if defined(SECURE_RPC) && defined(sun)
+/* Go figure, there's no getdomainname() prototype available */
+extern int getdomainname(char *name, size_t len);
+#endif
+
+#ifdef GREET_LIB
/*
* Function pointers filled in by the initial call ito the library
*/
-int (*__xdm_PingServer)() = NULL;
-int (*__xdm_SessionPingFailed)() = NULL;
-int (*__xdm_Debug)() = NULL;
-int (*__xdm_RegisterCloseOnFork)() = NULL;
-int (*__xdm_SecureDisplay)() = NULL;
-int (*__xdm_UnsecureDisplay)() = NULL;
-int (*__xdm_ClearCloseOnFork)() = NULL;
-int (*__xdm_SetupDisplay)() = NULL;
-int (*__xdm_LogError)() = NULL;
-int (*__xdm_SessionExit)() = NULL;
-int (*__xdm_DeleteXloginResources)() = NULL;
-int (*__xdm_source)() = NULL;
-char **(*__xdm_defaultEnv)() = NULL;
-char **(*__xdm_setEnv)() = NULL;
-char **(*__xdm_parseArgs)() = NULL;
-int (*__xdm_printEnv)() = NULL;
-char **(*__xdm_systemEnv)() = NULL;
-int (*__xdm_LogOutOfMem)() = NULL;
-void (*__xdm_setgrent)() = NULL;
-struct group *(*__xdm_getgrent)() = NULL;
-void (*__xdm_endgrent)() = NULL;
+int (*__xdm_PingServer)(struct display *d, Display *alternateDpy) = NULL;
+void (*__xdm_SessionPingFailed)(struct display *d) = NULL;
+void (*__xdm_Debug)(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_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;
+char **(*__xdm_defaultEnv)(void) = NULL;
+char **(*__xdm_setEnv)(char **e, char *name, char *value) = NULL;
+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_setgrent)(void) = NULL;
+struct group *(*__xdm_getgrent)(void) = NULL;
+void (*__xdm_endgrent)(void) = NULL;
#ifdef USESHADOW
-struct spwd *(*__xdm_getspnam)() = NULL;
-void (*__xdm_endspent)() = NULL;
+struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL;
+void (*__xdm_endspent)(void) = NULL;
+#endif
+struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS) = NULL;
+#ifdef linux
+void (*__xdm_endpwent)(void) = NULL;
+#endif
+char *(*__xdm_crypt)(CRYPT_ARGS) = NULL;
+#ifdef USE_PAM
+pam_handle_t **(*__xdm_thepamhp)(void) = NULL;
#endif
-struct passwd *(*__xdm_getpwnam)() = NULL;
-char *(*__xdm_crypt)() = NULL;
#endif
@@ -99,9 +121,9 @@ static XtIntervalId pingTimeout;
/*ARGSUSED*/
static void
-GreetPingServer (closure, intervalId)
- XtPointer closure;
- XtIntervalId *intervalId;
+GreetPingServer (
+ XtPointer closure,
+ XtIntervalId *intervalId)
{
struct display *d;
@@ -114,10 +136,10 @@ GreetPingServer (closure, intervalId)
/*ARGSUSED*/
static void
-GreetDone (w, data, status)
- Widget w;
- LoginData *data;
- int status;
+GreetDone (
+ Widget w,
+ LoginData *data,
+ int status)
{
Debug ("GreetDone: %s, (password is %d long)\n",
data->name, strlen (data->passwd));
@@ -125,7 +147,7 @@ GreetDone (w, data, status)
case NOTIFY_OK:
strcpy (name, data->name);
strcpy (password, data->passwd);
- bzero (data->passwd, NAME_LEN);
+ bzero (data->passwd, PASSWORD_LEN);
code = 0;
done = 1;
break;
@@ -148,8 +170,7 @@ GreetDone (w, data, status)
}
static Display *
-InitGreet (d)
- struct display *d;
+InitGreet (struct display *d)
{
Arg arglist[10];
int i;
@@ -157,6 +178,10 @@ InitGreet (d)
Screen *scrn;
static char *argv[] = { "xlogin", 0 };
Display *dpy;
+#ifdef USE_XINERAMA
+ XineramaScreenInfo *screens;
+ int s_num;
+#endif
Debug ("greet %s\n", d->name);
argc = 1;
@@ -168,15 +193,16 @@ InitGreet (d)
if (!dpy)
return 0;
+#ifdef XKB
{
int opcode, evbase, errbase, majret, minret;
unsigned int value = XkbPCF_GrabsUseXKBStateMask;
if (XkbQueryExtension (dpy, &opcode, &evbase, &errbase, &majret, &minret)) {
- if (XkbSetPerClientControls (dpy, XkbPCF_GrabsUseXKBStateMask, &value))
+ if (!XkbSetPerClientControls (dpy, XkbPCF_GrabsUseXKBStateMask, &value))
LogError ("%s\n", "SetPerClientControls failed");
}
}
-
+#endif
RegisterCloseOnFork (ConnectionNumber (dpy));
SecureDisplay (d, dpy);
@@ -200,6 +226,21 @@ InitGreet (d)
arglist, i);
XtRealizeWidget (toplevel);
+#ifdef USE_XINERAMA
+ if (
+ XineramaIsActive(dpy) &&
+ (screens = XineramaQueryScreens(dpy, &s_num)) != NULL
+ )
+ {
+ XWarpPointer(dpy, None, XRootWindowOfScreen (scrn),
+ 0, 0, 0, 0,
+ screens[0].x_org + screens[0].width / 2,
+ screens[0].y_org + screens[0].height / 2);
+
+ XFree(screens);
+ }
+ else
+#endif
XWarpPointer(dpy, None, XRootWindowOfScreen (scrn),
0, 0, 0, 0,
XWidthOfScreen(scrn) / 2,
@@ -213,9 +254,8 @@ InitGreet (d)
return dpy;
}
-static
-CloseGreet (d)
- struct display *d;
+static void
+CloseGreet (struct display *d)
{
Boolean allow;
Arg arglist[1];
@@ -241,12 +281,10 @@ CloseGreet (d)
}
static int
-Greet (d, greet)
- struct display *d;
- struct greet_info *greet;
+Greet (struct display *d, struct greet_info *greet)
{
XEvent event;
- Arg arglist[1];
+ Arg arglist[3];
XtSetArg (arglist[0], XtNallowAccess, False);
XtSetValues (login, arglist, 1);
@@ -254,8 +292,15 @@ Greet (d, greet)
Debug ("dispatching %s\n", d->name);
done = 0;
while (!done) {
- XtAppNextEvent (context, &event);
+ XtAppNextEvent (context, &event);
+ switch (event.type) {
+ case MappingNotify:
+ XRefreshKeyboardMapping(&event.xmapping);
+ break;
+ default:
XtDispatchEvent (&event);
+ break;
+ }
}
XFlush (XtDisplay (toplevel));
Debug ("Done dispatch %s\n", d->name);
@@ -264,7 +309,9 @@ Greet (d, greet)
greet->name = name;
greet->password = password;
XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string));
- XtGetValues (login, arglist, 1);
+ XtSetArg (arglist[1], XtNallowNullPasswd, (char *) &(greet->allow_null_passwd));
+ XtSetArg (arglist[2], XtNallowRootLogin, (char *) &(greet->allow_root_login));
+ XtGetValues (login, arglist, 3);
Debug ("sessionArgument: %s\n", greet->string ? greet->string : "<NULL>");
}
return code;
@@ -272,22 +319,27 @@ Greet (d, greet)
static void
-FailedLogin (d, greet)
- struct display *d;
- struct greet_info *greet;
+FailedLogin (struct display *d, struct greet_info *greet)
{
+#ifdef __OpenBSD__
+ syslog(LOG_NOTICE, "LOGIN FAILURE ON %s",
+ d->name);
+ syslog(LOG_AUTHPRIV|LOG_NOTICE,
+ "LOGIN FAILURE ON %s, %s",
+ d->name, greet->name);
+#endif
DrawFail (login);
bzero (greet->name, strlen(greet->name));
bzero (greet->password, strlen(greet->password));
}
-greet_user_rtn GreetUser(d, dpy, verify, greet, dlfuncs)
- struct display *d;
- Display ** dpy;
- struct verify_info *verify;
- struct greet_info *greet;
- struct dlfuncs *dlfuncs;
+greet_user_rtn GreetUser(
+ struct display *d,
+ Display ** dpy,
+ struct verify_info *verify,
+ struct greet_info *greet,
+ struct dlfuncs *dlfuncs)
{
int i;
@@ -309,6 +361,7 @@ greet_user_rtn GreetUser(d, dpy, verify, greet, dlfuncs)
__xdm_source = dlfuncs->_source;
__xdm_defaultEnv = dlfuncs->_defaultEnv;
__xdm_setEnv = dlfuncs->_setEnv;
+ __xdm_putEnv = dlfuncs->_putEnv;
__xdm_parseArgs = dlfuncs->_parseArgs;
__xdm_printEnv = dlfuncs->_printEnv;
__xdm_systemEnv = dlfuncs->_systemEnv;
@@ -321,7 +374,13 @@ greet_user_rtn GreetUser(d, dpy, verify, greet, dlfuncs)
__xdm_endspent = dlfuncs->_endspent;
#endif
__xdm_getpwnam = dlfuncs->_getpwnam;
+#ifdef linux
+ __xdm_endpwent = dlfuncs->_endpwent;
+#endif
__xdm_crypt = dlfuncs->_crypt;
+#ifdef USE_PAM
+ __xdm_thepamhp = dlfuncs->_thepamhp;
+#endif
#endif
*dpy = InitGreet (d);
@@ -335,6 +394,9 @@ greet_user_rtn GreetUser(d, dpy, verify, greet, dlfuncs)
LogError ("Cannot reopen display %s for greet window\n", d->name);
exit (RESERVER_DISPLAY);
}
+#ifdef __OpenBSD__
+ openlog("xdm", LOG_ODELAY, LOG_AUTH);
+#endif
for (;;) {
/*
* Greet user, requesting name/password
diff --git a/greeter/verify.c b/greeter/verify.c
index 52b8138..182fef4 100644
--- a/greeter/verify.c
+++ b/greeter/verify.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/greeter/verify.c,v 3.24 2002/11/26 01:16:09 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -36,20 +37,24 @@ from The Open Group.
* typical unix verification routine.
*/
-# include "dm.h"
-# include <pwd.h>
-#ifdef USESHADOW
-# include <shadow.h>
-# include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
+#include "dm.h"
+#include "dm_error.h"
+
+#include <pwd.h>
+#ifdef USE_PAM
+# include <security/pam_appl.h>
+# include <stdlib.h>
+#else
+# ifdef USESHADOW
+# include <shadow.h>
+# include <errno.h>
+# endif
#endif
# include "greet.h"
-#ifdef X_NOT_STDC_ENV
-char *getenv();
+#ifdef QNX4
+extern char *crypt(const char *, const char *);
#endif
static char *envvars[] = {
@@ -71,17 +76,19 @@ static char *envvars[] = {
NULL
};
+#ifdef KERBEROS
+#include <sys/param.h>
+#include <kerberosIV/krb.h>
+static char krbtkfile[MAXPATHLEN];
+#endif
+
static char **
-userEnv (d, useSystemPath, user, home, shell)
-struct display *d;
-int useSystemPath;
-char *user, *home, *shell;
+userEnv (struct display *d, int useSystemPath, char *user, char *home, char *shell)
{
char **env;
char **envvar;
char *str;
- extern char **defaultEnv (), **setEnv ();
-
+
env = defaultEnv ();
env = setEnv (env, "DISPLAY", d->name);
env = setEnv (env, "HOME", home);
@@ -89,6 +96,10 @@ char *user, *home, *shell;
env = setEnv (env, "USER", user); /* BSD */
env = setEnv (env, "PATH", useSystemPath ? d->systemPath : d->userPath);
env = setEnv (env, "SHELL", shell);
+#ifdef KERBEROS
+ if (krbtkfile[0] != '\0')
+ env = setEnv (env, "KRBTKFILE", krbtkfile);
+#endif
for (envvar = envvars; *envvar; envvar++)
{
str = getenv(*envvar);
@@ -98,33 +109,260 @@ char *user, *home, *shell;
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) {
+ reply = realloc(reply, size);
+ bzero(reply + size - PAM_RESPONSE_SIZE, PAM_RESPONSE_SIZE);
+ } else {
+ reply = (struct pam_response*)malloc(size);
+ 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
int
-Verify (d, greet, verify)
-struct display *d;
-struct greet_info *greet;
-struct verify_info *verify;
+Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
{
struct passwd *p;
+ login_cap_t *lc;
+ auth_session_t *as;
+ char *style, *shell, *home, *s, **argv;
+ char path[MAXPATHLEN];
+ int authok;
+
+ /* User may have specified an authentication style. */
+ if ((style = strchr(greet->name, ':')) != NULL)
+ *style++ = '\0';
+
+ Debug ("Verify %s, style %s ...\n", greet->name,
+ style ? style : "default");
+
+ p = getpwnam (greet->name);
+ endpwent();
+
+ if (!p || strlen (greet->name) == 0) {
+ Debug("getpwnam() failed.\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+
+ if ((lc = login_getclass(p->pw_class)) == NULL) {
+ Debug("login_getclass() failed.\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+ if ((style = login_getstyle(lc, style, "xdm")) == NULL) {
+ Debug("login_getstyle() failed.\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+ if ((as = auth_open()) == NULL) {
+ Debug("auth_open() failed.\n");
+ login_close(lc);
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+ if (auth_setoption(as, "login", "yes") == -1) {
+ Debug("auth_setoption() failed.\n");
+ login_close(lc);
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+
+ /* Set up state for no challenge, just check a response. */
+ auth_setstate(as, 0);
+ auth_setdata(as, "", 1);
+ auth_setdata(as, greet->password, strlen(greet->password) + 1);
+
+ /* 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,
+ (void *)NULL);
+ authok = auth_getstate(as);
+
+ if ((authok & AUTH_ALLOW) == 0) {
+ Debug("password verify failed\n");
+ bzero(greet->password, strlen(greet->password));
+ auth_close(as);
+ login_close(lc);
+ return 0;
+ }
+ /* Run the approval script */
+ if (!auth_approval(as, lc, greet->name, "auth-xdm")) {
+ Debug("login not approved\n");
+ bzero(greet->password, strlen(greet->password));
+ auth_close(as);
+ login_close(lc);
+ return 0;
+ }
+ auth_close(as);
+ login_close(lc);
+ /* Check empty passwords against allowNullPasswd */
+ if (!greet->allow_null_passwd && strlen(greet->password) == 0) {
+ Debug("empty password not allowed\n");
+ return 0;
+ }
+ /* Only accept root logins if allowRootLogin resource is set */
+ if (p->pw_uid == 0 && !greet->allow_root_login) {
+ Debug("root logins not allowed\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+
+ /*
+ * Shell must be in /etc/shells
+ */
+ for (;;) {
+ s = getusershell();
+ if (s == NULL) {
+ /* did not found the shell in /etc/shells
+ -> failure */
+ Debug("shell not in /etc/shells\n");
+ bzero(greet->password, strlen(greet->password));
+ endusershell();
+ return 0;
+ }
+ if (strcmp(s, p->pw_shell) == 0) {
+ /* found the shell in /etc/shells */
+ endusershell();
+ break;
+ }
+ }
+#else /* !USE_BSDAUTH */
+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
#ifdef USESHADOW
struct spwd *sp;
#endif
- char *user_pass;
-#if !defined(SVR4) || !defined(GREET_LIB) /* shared lib decls handle this */
- char *crypt ();
- char **systemEnv (), **parseArgs ();
+ char *user_pass = NULL;
+#endif
+#ifdef __OpenBSD__
+ char *s;
+ struct timeval tp;
#endif
char *shell, *home;
char **argv;
Debug ("Verify %s ...\n", greet->name);
+#ifndef USE_PAM
p = getpwnam (greet->name);
+ endpwent();
+
if (!p || strlen (greet->name) == 0) {
Debug ("getpwnam() failed.\n");
bzero(greet->password, strlen(greet->password));
return 0;
} else {
+#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
user_pass = p->pw_passwd;
}
+#endif
+#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);
+ krb_set_tkt_string(krbtkfile);
+ unlink(krbtkfile);
+
+ 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");
+ if (k_hasafs()) {
+ if (k_setpag() == -1)
+ LogError ("setpag() failed for %s\n",
+ greet->name);
+
+ if((ret = k_afsklog(NULL, NULL)) != KSUCCESS)
+ LogError("Warning %s\n",
+ krb_get_err_text(ret));
+ }
+ goto done;
+ } else if(ret != KDC_PR_UNKNOWN && ret != SKDC_CANT){
+ /* failure */
+ Debug("kerberos verify failure %d\n", ret);
+ krbtkfile[0] = '\0';
+ }
+ }
+ }
+#endif
+#ifndef USE_PAM
#ifdef USESHADOW
errno = 0;
sp = getspnam(greet->name);
@@ -133,7 +371,9 @@ struct verify_info *verify;
} else {
user_pass = sp->sp_pwdp;
}
+#ifndef QNX4
endspent();
+#endif /* QNX4 doesn't need endspent() to end shadow passwd ops */
#endif
#if defined(ultrix) || defined(__ultrix__)
if (authenticate_user(p, greet->password, NULL) < 0)
@@ -141,12 +381,103 @@ struct verify_info *verify;
if (strcmp (crypt (greet->password, user_pass), user_pass))
#endif
{
- Debug ("password verify failed\n");
+ if(!greet->allow_null_passwd || strlen(p->pw_passwd) > 0) {
+ Debug ("password verify failed\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ } /* else: null passwd okay */
+ }
+#ifdef KERBEROS
+done:
+#endif
+#ifdef __OpenBSD__
+ /*
+ * Only accept root logins if allowRootLogin resource is set
+ */
+ if ((p->pw_uid == 0) && !greet->allow_root_login) {
+ Debug("root logins not allowed\n");
bzero(greet->password, strlen(greet->password));
return 0;
}
- Debug ("verify succeeded\n");
+ /*
+ * Shell must be in /etc/shells
+ */
+ for (;;) {
+ s = getusershell();
+ if (s == NULL) {
+ /* did not found the shell in /etc/shells
+ -> failure */
+ Debug("shell not in /etc/shells\n");
+ bzero(greet->password, strlen(greet->password));
+ endusershell();
+ return 0;
+ }
+ if (strcmp(s, p->pw_shell) == 0) {
+ /* found the shell in /etc/shells */
+ endusershell();
+ break;
+ }
+ }
+ /*
+ * Test for expired password
+ */
+ if (p->pw_change || p->pw_expire)
+ (void)gettimeofday(&tp, (struct timezone *)NULL);
+ if (p->pw_change) {
+ if (tp.tv_sec >= p->pw_change) {
+ Debug("Password has expired.\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+ }
+ if (p->pw_expire) {
+ if (tp.tv_sec >= p->pw_expire) {
+ Debug("account has expired.\n");
+ bzero(greet->password, strlen(greet->password));
+ return 0;
+ }
+ }
+#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 */
+
+ Debug ("verify succeeded\n");
/* The password is passed to StartClient() for use by user-based
authorization schemes. It is zeroed there. */
verify->uid = p->pw_uid;
diff --git a/krb5auth.c b/krb5auth.c
index 5451430..d6f57da 100644
--- a/krb5auth.c
+++ b/krb5auth.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/krb5auth.c,v 1.4 2001/12/14 20:01:22 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -39,15 +40,16 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <krb5/krb5.h>
#include <krb5/kdb.h> /* for TGTNAME */
/*ARGSUSED*/
-Krb5InitAuth (name_len, name)
- unsigned short name_len;
- char *name;
+void
+Krb5InitAuth (unsigned short name_len, char *name)
{
krb5_init_ets(); /* initialize error_message() tables */
}
@@ -57,8 +59,7 @@ Krb5InitAuth (name_len, name)
* name should be freed by caller.
*/
char *
-Krb5CCacheName(dname)
- char *dname;
+Krb5CCacheName(char *dname)
{
char *name;
char *tmpdir;
@@ -75,9 +76,7 @@ Krb5CCacheName(dname)
}
krb5_error_code
-Krb5DisplayCCache(dname, ccache_return)
- char *dname;
- krb5_ccache *ccache_return;
+Krb5DisplayCCache(char *dname, krb5_ccache *ccache_return)
{
krb5_error_code code;
char *name;
@@ -92,10 +91,7 @@ Krb5DisplayCCache(dname, ccache_return)
}
Xauth *
-Krb5GetAuthFor(namelen, name, dname)
- unsigned short namelen;
- char *name;
- char *dname;
+Krb5GetAuthFor(unsigned short namelen, char *name, char *dname)
{
Xauth *new;
char *filename;
@@ -145,9 +141,7 @@ Krb5GetAuthFor(namelen, name, dname)
Xauth *
-Krb5GetAuth (namelen, name)
- unsigned short namelen;
- char *name;
+Krb5GetAuth (unsigned short namelen, char *name)
{
return Krb5GetAuthFor(namelen, name, NULL);
}
@@ -164,10 +158,10 @@ int preauth_search_list[] = {
* Returns 0 if successful, 1 if not.
*/
int
-Krb5Init(name, passwd, d)
- char *name;
- char *passwd;
- struct display *d; /* k5_ccache filled in if successful */
+Krb5Init(
+ char *name,
+ char *passwd,
+ struct display *d) /* k5_ccache filled in if successful */
{
krb5_ccache ccache;
krb5_error_code code;
diff --git a/mitauth.c b/mitauth.c
index 1eee630..6c0ad9c 100644
--- a/mitauth.c
+++ b/mitauth.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/mitauth.c,v 1.4 2001/12/14 20:01:22 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -38,15 +39,16 @@ from The Open Group.
*/
# include <X11/Xos.h>
+
# include "dm.h"
+# include "dm_auth.h"
# define AUTH_DATA_LEN 16 /* bytes of authorization data */
static char auth_name[256];
static int auth_name_len;
-MitInitAuth (name_len, name)
- unsigned short name_len;
- char *name;
+void
+MitInitAuth (unsigned short name_len, char *name)
{
if (name_len > 256)
name_len = 256;
@@ -55,9 +57,7 @@ MitInitAuth (name_len, name)
}
Xauth *
-MitGetAuth (namelen, name)
- unsigned short namelen;
- char *name;
+MitGetAuth (unsigned short namelen, char *name)
{
Xauth *new;
new = (Xauth *) malloc (sizeof (Xauth));
diff --git a/netaddr.c b/netaddr.c
index 7053780..02cde08 100644
--- a/netaddr.c
+++ b/netaddr.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/netaddr.c,v 3.6 2001/12/14 20:01:22 dawes Exp $ */
/*
* xdm - X display manager
@@ -34,16 +35,22 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
#include <X11/X.h> /* FamilyInternet, etc. */
#ifdef XDMCP
-#include <sys/socket.h> /* struct sockaddr */
-#include <netinet/in.h> /* struct sockaddr_in */
+#include "dm_socket.h"
#ifdef UNIXCONN
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
#include <sys/un.h> /* struct sockaddr_un */
+#else
+#include <un.h> /* struct sockaddr_un */
+#endif
+#endif
#endif
#ifdef DNETCONN
#include <netdnet/dn.h> /* struct sockaddr_dn */
@@ -52,8 +59,7 @@ from The Open Group.
/* given an XdmcpNetaddr, returns the socket protocol family used,
e.g., AF_INET */
-int NetaddrFamily(netaddrp)
- XdmcpNetaddr netaddrp;
+int NetaddrFamily(XdmcpNetaddr netaddrp)
{
#ifdef STREAMSCONN
short family = *(short *)netaddrp;
@@ -68,9 +74,7 @@ int NetaddrFamily(netaddrp)
and sets *lenp to the length of the address
or 0 if not using TCP or UDP. */
-char * NetaddrPort(netaddrp, lenp)
- XdmcpNetaddr netaddrp;
- int *lenp; /* return */
+char * NetaddrPort(XdmcpNetaddr netaddrp, int *lenp)
{
#ifdef STREAMSCONN
*lenp = 2;
@@ -92,9 +96,7 @@ char * NetaddrPort(netaddrp, lenp)
/* given an XdmcpNetaddr, returns a pointer to the network address
and sets *lenp to the length of the address */
-char * NetaddrAddress(netaddrp, lenp)
- XdmcpNetaddr netaddrp;
- int *lenp; /* return */
+char * NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp)
{
#ifdef STREAMSCONN
*lenp = 4;
@@ -131,10 +133,7 @@ char * NetaddrAddress(netaddrp, lenp)
sets *len to the number of bytes in addr.
Returns the X protocol family used, e.g., FamilyInternet */
-int ConvertAddr (saddr, len, addr)
- XdmcpNetaddr saddr;
- int *len; /* return */
- char **addr; /* return */
+int ConvertAddr (XdmcpNetaddr saddr, int *len, char **addr)
{
int retval;
@@ -185,9 +184,8 @@ int ConvertAddr (saddr, len, addr)
return retval;
}
-addressEqual (a1, len1, a2, len2)
- XdmcpNetaddr a1, a2;
- int len1, len2;
+int
+addressEqual (XdmcpNetaddr a1, int len1, XdmcpNetaddr a2, int len2)
{
int partlen1, partlen2;
char *part1, *part2;
@@ -217,9 +215,8 @@ addressEqual (a1, len1, a2, len2)
#ifdef DEBUG
/*ARGSUSED*/
-PrintSockAddr (a, len) /* Debugging routine */
- struct sockaddr *a;
- int len;
+void
+PrintSockAddr (struct sockaddr *a, int len)
{
unsigned char *t, *p;
diff --git a/policy.c b/policy.c
index 3cffa90..29982cb 100644
--- a/policy.c
+++ b/policy.c
@@ -33,16 +33,18 @@ from The Open Group.
*
* policy.c. Implement site-dependent policy for XDMCP connections
*/
+/* $XFree86: xc/programs/xdm/policy.c,v 3.8 2002/12/07 20:31:04 herrb Exp $ */
# include "dm.h"
+# include "dm_auth.h"
+
+#include <errno.h>
#ifdef XDMCP
# include <X11/X.h>
-# include <sys/socket.h>
-#ifdef AF_INET
-# include <netinet/in.h>
-#endif
+
+# include "dm_socket.h"
static ARRAY8 noAuthentication = { (CARD16) 0, (CARD8Ptr) 0 };
@@ -65,8 +67,7 @@ static XdmAuthRec auth[] = {
#define NumAuth (sizeof auth / sizeof auth[0])
ARRAY8Ptr
-ChooseAuthentication (authenticationNames)
- ARRAYofARRAY8Ptr authenticationNames;
+ChooseAuthentication (ARRAYofARRAY8Ptr authenticationNames)
{
int i, j;
@@ -78,9 +79,12 @@ ChooseAuthentication (authenticationNames)
return &noAuthentication;
}
-CheckAuthentication (pdpy, displayID, name, data)
- struct protoDisplay *pdpy;
- ARRAY8Ptr displayID, name, data;
+int
+CheckAuthentication (
+ struct protoDisplay *pdpy,
+ ARRAY8Ptr displayID,
+ ARRAY8Ptr name,
+ ARRAY8Ptr data)
{
#ifdef HASXDMAUTH
if (name->length && !strncmp ((char *)name->data, "XDM-AUTHENTICATION-1", 20))
@@ -90,9 +94,9 @@ CheckAuthentication (pdpy, displayID, name, data)
}
int
-SelectAuthorizationTypeIndex (authenticationName, authorizationNames)
- ARRAY8Ptr authenticationName;
- ARRAYofARRAY8Ptr authorizationNames;
+SelectAuthorizationTypeIndex (
+ ARRAY8Ptr authenticationName,
+ ARRAYofARRAY8Ptr authorizationNames)
{
int i, j;
@@ -116,12 +120,12 @@ SelectAuthorizationTypeIndex (authenticationName, authorizationNames)
/*ARGSUSED*/
int
-Willing (addr, connectionType, authenticationName, status, type)
- ARRAY8Ptr addr;
- CARD16 connectionType;
- ARRAY8Ptr authenticationName;
- ARRAY8Ptr status;
- xdmOpCode type;
+Willing (
+ ARRAY8Ptr addr,
+ CARD16 connectionType,
+ ARRAY8Ptr authenticationName,
+ ARRAY8Ptr status,
+ xdmOpCode type)
{
char statusBuf[256];
int ret;
@@ -130,7 +134,26 @@ Willing (addr, connectionType, authenticationName, status, type)
if (!ret)
sprintf (statusBuf, "Display not authorized to connect");
else
- sprintf (statusBuf, "Willing to manage");
+ {
+ if (*willing)
+ { FILE *fd = NULL;
+ if ((fd = popen(willing, "r")))
+ {
+ char *s = NULL;
+ while(!(s = fgets(statusBuf, 256, fd)) && errno == EINTR)
+ ;
+ if (s && strlen(statusBuf) > 0)
+ statusBuf[strlen(statusBuf)-1] = 0; /* chop newline */
+ else
+ snprintf (statusBuf, sizeof(statusBuf), "Willing, but %s failed",willing);
+ }
+ else
+ snprintf (statusBuf, sizeof(statusBuf), "Willing, but %s failed",willing);
+ if (fd) pclose(fd);
+ }
+ else
+ sprintf (statusBuf, "Willing to manage");
+ }
status->length = strlen (statusBuf);
status->data = (CARD8Ptr) malloc (status->length);
if (!status->data)
@@ -142,19 +165,19 @@ Willing (addr, connectionType, authenticationName, status, type)
/*ARGSUSED*/
ARRAY8Ptr
-Accept (from, fromlen, displayNumber)
- struct sockaddr *from;
- int fromlen;
- CARD16 displayNumber;
+Accept (
+ struct sockaddr *from,
+ int fromlen,
+ CARD16 displayNumber)
{
return 0;
}
/*ARGSUSED*/
int
-SelectConnectionTypeIndex (connectionTypes, connectionAddresses)
- ARRAY16Ptr connectionTypes;
- ARRAYofARRAY8Ptr connectionAddresses;
+SelectConnectionTypeIndex (
+ ARRAY16Ptr connectionTypes,
+ ARRAYofARRAY8Ptr connectionAddresses)
{
return 0;
}
diff --git a/protodpy.c b/protodpy.c
index 4672f77..47c25e4 100644
--- a/protodpy.c
+++ b/protodpy.c
@@ -25,6 +25,7 @@ in this Software without prior written authorization from The Open Group.
*
* Author: Keith Packard, MIT X Consortium
*/
+/* $XFree86: xc/programs/xdm/protodpy.c,v 1.5 2001/12/14 20:01:23 dawes Exp $ */
/*
* protodpy.c
@@ -35,17 +36,13 @@ in this Software without prior written authorization from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
#ifdef XDMCP
#include <sys/types.h>
-#ifdef X_NOT_STDC_ENV
-#define Time_t long
-extern Time_t time ();
-#else
#include <time.h>
#define Time_t time_t
-#endif
static struct protoDisplay *protoDisplays;
@@ -64,10 +61,10 @@ PrintProtoDisplay (pdpy)
#endif
struct protoDisplay *
-FindProtoDisplay (address, addrlen, displayNumber)
- XdmcpNetaddr address;
- int addrlen;
- CARD16 displayNumber;
+FindProtoDisplay (
+ XdmcpNetaddr address,
+ int addrlen,
+ CARD16 displayNumber)
{
struct protoDisplay *pdpy;
@@ -83,9 +80,8 @@ FindProtoDisplay (address, addrlen, displayNumber)
return (struct protoDisplay *) 0;
}
-static
-TimeoutProtoDisplays (now)
- Time_t now;
+static void
+TimeoutProtoDisplays (Time_t now)
{
struct protoDisplay *pdpy, *next;
@@ -98,14 +94,13 @@ TimeoutProtoDisplays (now)
}
struct protoDisplay *
-NewProtoDisplay (address, addrlen, displayNumber,
- connectionType, connectionAddress, sessionID)
- XdmcpNetaddr address;
- int addrlen;
- CARD16 displayNumber;
- CARD16 connectionType;
- ARRAY8Ptr connectionAddress;
- CARD32 sessionID;
+NewProtoDisplay (
+ XdmcpNetaddr address,
+ int addrlen,
+ CARD16 displayNumber,
+ CARD16 connectionType,
+ ARRAY8Ptr connectionAddress,
+ CARD32 sessionID)
{
struct protoDisplay *pdpy;
Time_t date;
diff --git a/reset.c b/reset.c
index 76dfb9d..d5c49ca 100644
--- a/reset.c
+++ b/reset.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/reset.c,v 1.4 2001/12/14 20:01:23 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -37,16 +38,17 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
+
# include <X11/Xlib.h>
# include <signal.h>
/*ARGSUSED*/
static int
-ignoreErrors (dpy, event)
-Display *dpy;
-XErrorEvent *event;
+ignoreErrors (Display *dpy, XErrorEvent *event)
{
Debug ("ignoring error\n");
+ return 0;
}
/*
@@ -55,10 +57,8 @@ XErrorEvent *event;
* this code wouldn't have to be this kludgy.
*/
-static
-killWindows (dpy, window)
-Display *dpy;
-Window window;
+static void
+killWindows (Display *dpy, Window window)
{
Window root, parent, *children;
int child;
@@ -68,7 +68,7 @@ Window window;
&& nchildren > 0)
{
for (child = 0; child < nchildren; child++) {
- Debug ("XKillClient 0x%x\n", children[child]);
+ Debug ("XKillClient 0x%lx\n", (unsigned long)children[child]);
XKillClient (dpy, children[child]);
}
XFree ((char *)children);
@@ -79,8 +79,7 @@ static Jmp_buf resetJmp;
/* ARGSUSED */
static SIGVAL
-abortReset (n)
- int n;
+abortReset (int n)
{
Longjmp (resetJmp, 1);
}
@@ -89,8 +88,8 @@ abortReset (n)
* this display connection better not have any windows...
*/
-pseudoReset (dpy)
-Display *dpy;
+void
+pseudoReset (Display *dpy)
{
Window root;
int screen;
@@ -111,6 +110,6 @@ Display *dpy;
(void) alarm (0);
}
Signal (SIGALRM, SIG_DFL);
- XSetErrorHandler ((int (*)()) 0);
+ XSetErrorHandler ((XErrorHandler)0 );
Debug ("pseudoReset done\n");
}
diff --git a/resource.c b/resource.c
index 5745ae6..982dd8e 100644
--- a/resource.c
+++ b/resource.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/resource.c,v 3.10 2002/12/07 20:31:04 herrb Exp $ */
/*
* xdm - display manager daemon
@@ -35,6 +36,8 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
+
# include <X11/Intrinsic.h>
# include <X11/Xmu/CharSet.h>
@@ -47,6 +50,7 @@ char *errorLogFile;
int daemonMode;
char *pidFile;
int lockPidFile;
+int sourceAddress;
char *authDir;
int autoRescan;
int removeDomainname;
@@ -55,6 +59,7 @@ char *accessFile;
char **exportList;
char *randomFile;
char *greeterLib;
+char *willing;
int choiceTimeout; /* chooser choice timeout */
# define DM_STRING 0
@@ -114,10 +119,14 @@ int choiceTimeout; /* chooser choice timeout */
#define DEF_ACCESS_FILE ""
#endif
#ifndef DEF_RANDOM_FILE
-#define DEF_RANDOM_FILE "/dev/mem"
+# ifdef linux
+# define DEF_RANDOM_FILE "/dev/urandom"
+# else
+# define DEF_RANDOM_FILE "/dev/mem"
+# endif
#endif
#ifndef DEF_GREETER_LIB
-#define DEF_GREETER_LIB "/X11/lib/X11/xdm/libXdmGreet.so"
+#define DEF_GREETER_LIB "/usr/lib/X11/xdm/libXdmGreet.so"
#endif
#define DEF_UDP_PORT "177" /* registered XDMCP port, dont change */
@@ -128,38 +137,42 @@ struct dmResources {
char **dm_value;
char *default_value;
} DmResources[] = {
-"servers", "Servers", DM_STRING, &servers,
- DEF_SERVER_LINE,
-"requestPort", "RequestPort", DM_INT, (char **) &request_port,
- DEF_UDP_PORT,
-"debugLevel", "DebugLevel", DM_INT, (char **) &debugLevel,
- "0",
-"errorLogFile", "ErrorLogFile", DM_STRING, &errorLogFile,
- "",
-"daemonMode", "DaemonMode", DM_BOOL, (char **) &daemonMode,
- "true",
-"pidFile", "PidFile", DM_STRING, &pidFile,
- "",
-"lockPidFile", "LockPidFile", DM_BOOL, (char **) &lockPidFile,
- "true",
-"authDir", "authDir", DM_STRING, &authDir,
- DEF_AUTH_DIR,
-"autoRescan", "AutoRescan", DM_BOOL, (char **) &autoRescan,
- "true",
-"removeDomainname","RemoveDomainname",DM_BOOL, (char **) &removeDomainname,
- "true",
-"keyFile", "KeyFile", DM_STRING, &keyFile,
- DEF_KEY_FILE,
-"accessFile", "AccessFile", DM_STRING, &accessFile,
- DEF_ACCESS_FILE,
-"exportList", "ExportList", DM_ARGV, (char **) &exportList,
- "",
-"randomFile", "RandomFile", DM_STRING, &randomFile,
- DEF_RANDOM_FILE,
-"greeterLib", "GreeterLib", DM_STRING, &greeterLib,
- DEF_GREETER_LIB,
-"choiceTimeout","ChoiceTimeout",DM_INT, (char **) &choiceTimeout,
- "15",
+{ "servers", "Servers", DM_STRING, &servers,
+ DEF_SERVER_LINE} ,
+{ "requestPort","RequestPort", DM_INT, (char **) &request_port,
+ DEF_UDP_PORT} ,
+{ "debugLevel", "DebugLevel", DM_INT, (char **) &debugLevel,
+ "0"} ,
+{ "errorLogFile","ErrorLogFile", DM_STRING, &errorLogFile,
+ ""} ,
+{ "daemonMode", "DaemonMode", DM_BOOL, (char **) &daemonMode,
+ "true"} ,
+{ "pidFile", "PidFile", DM_STRING, &pidFile,
+ ""} ,
+{ "lockPidFile","LockPidFile", DM_BOOL, (char **) &lockPidFile,
+ "true"} ,
+{ "authDir", "authDir", DM_STRING, &authDir,
+ DEF_AUTH_DIR} ,
+{ "autoRescan", "AutoRescan", DM_BOOL, (char **) &autoRescan,
+ "true"} ,
+{ "removeDomainname","RemoveDomainname",DM_BOOL,(char **) &removeDomainname,
+ "true"} ,
+{ "keyFile", "KeyFile", DM_STRING, &keyFile,
+ DEF_KEY_FILE} ,
+{ "accessFile", "AccessFile", DM_STRING, &accessFile,
+ DEF_ACCESS_FILE} ,
+{ "exportList", "ExportList", DM_ARGV, (char **) &exportList,
+ ""} ,
+{ "randomFile", "RandomFile", DM_STRING, &randomFile,
+ DEF_RANDOM_FILE} ,
+{ "greeterLib", "GreeterLib", DM_STRING, &greeterLib,
+ DEF_GREETER_LIB} ,
+{ "choiceTimeout","ChoiceTimeout",DM_INT, (char **) &choiceTimeout,
+ "15"} ,
+{ "sourceAddress","SourceAddress",DM_BOOL, (char **) &sourceAddress,
+ "false"} ,
+{ "willing", "Willing", DM_STRING, &willing,
+ ""} ,
};
# define NUM_DM_RESOURCES (sizeof DmResources / sizeof DmResources[0])
@@ -176,40 +189,40 @@ struct displayResource {
/* resources for managing the server */
struct displayResource serverResources[] = {
-"serverAttempts","ServerAttempts",DM_INT, boffset(serverAttempts),
- "1",
-"openDelay", "OpenDelay", DM_INT, boffset(openDelay),
- "15",
-"openRepeat", "OpenRepeat", DM_INT, boffset(openRepeat),
- "5",
-"openTimeout", "OpenTimeout", DM_INT, boffset(openTimeout),
- "30",
-"startAttempts","StartAttempts",DM_INT, boffset(startAttempts),
- "4",
-"pingInterval", "PingInterval", DM_INT, boffset(pingInterval),
- "5",
-"pingTimeout", "PingTimeout", DM_INT, boffset(pingTimeout),
- "5",
-"terminateServer","TerminateServer",DM_BOOL, boffset(terminateServer),
- "false",
-"grabServer", "GrabServer", DM_BOOL, boffset(grabServer),
- "false",
-"grabTimeout", "GrabTimeout", DM_INT, boffset(grabTimeout),
- "3",
-"resetSignal", "Signal", DM_INT, boffset(resetSignal),
- "1", /* SIGHUP */
-"termSignal", "Signal", DM_INT, boffset(termSignal),
- "15", /* SIGTERM */
-"resetForAuth", "ResetForAuth", DM_BOOL, boffset(resetForAuth),
- "false",
-"authorize", "Authorize", DM_BOOL, boffset(authorize),
- "true",
-"authComplain", "AuthComplain", DM_BOOL, boffset(authComplain),
- "true",
-"authName", "AuthName", DM_ARGV, boffset(authNames),
- DEF_AUTH_NAME,
-"authFile", "AuthFile", DM_STRING, boffset(clientAuthFile),
- "",
+{ "serverAttempts","ServerAttempts",DM_INT, boffset(serverAttempts),
+ "1" },
+{ "openDelay", "OpenDelay", DM_INT, boffset(openDelay),
+ "15" },
+{ "openRepeat", "OpenRepeat", DM_INT, boffset(openRepeat),
+ "5" },
+{ "openTimeout","OpenTimeout", DM_INT, boffset(openTimeout),
+ "120" },
+{ "startAttempts","StartAttempts",DM_INT, boffset(startAttempts),
+ "4" },
+{ "pingInterval","PingInterval",DM_INT, boffset(pingInterval),
+ "5" },
+{ "pingTimeout","PingTimeout", DM_INT, boffset(pingTimeout),
+ "5" },
+{ "terminateServer","TerminateServer",DM_BOOL, boffset(terminateServer),
+ "false" },
+{ "grabServer", "GrabServer", DM_BOOL, boffset(grabServer),
+ "false" },
+{ "grabTimeout","GrabTimeout", DM_INT, boffset(grabTimeout),
+ "3" },
+{ "resetSignal","Signal", DM_INT, boffset(resetSignal),
+ "1" }, /* SIGHUP */
+{ "termSignal", "Signal", DM_INT, boffset(termSignal),
+ "15" }, /* SIGTERM */
+{ "resetForAuth","ResetForAuth",DM_BOOL, boffset(resetForAuth),
+ "false" },
+{ "authorize", "Authorize", DM_BOOL, boffset(authorize),
+ "true" },
+{ "authComplain","AuthComplain",DM_BOOL, boffset(authComplain),
+ "true" },
+{ "authName", "AuthName", DM_ARGV, boffset(authNames),
+ DEF_AUTH_NAME },
+{ "authFile", "AuthFile", DM_STRING, boffset(clientAuthFile),
+ "" },
};
# define NUM_SERVER_RESOURCES (sizeof serverResources/\
@@ -218,30 +231,30 @@ struct displayResource serverResources[] = {
/* resources which control the session behaviour */
struct displayResource sessionResources[] = {
-"resources", "Resources", DM_STRING, boffset(resources),
- "",
-"xrdb", "Xrdb", DM_STRING, boffset(xrdb),
- XRDB_PROGRAM,
-"setup", "Setup", DM_STRING, boffset(setup),
- "",
-"startup", "Startup", DM_STRING, boffset(startup),
- "",
-"reset", "Reset", DM_STRING, boffset(reset),
- "",
-"session", "Session", DM_STRING, boffset(session),
- DEF_SESSION,
-"userPath", "Path", DM_STRING, boffset(userPath),
- DEF_USER_PATH,
-"systemPath", "Path", DM_STRING, boffset(systemPath),
- DEF_SYSTEM_PATH,
-"systemShell", "Shell", DM_STRING, boffset(systemShell),
- DEF_SYSTEM_SHELL,
-"failsafeClient","FailsafeClient", DM_STRING, boffset(failsafeClient),
- DEF_FAILSAFE_CLIENT,
-"userAuthDir", "UserAuthDir", DM_STRING, boffset(userAuthDir),
- DEF_USER_AUTH_DIR,
-"chooser", "Chooser", DM_STRING, boffset(chooser),
- DEF_CHOOSER,
+{ "resources", "Resources", DM_STRING, boffset(resources),
+ "" },
+{ "xrdb", "Xrdb", DM_STRING, boffset(xrdb),
+ XRDB_PROGRAM },
+{ "setup", "Setup", DM_STRING, boffset(setup),
+ "" },
+{ "startup", "Startup", DM_STRING, boffset(startup),
+ "" },
+{ "reset", "Reset", DM_STRING, boffset(reset),
+ "" },
+{ "session", "Session", DM_STRING, boffset(session),
+ DEF_SESSION },
+{ "userPath", "Path", DM_STRING, boffset(userPath),
+ DEF_USER_PATH },
+{ "systemPath", "Path", DM_STRING, boffset(systemPath),
+ DEF_SYSTEM_PATH },
+{ "systemShell","Shell", DM_STRING, boffset(systemShell),
+ DEF_SYSTEM_SHELL },
+{ "failsafeClient","FailsafeClient", DM_STRING, boffset(failsafeClient),
+ DEF_FAILSAFE_CLIENT },
+{ "userAuthDir","UserAuthDir", DM_STRING, boffset(userAuthDir),
+ DEF_USER_AUTH_DIR },
+{ "chooser", "Chooser", DM_STRING, boffset(chooser),
+ DEF_CHOOSER },
};
# define NUM_SESSION_RESOURCES (sizeof sessionResources/\
@@ -249,18 +262,19 @@ struct displayResource sessionResources[] = {
XrmDatabase DmResourceDB;
-GetResource (name, class, valueType, valuep, default_value)
- char *name, *class;
- int valueType;
- char **valuep;
- char *default_value;
+static void
+GetResource (
+ char *name,
+ char *class,
+ int valueType,
+ char **valuep,
+ char *default_value)
{
char *type;
XrmValue value;
char *string, *new_string;
char str_buf[50];
int len;
- extern char **parseArgs();
if (DmResourceDB && XrmGetResource (DmResourceDB,
name, class,
@@ -347,9 +361,8 @@ XrmOptionDescRec optionTable [] = {
static int originalArgc;
static char **originalArgv;
-InitResources (argc, argv)
-int argc;
-char **argv;
+void
+InitResources (int argc, char **argv)
{
XrmInitialize ();
originalArgc = argc;
@@ -357,7 +370,8 @@ char **argv;
ReinitResources ();
}
-ReinitResources ()
+void
+ReinitResources (void)
{
int argc;
char **a;
@@ -401,24 +415,23 @@ ReinitResources ()
free (argv);
}
-LoadDMResources ()
+void
+LoadDMResources (void)
{
int i;
char name[1024], class[1024];
for (i = 0; i < NUM_DM_RESOURCES; i++) {
- sprintf (name, "DisplayManager.%s", DmResources[i].name);
- sprintf (class, "DisplayManager.%s", DmResources[i].class);
+ snprintf (name, sizeof(name), "DisplayManager.%s", DmResources[i].name);
+ snprintf (class, sizeof(class), "DisplayManager.%s", DmResources[i].class);
GetResource (name, class, DmResources[i].type,
(char **) DmResources[i].dm_value,
DmResources[i].default_value);
}
}
-static
-CleanUpName (src, dst, len)
-char *src, *dst;
-int len;
+static void
+CleanUpName (char *src, char *dst, int len)
{
while (*src) {
if (--len <= 0)
@@ -437,10 +450,11 @@ int len;
*dst = '\0';
}
-LoadDisplayResources (d, resources, numResources)
- struct display *d;
- struct displayResource *resources;
- int numResources;
+static void
+LoadDisplayResources (
+ struct display *d,
+ struct displayResource *resources,
+ int numResources)
{
int i;
char name[1024], class[1024];
@@ -449,9 +463,9 @@ LoadDisplayResources (d, resources, numResources)
CleanUpName (d->name, dpyName, sizeof (dpyName));
CleanUpName (d->class ? d->class : d->name, dpyClass, sizeof (dpyClass));
for (i = 0; i < numResources; i++) {
- sprintf (name, "DisplayManager.%s.%s",
+ snprintf (name, sizeof(name), "DisplayManager.%s.%s",
dpyName, resources[i].name);
- sprintf (class, "DisplayManager.%s.%s",
+ snprintf (class, sizeof(class), "DisplayManager.%s.%s",
dpyClass, resources[i].class);
GetResource (name, class, resources[i].type,
(char **) (((char *) d) + resources[i].offset),
@@ -459,14 +473,14 @@ LoadDisplayResources (d, resources, numResources)
}
}
-LoadServerResources (d)
- struct display *d;
+void
+LoadServerResources (struct display *d)
{
LoadDisplayResources (d, serverResources, NUM_SERVER_RESOURCES);
}
-LoadSessionResources (d)
- struct display *d;
+void
+LoadSessionResources (struct display *d)
{
LoadDisplayResources (d, sessionResources, NUM_SESSION_RESOURCES);
}
diff --git a/rpcauth.c b/rpcauth.c
index 7c94652..399ebb6 100644
--- a/rpcauth.c
+++ b/rpcauth.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/rpcauth.c,v 1.4 2001/12/14 20:01:23 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -39,19 +40,21 @@ from The Open Group.
# include <X11/Xos.h>
# include <rpc/rpc.h>
# include <rpc/key_prot.h>
+
# include "dm.h"
+# include "dm_auth.h"
+# include "dm_error.h"
/*ARGSUSED*/
-SecureRPCInitAuth (name_len, name)
- unsigned short name_len;
- char *name;
+void
+SecureRPCInitAuth (unsigned short name_len, char *name)
{
}
Xauth *
-SecureRPCGetAuth (namelen, name)
- unsigned short namelen;
- char *name;
+SecureRPCGetAuth (
+ unsigned short namelen,
+ char *name)
{
char key[MAXNETNAMELEN+1];
Xauth *new;
diff --git a/server.c b/server.c
index 76c17d7..2ee5bba 100644
--- a/server.c
+++ b/server.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/server.c,v 3.13 2001/12/14 20:01:23 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,6 +36,9 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
+# include "dm_socket.h"
+
# include <X11/Xlib.h>
# include <X11/Xos.h>
# include <stdio.h>
@@ -42,42 +46,38 @@ from The Open Group.
# include <errno.h>
# include <sys/socket.h>
-static receivedUsr1;
-
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
+static int receivedUsr1;
-static serverPause ();
+static int serverPause (unsigned t, int serverPid);
static Display *dpy;
/* ARGSUSED */
static SIGVAL
-CatchUsr1 (n)
- int n;
+CatchUsr1 (int n)
{
+ int olderrno = errno;
+
#ifdef SIGNALS_RESET_WHEN_CAUGHT
(void) Signal (SIGUSR1, CatchUsr1);
#endif
Debug ("display manager caught SIGUSR1\n");
++receivedUsr1;
+ errno = olderrno;
}
-char *_SysErrorMsg (n)
- int n;
+char *_SysErrorMsg (int n)
{
char *s = strerror(n);
return (s ? s : "unknown error");
}
-StartServerOnce (d)
-struct display *d;
+static int
+StartServerOnce (struct display *d)
{
char **f;
char **argv;
char arg[1024];
- char **parseArgs ();
int pid;
Debug ("StartServer for %s\n", d->name);
@@ -87,6 +87,10 @@ struct display *d;
switch (pid = fork ()) {
case 0:
CleanUpChild ();
+#ifdef XDMCP
+ /* The chooser socket is not closed by CleanUpChild() */
+ DestroyWellKnownSockets();
+#endif
if (d->authFile) {
sprintf (arg, "-auth %s", d->authFile);
argv = parseArgs (argv, arg);
@@ -123,8 +127,8 @@ struct display *d;
return TRUE;
}
-StartServer (d)
-struct display *d;
+int
+StartServer (struct display *d)
{
int i;
int ret = FALSE;
@@ -150,26 +154,22 @@ static int serverPauseRet;
/* ARGSUSED */
static SIGVAL
-serverPauseAbort (n)
- int n;
+serverPauseAbort (int n)
{
Longjmp (pauseAbort, 1);
}
/* ARGSUSED */
static SIGVAL
-serverPauseUsr1 (n)
- int n;
+serverPauseUsr1 (int n)
{
Debug ("display manager paused til SIGUSR1\n");
++receivedUsr1;
Longjmp (pauseAbort, 1);
}
-static
-serverPause (t, serverPid)
-unsigned t;
-int serverPid;
+static int
+serverPause (unsigned t, int serverPid)
{
int pid;
@@ -203,7 +203,7 @@ int serverPid;
#endif /* X_NOT_POSIX */
#endif /* SYSV */
if (pid == serverPid ||
- pid == -1 && errno == ECHILD)
+ (pid == -1 && errno == ECHILD))
{
Debug ("Server dead\n");
serverPauseRet = 1;
@@ -240,8 +240,7 @@ static Jmp_buf openAbort;
/* ARGSUSED */
static SIGVAL
-abortOpen (n)
- int n;
+abortOpen (int n)
{
Longjmp (openAbort, 1);
}
@@ -252,10 +251,8 @@ abortOpen (n)
#include <tiuser.h>
#endif
-static
-GetRemoteAddress (d, fd)
- struct display *d;
- int fd;
+static void
+GetRemoteAddress (struct display *d, int fd)
{
char buf[512];
int len = sizeof (buf);
@@ -272,7 +269,7 @@ GetRemoteAddress (d, fd)
len = 8;
/* lucky for us, t_getname returns something that looks like a sockaddr */
#else
- getpeername (fd, (struct sockaddr *) buf, &len);
+ getpeername (fd, (struct sockaddr *) buf, (void *)&len);
#endif
d->peerlen = 0;
if (len)
@@ -290,18 +287,18 @@ GetRemoteAddress (d, fd)
#endif /* XDMCP */
static int
-openErrorHandler (dpy)
- Display *dpy;
+openErrorHandler (Display *dpy)
{
LogError ("IO Error in XOpenDisplay\n");
exit (OPENFAILED_DISPLAY);
+ /*NOTREACHED*/
+ return(0);
}
int
-WaitForServer (d)
- struct display *d;
+WaitForServer (struct display *d)
{
- int i;
+ static int i;
for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) {
(void) Signal (SIGALRM, abortOpen);
@@ -324,7 +321,7 @@ WaitForServer (d)
#endif
(void) alarm ((unsigned) 0);
(void) Signal (SIGALRM, SIG_DFL);
- (void) XSetIOErrorHandler ((int (*)()) 0);
+ (void) XSetIOErrorHandler ((int (*)(Display *)) 0);
Debug ("After XOpenDisplay(%s)\n", d->name);
if (dpy) {
#ifdef XDMCP
@@ -336,7 +333,7 @@ WaitForServer (d)
return 1;
} else {
Debug ("OpenDisplay failed %d (%s) on \"%s\"\n",
- errno, _SysErrorMsg (errno), d->name);
+ errno, strerror (errno), d->name);
}
Debug ("waiting for server to start %d\n", i);
sleep ((unsigned) d->openDelay);
@@ -352,8 +349,8 @@ WaitForServer (d)
return 0;
}
-ResetServer (d)
- struct display *d;
+void
+ResetServer (struct display *d)
{
if (dpy && d->displayType.origin != FromXDMCP)
pseudoReset (dpy);
@@ -362,37 +359,35 @@ ResetServer (d)
static Jmp_buf pingTime;
static void
-PingLost ()
+PingLost (void)
{
Longjmp (pingTime, 1);
}
/* ARGSUSED */
static int
-PingLostIOErr (dpy)
- Display *dpy;
+PingLostIOErr (Display *dpy)
{
PingLost();
+ return 0;
}
/* ARGSUSED */
static SIGVAL
-PingLostSig (n)
- int n;
+PingLostSig (int n)
{
PingLost();
}
-PingServer (d, alternateDpy)
- struct display *d;
- Display *alternateDpy;
+int
+PingServer (struct display *d, Display *alternateDpy)
{
- int (*oldError)();
- SIGVAL (*oldSig)();
+ int (*oldError)(Display *);
+ SIGVAL (*oldSig)(int);
int oldAlarm;
-
- if (!alternateDpy)
- alternateDpy = dpy;
+ static Display *aDpy;
+
+ aDpy = (alternateDpy != NULL ? alternateDpy : dpy);
oldError = XSetIOErrorHandler (PingLostIOErr);
oldAlarm = alarm (0);
oldSig = Signal (SIGALRM, PingLostSig);
@@ -400,7 +395,7 @@ PingServer (d, alternateDpy)
if (!Setjmp (pingTime))
{
Debug ("Ping server\n");
- XSync (alternateDpy, 0);
+ XSync (aDpy, 0);
}
else
{
diff --git a/session.c b/session.c
index 9eae405..9befc15 100644
--- a/session.c
+++ b/session.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/session.c,v 3.33 2001/12/14 20:01:23 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,13 +36,18 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_auth.h"
+#include "dm_error.h"
#include "greet.h"
+
#include <X11/Xlib.h>
#include <signal.h>
#include <X11/Xatom.h>
+#include <X11/Xmu/Error.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
+#include <grp.h> /* for initgroups */
#ifdef AIXV3
# include <usersec.h>
#endif
@@ -60,41 +66,50 @@ from The Open Group.
#endif
#endif
-#ifdef CSRG_BASED
-#include <sys/param.h>
-#ifdef HAS_SETUSERCONTEXT
-#include <login_cap.h>
+static int runAndWait (char **args, char **environ);
+
+#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__) || defined(__QNXNTO__)
+#include <sys/types.h>
+#include <grp.h>
+#else
+/* should be in <grp.h> */
+extern void setgrent(void);
+extern struct group *getgrent(void);
+extern void endgrent(void);
+#endif
+
+#ifdef USESHADOW
+extern struct spwd *getspnam(GETSPNAM_ARGS);
+extern void endspent(void);
+#endif
+#if defined(CSRG_BASED)
#include <pwd.h>
+#include <unistd.h>
+#else
+extern struct passwd *getpwnam(GETPWNAM_ARGS);
+#ifdef linux
+extern void endpwent(void);
#endif
+extern char *crypt(CRYPT_ARGS);
#endif
+#ifdef USE_PAM
+pam_handle_t **thepamhp()
+{
+ static pam_handle_t *pamh = NULL;
+ return &pamh;
+}
-extern int PingServer();
-extern int SessionPingFailed();
-extern int Debug();
-extern int RegisterCloseOnFork();
-extern int SecureDisplay();
-extern int UnsecureDisplay();
-extern int ClearCloseOnFork();
-extern int SetupDisplay();
-extern int LogError();
-extern int SessionExit();
-extern int DeleteXloginResources();
-extern int source();
-extern char **defaultEnv();
-extern char **setEnv();
-extern char **parseArgs();
-extern int printEnv();
-extern char **systemEnv();
-extern int LogOutOfMem();
-extern void setgrent();
-extern struct group *getgrent();
-extern void endgrent();
-#ifdef USESHADOW
-extern struct spwd *getspnam();
-extern void endspent();
+pam_handle_t *thepamh()
+{
+ pam_handle_t **pamhp;
+
+ pamhp = thepamhp();
+ if (pamhp)
+ return *pamhp;
+ else
+ return NULL;
+}
#endif
-extern struct passwd *getpwnam();
-extern char *crypt();
static struct dlfuncs dlfuncs = {
PingServer,
@@ -111,6 +126,7 @@ static struct dlfuncs dlfuncs = {
source,
defaultEnv,
setEnv,
+ putEnv,
parseArgs,
printEnv,
systemEnv,
@@ -120,17 +136,26 @@ static struct dlfuncs dlfuncs = {
endgrent,
#ifdef USESHADOW
getspnam,
+#ifndef QNX4
endspent,
+#endif /* QNX4 doesn't use endspent */
#endif
getpwnam,
+#ifdef linux
+ endpwent,
+#endif
crypt,
- };
-
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+#ifdef USE_PAM
+ thepamhp,
#endif
+ };
-static Bool StartClient();
+static Bool StartClient(
+ struct verify_info *verify,
+ struct display *d,
+ int *pidp,
+ char *name,
+ char *passwd);
static int clientPid;
static struct greet_info greet;
@@ -140,8 +165,7 @@ static Jmp_buf abortSession;
/* ARGSUSED */
static SIGVAL
-catchTerm (n)
- int n;
+catchTerm (int n)
{
Longjmp (abortSession, 1);
}
@@ -150,8 +174,7 @@ static Jmp_buf pingTime;
/* ARGSUSED */
static SIGVAL
-catchAlrm (n)
- int n;
+catchAlrm (int n)
{
Longjmp (pingTime, 1);
}
@@ -160,8 +183,7 @@ static Jmp_buf tenaciousClient;
/* ARGSUSED */
static SIGVAL
-waitAbort (n)
- int n;
+waitAbort (int n)
{
Longjmp (tenaciousClient, 1);
}
@@ -171,16 +193,12 @@ waitAbort (n)
#endif
static void
-AbortClient (pid)
- int pid;
+AbortClient (int pid)
{
int sig = SIGTERM;
-#ifdef __STDC__
volatile int i;
-#else
- int i;
-#endif
int retId;
+
for (i = 0; i < 4; i++) {
if (killpg (pid, sig) == -1) {
switch (errno) {
@@ -205,8 +223,8 @@ AbortClient (pid)
}
}
-SessionPingFailed (d)
- struct display *d;
+void
+SessionPingFailed (struct display *d)
{
if (clientPid > 1)
{
@@ -225,18 +243,17 @@ SessionPingFailed (d)
*/
/*ARGSUSED*/
-static
-IOErrorHandler (dpy)
- Display *dpy;
+static int
+IOErrorHandler (Display *dpy)
{
LogError("fatal IO error %d (%s)\n", errno, _SysErrorMsg(errno));
exit(RESERVER_DISPLAY);
+ /*NOTREACHED*/
+ return 0;
}
static int
-ErrorHandler(dpy, event)
- Display *dpy;
- XErrorEvent *event;
+ErrorHandler(Display *dpy, XErrorEvent *event)
{
LogError("X error\n");
if (XmuPrintDefaultErrorMessage (dpy, event, stderr) == 0) return 0;
@@ -244,10 +261,10 @@ ErrorHandler(dpy, event)
/*NOTREACHED*/
}
-ManageSession (d)
-struct display *d;
+void
+ManageSession (struct display *d)
{
- int pid;
+ static int pid = 0;
Display *dpy;
greet_user_rtn greet_stat;
static GreetUserProc greet_user_proc = NULL;
@@ -258,7 +275,11 @@ struct display *d;
Debug ("ManageSession %s\n", d->name);
(void)XSetIOErrorHandler(IOErrorHandler);
(void)XSetErrorHandler(ErrorHandler);
+#ifndef HAS_SETPROCTITLE
SetTitle(d->name, (char *) 0);
+#else
+ setproctitle("%s", d->name);
+#endif
/*
* Load system default Resources
*/
@@ -348,11 +369,11 @@ struct display *d;
SessionExit (d, OBEYSESS_DISPLAY, TRUE);
}
-LoadXloginResources (d)
-struct display *d;
+void
+LoadXloginResources (struct display *d)
{
- char **args, **parseArgs();
- char **env = 0, **setEnv(), **systemEnv();
+ char **args;
+ char **env = 0;
if (d->resources[0] && access (d->resources, 4) == 0) {
env = systemEnv (d, (char *) 0, (char *) 0);
@@ -365,10 +386,10 @@ struct display *d;
}
}
-SetupDisplay (d)
-struct display *d;
+void
+SetupDisplay (struct display *d)
{
- char **env = 0, **setEnv(), **systemEnv();
+ char **env = 0;
if (d->setup && d->setup[0])
{
@@ -379,9 +400,8 @@ struct display *d;
}
/*ARGSUSED*/
-DeleteXloginResources (d, dpy)
-struct display *d;
-Display *dpy;
+void
+DeleteXloginResources (struct display *d, Display *dpy)
{
int i;
Atom prop = XInternAtom(dpy, "SCREEN_RESOURCES", True);
@@ -397,15 +417,13 @@ static Jmp_buf syncJump;
/* ARGSUSED */
static SIGVAL
-syncTimeout (n)
- int n;
+syncTimeout (int n)
{
Longjmp (syncJump, 1);
}
-SecureDisplay (d, dpy)
-struct display *d;
-Display *dpy;
+void
+SecureDisplay (struct display *d, Display *dpy)
{
Debug ("SecureDisplay %s\n", d->name);
(void) Signal (SIGALRM, syncTimeout);
@@ -438,9 +456,8 @@ Display *dpy;
Debug ("done secure %s\n", d->name);
}
-UnsecureDisplay (d, dpy)
-struct display *d;
-Display *dpy;
+void
+UnsecureDisplay (struct display *d, Display *dpy)
{
Debug ("Unsecure display %s\n", d->name);
if (d->grabServer)
@@ -450,9 +467,21 @@ Display *dpy;
}
}
-SessionExit (d, status, removeAuth)
- struct display *d;
+void
+SessionExit (struct display *d, int status, int removeAuth)
{
+#ifdef USE_PAM
+ pam_handle_t *pamh = thepamh();
+#endif
+#ifdef USE_PAM
+ if (pamh) {
+ /* shutdown PAM session */
+ pam_close_session(pamh, 0);
+ pam_end(pamh, PAM_SUCCESS);
+ pamh = NULL;
+ }
+#endif
+
/* make sure the server gets reset after the session is over */
if (d->serverPid >= 2 && d->resetSignal)
kill (d->serverPid, d->resetSignal);
@@ -493,19 +522,22 @@ SessionExit (d, status, removeAuth)
}
static Bool
-StartClient (verify, d, pidp, name, passwd)
- struct verify_info *verify;
- struct display *d;
- int *pidp;
- char *name;
- char *passwd;
+StartClient (
+ struct verify_info *verify,
+ struct display *d,
+ int *pidp,
+ char *name,
+ char *passwd)
{
- char **f, *home, *getEnv ();
+ char **f, *home;
char *failsafeArgv[2];
int pid;
#ifdef HAS_SETUSERCONTEXT
struct passwd* pwd;
#endif
+#ifdef USE_PAM
+ pam_handle_t *pamh = thepamh();
+#endif
if (verify->argv) {
Debug ("StartSession %s: ", verify->argv[0]);
@@ -518,12 +550,31 @@ StartClient (verify, d, pidp, name, passwd)
Debug ("%s ", *f);
Debug ("\n");
}
+#ifdef USE_PAM
+ if (pamh) pam_open_session(pamh, 0);
+#endif
switch (pid = fork ()) {
case 0:
CleanUpChild ();
+#ifdef XDMCP
+ /* The chooser socket is not closed by CleanUpChild() */
+ DestroyWellKnownSockets();
+#endif
/* Do system-dependent login setup here */
+#ifdef USE_PAM
+ /* pass in environment variables set by libpam and modules it called */
+ if (pamh) {
+ long i;
+ char **pam_env = pam_getenvlist(pamh);
+ for(i = 0; pam_env && pam_env[i]; i++) {
+ verify->userEnviron = putEnv(pam_env[i], verify->userEnviron);
+ }
+ }
+#endif
+
+
#ifndef AIXV3
#ifndef HAS_SETUSERCONTEXT
if (setgid(verify->gid) < 0)
@@ -532,18 +583,25 @@ StartClient (verify, d, pidp, name, passwd)
verify->gid, name, errno);
return (0);
}
-#if (BSD >= 199103)
+#if defined(BSD) && (BSD >= 199103)
if (setlogin(name) < 0)
{
LogError("setlogin for \"%s\" failed, errno=%d", name, errno);
return(0);
}
#endif
+#ifndef QNX4
if (initgroups(name, verify->gid) < 0)
{
LogError("initgroups for \"%s\" failed, errno=%d\n", name, errno);
return (0);
}
+#endif /* QNX4 doesn't support multi-groups, no initgroups() */
+#ifdef USE_PAM
+ if (thepamh()) {
+ pam_setcred(thepamh(), PAM_ESTABLISH_CRED);
+ }
+#endif
if (setuid(verify->uid) < 0)
{
LogError("setuid %d (user \"%s\") failed, errno=%d\n",
@@ -707,12 +765,9 @@ StartClient (verify, d, pidp, name, passwd)
}
int
-source (environ, file)
-char **environ;
-char *file;
+source (char **environ, char *file)
{
char **args, *args_safe[2];
- extern char **parseArgs ();
int ret;
if (file && file[0]) {
@@ -731,10 +786,8 @@ char *file;
return 0;
}
-int
-runAndWait (args, environ)
- char **args;
- char **environ;
+static int
+runAndWait (char **args, char **environ)
{
int pid;
waitType result;
@@ -759,13 +812,11 @@ runAndWait (args, environ)
}
void
-execute (argv, environ)
- char **argv;
- char **environ;
+execute (char **argv, char **environ)
{
/* give /dev/null as stdin */
(void) close (0);
- open ("/dev/null", 0);
+ open ("/dev/null", O_RDONLY);
/* make stdout follow stderr to the log file */
dup2 (2,1);
execve (argv[0], argv, environ);
@@ -837,10 +888,8 @@ execute (argv, environ)
}
}
-extern char **setEnv ();
-
char **
-defaultEnv ()
+defaultEnv (void)
{
char **env, **exp, *value;
@@ -855,9 +904,7 @@ defaultEnv ()
}
char **
-systemEnv (d, user, home)
-struct display *d;
-char *user, *home;
+systemEnv (struct display *d, char *user, char *home)
{
char **env;
@@ -876,3 +923,10 @@ char *user, *home;
env = setEnv (env, "XAUTHORITY", d->authFile);
return env;
}
+
+#if (defined(Lynx) && !defined(HAS_CRYPT)) || defined(SCO) && !defined(SCO_USA) && !defined(_SCO_DS)
+char *crypt(char *s1, char *s2)
+{
+ return(s2);
+}
+#endif
diff --git a/socket.c b/socket.c
index 47b0c79..83dddf6 100644
--- a/socket.c
+++ b/socket.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/socket.c,v 3.10 2001/12/14 20:01:24 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,19 +36,22 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
#ifdef XDMCP
#ifndef STREAMSCONN
#include <errno.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/un.h>
-#include <netdb.h>
+#include "dm_socket.h"
-#ifdef X_NOT_STDC_ENV
-extern int errno;
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
+#include <sys/un.h>
+#else
+#include <un.h>
#endif
+#endif
+#include <netdb.h>
extern int xdmcpFd;
@@ -56,10 +60,11 @@ extern int chooserFd;
extern FD_TYPE WellKnownSocketsMask;
extern int WellKnownSocketsMax;
-CreateWellKnownSockets ()
+void
+CreateWellKnownSockets (void)
{
struct sockaddr_in sock_addr;
- char *name, *localHostname();
+ char *name;
if (request_port == 0)
return;
@@ -103,19 +108,21 @@ CreateWellKnownSockets ()
FD_SET (chooserFd, &WellKnownSocketsMask);
}
-GetChooserAddr (addr, lenp)
- char *addr;
- int *lenp;
+int
+GetChooserAddr (
+ char *addr,
+ int *lenp)
{
struct sockaddr_in in_addr;
int len;
len = sizeof in_addr;
- if (getsockname (chooserFd, (struct sockaddr *)&in_addr, &len) < 0)
+ if (getsockname (chooserFd, (struct sockaddr *)&in_addr, (void *)&len) < 0)
return -1;
Debug ("Chooser socket port: %d\n", ntohs(in_addr.sin_port));
memmove( addr, (char *) &in_addr, len);
*lenp = len;
+
return 0;
}
diff --git a/streams.c b/streams.c
index 585fe90..de6b41a 100644
--- a/streams.c
+++ b/streams.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/streams.c,v 3.6 2001/12/14 20:01:24 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -35,6 +36,7 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_error.h"
#ifdef XDMCP
#ifdef STREAMSCONN
@@ -50,6 +52,7 @@ extern int chooserFd;
extern FD_TYPE WellKnownSocketsMask;
extern int WellKnownSocketsMax;
+void
CreateWellKnownSockets ()
{
struct t_bind bind_addr;
diff --git a/util.c b/util.c
index 372f372..401d4ae 100644
--- a/util.c
+++ b/util.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/util.c,v 3.20 2002/05/31 18:46:10 dawes Exp $ */
/*
* xdm - display manager daemon
@@ -37,6 +38,10 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_error.h"
+
+#include <X11/Xmu/SysUtil.h> /* for XmuGetHostname */
+
#ifdef X_POSIX_C_SOURCE
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
#include <signal.h>
@@ -50,21 +55,19 @@ from The Open Group.
#undef _POSIX_SOURCE
#endif
#endif
-#if defined(__osf__) || defined(linux)
+#if defined(__osf__) || defined(linux) || defined(__QNXNTO__) || defined(__GNU__)
#define setpgrp setpgid
#endif
-printEnv (e)
-char **e;
+void
+printEnv (char **e)
{
while (*e)
Debug ("%s\n", *e++);
}
static char *
-makeEnv (name, value)
-char *name;
-char *value;
+makeEnv (char *name, char *value)
{
char *result;
@@ -78,9 +81,7 @@ char *value;
}
char *
-getEnv (e, name)
- char **e;
- char *name;
+getEnv (char **e, char *name)
{
int l = strlen (name);
@@ -96,10 +97,7 @@ getEnv (e, name)
}
char **
-setEnv (e, name, value)
- char **e;
- char *name;
- char *value;
+setEnv (char **e, char *name, char *value)
{
char **new, **old;
char *newe;
@@ -138,8 +136,33 @@ setEnv (e, name, value)
return new;
}
-freeEnv (env)
- char **env;
+char **
+putEnv(const char *string, char **env)
+{
+ char *v, *b, *n;
+ int nl;
+
+ if ((b = strchr(string, '=')) == NULL)
+ return NULL;
+ v = b + 1;
+
+ nl = b - string;
+ if ((n = malloc(nl + 1)) == NULL)
+ {
+ LogOutOfMem ("putAllEnv");
+ return NULL;
+ }
+
+ strncpy(n, string,nl + 1);
+ n[nl] = 0;
+
+ env = setEnv(env,n,v);
+ free(n);
+ return env;
+}
+
+void
+freeEnv (char **env)
{
char **e;
@@ -154,12 +177,11 @@ freeEnv (env)
# define isblank(c) ((c) == ' ' || c == '\t')
char **
-parseArgs (argv, string)
-char **argv;
-char *string;
+parseArgs (char **argv, char *string)
{
char *word;
char *save;
+ char **newargv;
int i;
i = 0;
@@ -176,16 +198,17 @@ char *string;
for (;;) {
if (!*string || isblank (*string)) {
if (word != string) {
- argv = (char **) realloc ((char *) argv,
+ newargv = (char **) realloc ((char *) argv,
(unsigned) ((i + 2) * sizeof (char *)));
save = malloc ((unsigned) (string - word + 1));
- if (!argv || !save) {
+ if (!newargv || !save) {
LogOutOfMem ("parseArgs");
- if (argv)
- free ((char *) argv);
+ free ((char *) argv);
if (save)
free (save);
return 0;
+ } else {
+ argv = newargv;
}
argv[i] = strncpy (save, word, string-word);
argv[i][string-word] = '\0';
@@ -201,8 +224,8 @@ char *string;
return argv;
}
-freeArgs (argv)
- char **argv;
+void
+freeArgs (char **argv)
{
char **a;
@@ -214,14 +237,21 @@ freeArgs (argv)
free ((char *) argv);
}
-CleanUpChild ()
+void
+CleanUpChild (void)
{
-#if defined(SYSV) || defined(SVR4)
+#ifdef CSRG_BASED
+ setsid();
+#else
+#if defined(SYSV) || defined(SVR4) || defined(__CYGWIN__)
+#if !(defined(SVR4) && defined(i386)) || defined(SCO325)
setpgrp ();
+#endif
#else
setpgrp (0, getpid ());
sigsetmask (0);
#endif
+#endif
#ifdef SIGCHLD
(void) Signal (SIGCHLD, SIG_DFL);
#endif
@@ -236,7 +266,7 @@ static char localHostbuf[256];
static int gotLocalHostname;
char *
-localHostname ()
+localHostname (void)
{
if (!gotLocalHostname)
{
@@ -246,11 +276,9 @@ localHostname ()
return localHostbuf;
}
-SIGVAL (*Signal (sig, handler))()
- int sig;
- SIGVAL (*handler)();
+SIGVAL (*Signal (int sig, SIGFUNC handler))(int)
{
-#ifndef X_NOT_POSIX
+#if !defined(X_NOT_POSIX) && !defined(__UNIXOS2__)
struct sigaction sigact, osigact;
sigact.sa_handler = handler;
sigemptyset(&sigact.sa_mask);
diff --git a/xdm.man.cpp b/xdm.man.cpp
index 45f8a90..07fd53f 100644
--- a/xdm.man.cpp
+++ b/xdm.man.cpp
@@ -22,7 +22,10 @@
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
-.TH XDM 1 "Release 6.4" "X Version 11"
+.\"
+.\" $XFree86: xc/programs/xdm/xdm.man,v 3.22 2002/10/12 16:06:47 herrb Exp $
+.\"
+.TH XDM 1 __xorgversion__
.SH NAME
xdm \- X Display Manager with support for XDMCP, host chooser
.SH SYNOPSIS
@@ -82,6 +85,13 @@ offer a menu of possible hosts that offer XDMCP display management.
This feature is useful with X terminals that do not offer a host
menu themselves.
.PP
+.I Xdm
+can be configured to ignore BroadcastQuery messages from selected hosts.
+This is useful when you don't want the host to appear in menus produced
+by
+.I chooser
+or X terminals themselves.
+.PP
Because
.I xdm
provides the first interface that users will see, it is designed to be
@@ -134,7 +144,7 @@ When the \fIXsession\fP script exits, the session is over.
At the end of the session, the \fIXreset\fP script is run to clean up,
the X server is reset, and the cycle starts over.
.PP
-The file \fI/usr/X11R6/lib/X11/xdm/xdm-errors\fP will contain error
+The file \fI__projectroot__/lib/X11/xdm/xdm-errors\fP will contain error
messages from
.I xdm
and anything output to stderr by \fIXsetup, Xstartup, Xsession\fP
@@ -153,7 +163,7 @@ as resources.
Names the configuration file, which specifies resources to control
the behavior of
.I xdm.
-.I <XRoot>/lib/X11/xdm/xdm-config
+.I __projectroot__/lib/X11/xdm/xdm-config
is the default.
See the section \fBConfiguration File\fP.
.IP "\fB\-nodaemon\fP"
@@ -199,7 +209,8 @@ sets the port-number which
.I xdm
will monitor for XDMCP requests. As XDMCP
uses the registered well-known UDP port 177, this resource should
-not be changed except for debugging.
+not be changed except for debugging. If set to 0 xdm will not listen
+for XDMCP or Chooser requests.
.IP "\fB\-session\fP \fIsession_program\fP"
Specifies the value for the \fBDisplayManager*session\fP resource. This
indicates the program to run as the session after the user has logged in.
@@ -294,7 +305,7 @@ uses the \fIlockf\fP library call, while on BSD it uses \fIflock.\fP
This names a directory under which
.I xdm
stores authorization files while initializing the session. The
-default value is \fI<XRoot>/lib/X11/xdm.\fP
+default value is \fI__projectroot__/lib/X11/xdm.\fP
Can be overridden for specific displays by
DisplayManager.\fIDISPLAY\fP.authFile.
.IP \fBDisplayManager.autoRescan\fP
@@ -340,7 +351,8 @@ This should be a file that changes frequently.
The default is \fI/dev/mem\fP.
.IP \fBDisplayManager.greeterLib\fP
On systems that support a dynamically-loadable greeter library, the
-name of the library. Default is \fI<XRoot>/lib/X11/xdm/libXdmGreet.so\fP.
+name of the library. The default is
+\fI__projectroot__/lib/X11/xdm/libXdmGreet.so\fP.
.IP \fBDisplayManager.choiceTimeout\fP
Number of seconds to wait for display to respond after user has
selected a host from the chooser. If the display sends an XDMCP
@@ -348,6 +360,17 @@ IndirectQuery within this time, the request is forwarded to the chosen
host. Otherwise, it is assumed to be from a new session and the
chooser is offered again.
Default is 15.
+.IP \fBDisplayManager.sourceAddress\fP
+Use the numeric IP address of the incoming connection on multihomed hosts
+instead of the host name. This is to avoid trying to connect on the wrong
+interface which might be down at this time.
+.IP \fBDisplayManager.willing\fP
+This specifies a program which is run (as) root when an an XDMCP
+BroadcastQuery is received and this host is configured to offer XDMCP
+display management. The output of this program may be displayed on a chooser
+window. If no program is specified, the string \fIWilling to manage\fP is
+sent.
+.PP
.\"
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.resources\fP"
This resource specifies the name of the file to be loaded by \fIxrdb\fP
@@ -361,17 +384,17 @@ section
which describes the various
resources that are appropriate to place in this file.
There is no default value for this resource, but
-\fI<XRoot>/lib/X11/xdm/Xresources\fP
+\fI__projectroot__/lib/X11/xdm/Xresources\fP
is the conventional name.
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.chooser\fP"
Specifies the program run to offer a host menu for Indirect queries
redirected to the special host name CHOOSER.
-\fI<XRoot>/lib/X11/xdm/chooser\fP is the default.
+\fI__projectroot__/lib/X11/xdm/chooser\fP is the default.
See the sections \fBXDMCP Access Control\fP and \fBChooser\fP.
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.xrdb\fP"
Specifies the program used to load the resources. By default,
.I xdm
-uses \fI<XRoot>/bin/xrdb\fP.
+uses \fI__projectroot__/bin/xrdb\fP.
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.cpp\fP"
This specifies the name of the C preprocessor which is used by \fIxrdb\fP.
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.setup\fP"
@@ -389,7 +412,7 @@ file used here is \fIXstartup\fP.
See the section \fBStartup Program.\fP
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.session\fP"
This specifies the session to be executed (not running as root).
-By default, \fI<XRoot>/bin/xterm\fP is
+By default, \fI__projectroot__/bin/xterm\fP is
run. The conventional name is \fIXsession\fP.
See the section
.B "Session Program."
@@ -452,7 +475,7 @@ sets the PATH environment variable for the session to this value. It should
be a colon separated list of directories; see
.IR sh (1)
for a full description.
-``:/bin:/usr/bin:/usr/X11R6/bin:/usr/ucb''
+``:/bin:/usr/bin:__projectroot__/bin:/usr/ucb''
is a common setting.
The default value can be specified at build time in the X system
configuration file with DefaultUserPath.
@@ -461,7 +484,7 @@ configuration file with DefaultUserPath.
sets the PATH environment variable for the startup and reset scripts to the
value of this resource. The default for this resource is specified
at build time by the DefaultSystemPath entry in the system configuration file;
-``/etc:/bin:/usr/bin:/usr/X11R6/bin:/usr/ucb'' is a common choice.
+``/etc:/bin:/usr/bin:__projectroot__/bin:/usr/ucb'' is a common choice.
Note the absence of ``.'' from this entry. This is a good practice to
follow for root; it avoids many common Trojan Horse system penetration
schemes.
@@ -475,7 +498,7 @@ If the default session fails to execute,
will fall back to this program. This program is executed with no
arguments, but executes using the same environment variables as
the session would have had (see the section \fBSession Program\fP).
-By default, \fI<XRoot>/bin/xterm\fP is used.
+By default, \fI__projectroot__/bin/xterm\fP is used.
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.grabServer\fP"
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.grabTimeout\fP"
To improve security,
@@ -554,10 +577,8 @@ variable XAUTHORITY at the created file. It uses \fI/tmp\fP by default.
First, the
.I xdm
configuration file should be set up.
-Make a directory (usually \fI<XRoot>/lib/X11/xdm\fP, where <XRoot>
-refers to the root of the X11 install tree) to contain all of the relevant
-files. In the examples that follow, we use /usr/X11R6 as the value of
-<XRoot>.
+Make a directory (usually \fI__projectroot__/lib/X11/xdm\fP) to contain all
+of the relevant files.
.LP
Here is a reasonable configuration file, which could be
named \fIxdm-config\fP:
@@ -565,12 +586,12 @@ named \fIxdm-config\fP:
.ta .5i 4i
- DisplayManager.servers: /usr/X11R6/lib/X11/xdm/Xservers
- DisplayManager.errorLogFile: /usr/X11R6/lib/X11/xdm/xdm-errors
- DisplayManager*resources: /usr/X11R6/lib/X11/xdm/Xresources
- DisplayManager*startup: /usr/X11R6/lib/X11/xdm/Xstartup
- DisplayManager*session: /usr/X11R6/lib/X11/xdm/Xsession
- DisplayManager.pidFile: /usr/X11R6/lib/X11/xdm/xdm-pid
+ DisplayManager.servers: __projectroot__/lib/X11/xdm/Xservers
+ DisplayManager.errorLogFile: __projectroot__/lib/X11/xdm/xdm-errors
+ DisplayManager*resources: __projectroot__/lib/X11/xdm/Xresources
+ DisplayManager*startup: __projectroot__/lib/X11/xdm/Xstartup
+ DisplayManager*session: __projectroot__/lib/X11/xdm/Xsession
+ DisplayManager.pidFile: __projectroot__/lib/X11/xdm/xdm-pid
DisplayManager._0.authorize: true
DisplayManager*authorize: false
@@ -606,6 +627,11 @@ Preceding either a host name or a pattern with a `!' character
causes hosts which
match that entry to be excluded.
.PP
+To only respond to Direct queries for a host or pattern,
+it can be followed by the optional ``NOBROADCAST'' keyword.
+This can be used to prevent an xdm server from appearing on
+menus based on Broadcast queries.
+.PP
An Indirect entry also contains a host name or pattern,
but follows it with a list of
host names or macros to which indirect queries should be sent.
@@ -634,21 +660,24 @@ Here is an example Xaccess file:
.LP
.ta 2i 4i
.nf
-#
-# Xaccess \- XDMCP access control file
-#
+XCOMM
+XCOMM Xaccess \- XDMCP access control file
+XCOMM
-#
-# Direct/Broadcast query entries
-#
+XCOMM
+XCOMM Direct/Broadcast query entries
+XCOMM
!xtra.lcs.mit.edu # disallow direct/broadcast service for xtra
bambi.ogi.edu # allow access from this particular display
*.lcs.mit.edu # allow access from any display in LCS
-#
-# Indirect query entries
-#
+*.deshaw.com NOBROADCAST # allow only direct access
+*.gw.com # allow direct and broadcast
+
+XCOMM
+XCOMM Indirect query entries
+XCOMM
%HOSTS expo.lcs.mit.edu xenon.lcs.mit.edu \\
excess.lcs.mit.edu kanga.lcs.mit.edu
@@ -715,7 +744,7 @@ line to start the server. A typical entry for local display number 0 would
be:
.nf
- :0 Digital-QV local /usr/X11R6/bin/X :0
+ :0 Digital-QV local __projectroot__/bin/X :0
.fi
The display types are:
@@ -730,8 +759,8 @@ foreign remote display: \fIxdm\fP opens an X connection to a running server
The display name must be something that can be passed in the \fB\-display\fP
option to an X program. This string is used to generate the display-specific
resource names, so be careful to match the
-names (e.g., use ``:0 Sun-CG3 local /usr/X11R6/bin/X :0'' instead of
-``localhost:0 Sun-CG3 local /usr/X11R6/bin/X :0''
+names (e.g., use ``:0 Sun-CG3 local __projectroot__/bin/X :0'' instead of
+``localhost:0 Sun-CG3 local __projectroot__/bin/X :0''
if your other resources are specified as
``DisplayManager._0.session''). The display class portion is also used in the
display-specific resources, as the class of the resource. This is
@@ -767,17 +796,17 @@ parameters for that widget:
<Key>Return: set-session-argument() finish-field()
xlogin*borderWidth: 3
xlogin*greeting: CLIENTHOST
- #ifdef COLOR
+\& #ifdef COLOR
xlogin*greetColor: CadetBlue
xlogin*failColor: red
- #endif
+\& #endif
.fi
.PP
Please note the translations entry; it specifies
a few new translations for the widget which allow users to escape from the
default session (and avoid troubles that may occur in it). Note that if
-#override is not specified, the default translations are removed and replaced
+\&#override is not specified, the default translations are removed and replaced
by the new value, not a very useful result as some of the default translations
are quite useful (such as ``<Key>: insert-char ()'' which responds to normal
typing).
@@ -815,9 +844,9 @@ can be put into the file named by
Here is a sample \fIXsetup\fP script:
.nf
- #!/bin/sh
- # Xsetup_0 \- setup script for one workstation
- xcmsdb < /usr/X11R6/lib/monitors/alex.0
+\& #!/bin/sh
+\& # Xsetup_0 \- setup script for one workstation
+ xcmsdb < __projectroot__/lib/monitors/alex.0
xconsole\0\-geometry\0480x130\-0\-0\0\-notify\0\-verbose\0\-exitOnFail &
.fi
@@ -893,6 +922,15 @@ translation table is:
<Key>: insert-char() \\
.fi
+.IP "\fBxlogin.Login.allowRootLogin\fP"
+If set to ``false'', don't allow root (and any other user with uid = 0) to
+log in directly.
+The default is ``true''.
+.IP "\fBxlogin.Login.allowNullPasswd\fP"
+If set to ``true'', allow an otherwise failing password match to succeed
+if the account does not require a password at all.
+The default is ``false'', so only users that have passwords assigned can
+log in.
.PP
The actions which are supported by the widget are:
.IP "delete-previous-character"
@@ -944,6 +982,11 @@ the .Xauthority file cannot be created by
Be very careful using this;
it might be better to disconnect the machine from the network
before doing this.
+.PP
+On some systems (OpenBSD) the user's shell must be listed in
+.I /etc/shells
+to allow login through xdm. The normal password and account expiration
+dates are enforced too.
.SH "STARTUP PROGRAM"
.PP
The \fIXstartup\fP program is run as
@@ -990,18 +1033,18 @@ Here is a sample \fIXstartup\fP script:
.nf
.ta .5i 1i
- #!/bin/sh
- #
- # Xstartup
- #
- # This program is run as root after the user is verified
- #
+\& #!/bin/sh
+\& #
+\& # Xstartup
+\& #
+\& # This program is run as root after the user is verified
+\& #
if [ \-f /etc/nologin ]; then
xmessage\0\-file /etc/nologin\0\-timeout 30\0\-center
exit 1
fi
- sessreg\0\-a\0\-l $DISPLAY\0\-x /usr/X11R6/lib/xdm/Xservers $LOGNAME
- /usr/X11R6/lib/xdm/GiveConsole
+ sessreg\0\-a\0\-l $DISPLAY\0\-x __projectroot__/lib/xdm/Xservers $LOGNAME
+ __projectroot__/lib/xdm/GiveConsole
exit 0
.fi
.SH "SESSION PROGRAM"
@@ -1051,12 +1094,12 @@ be executable so we don't have to guess what shell it wants to use.
.nf
.ta .5i 1i 1.5i
- #!/bin/sh
- #
- # Xsession
- #
- # This is the program that is run as the client
- # for the display manager.
+\& #!/bin/sh
+\& #
+\& # Xsession
+\& #
+\& # This is the program that is run as the client
+\& # for the display manager.
case $# in
1)
@@ -1086,8 +1129,8 @@ be executable so we don't have to guess what shell it wants to use.
The user's \fI.xsession\fP file might look something like this
example. Don't forget that the file must have execute permission.
.nf
- #! /bin/csh
- # no \-f in the previous line so .cshrc gets run to set $PATH
+\& #! /bin/csh
+\& # no \-f in the previous line so .cshrc gets run to set $PATH
twm &
xrdb \-merge "$HOME/.Xresources"
emacs \-geometry +0+50 &
@@ -1108,14 +1151,14 @@ passed to \fIXreset\fP.
A sample \fIXreset\fP script:
.nf
.ta .5i 1i
- #!/bin/sh
- #
- # Xreset
- #
- # This program is run as root after the session ends
- #
- sessreg\0\-d\0\-l $DISPLAY\0\-x /usr/X11R6/lib/xdm/Xservers $LOGNAME
- /usr/X11R6/lib/xdm/TakeConsole
+\& #!/bin/sh
+\& #
+\& # Xreset
+\& #
+\& # This program is run as root after the session ends
+\& #
+ sessreg\0\-d\0\-l $DISPLAY\0\-x __projectroot__/lib/xdm/Xservers $LOGNAME
+ __projectroot__/lib/xdm/TakeConsole
exit 0
.fi
.SH "CONTROLLING THE SERVER"
@@ -1187,7 +1230,7 @@ line:
.nf
.ta .5i
- xdm \-server ":0 SUN-3/60CG4 local /usr/X11R6/bin/X :0"
+ xdm \-server ":0 SUN-3/60CG4 local __projectroot__/bin/X :0"
.fi
.PP
@@ -1218,36 +1261,34 @@ interested in
.I xinit.
.SH FILES
.TP 20
-.I <XRoot>/lib/X11/xdm/xdm-config
+.I __projectroot__/lib/X11/xdm/xdm-config
the default configuration file
.TP 20
.I $HOME/.Xauthority
user authorization file where \fIxdm\fP stores keys for clients to read
.TP 20
-.I <XRoot>/lib/X11/xdm/chooser
+.I __projectroot__/lib/X11/xdm/chooser
the default chooser
.TP 20
-.I <XRoot>/bin/xrdb
+.I __projectroot__/bin/xrdb
the default resource database loader
.TP 20
-.I <XRoot>/bin/X
+.I __projectroot__/bin/X
the default server
.TP 20
-.I <XRoot>/bin/xterm
+.I __projectroot__/bin/xterm
the default session program and failsafe client
.TP 20
-.I <XRoot>/lib/X11/xdm/A<display>\-<suffix>
+.I __projectroot__/lib/X11/xdm/A<display>\-<suffix>
the default place for authorization files
.TP 20
.I /tmp/K5C<display>
Kerberos credentials cache
-.LP
-Note: <XRoot> refers to the root of the X11 install tree.
.SH "SEE ALSO"
-.IR X (1),
+.IR X (__miscmansuffix__),
.IR xinit (1),
.IR xauth (1),
-.IR Xsecurity (1),
+.IR Xsecurity (__miscmansuffix__),
.IR sessreg (1),
.IR Xserver (1),
.\" .IR chooser (1), \" except that there isn't a manual for it yet
diff --git a/xdmauth.c b/xdmauth.c
index cd4d221..7be4d3d 100644
--- a/xdmauth.c
+++ b/xdmauth.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-
+/* $XFree86: xc/programs/xdm/xdmauth.c,v 1.5 2001/12/14 20:01:25 dawes Exp $ */
/*
* xdm - display manager daemon
* Author: Keith Packard, MIT X Consortium
@@ -37,12 +37,15 @@ from The Open Group.
*/
#include "dm.h"
+#include "dm_auth.h"
+#include "dm_error.h"
#ifdef HASXDMAUTH
static char auth_name[256];
static int auth_name_len;
+void
XdmPrintDataHex (s, a, l)
char *s;
char *a;
@@ -57,6 +60,7 @@ XdmPrintDataHex (s, a, l)
}
#ifdef notdef /* not used */
+void
XdmPrintKey (s, k)
char *s;
XdmAuthKeyRec *k;
@@ -66,6 +70,7 @@ XdmPrintKey (s, k)
#endif
#ifdef XDMCP
+void
XdmPrintArray8Hex (s, a)
char *s;
ARRAY8Ptr a;
@@ -74,6 +79,7 @@ XdmPrintArray8Hex (s, a)
}
#endif
+void
XdmInitAuth (name_len, name)
unsigned short name_len;
char *name;
@@ -194,7 +200,7 @@ XdmGetXdmcpAuth (pdpy,authorizationNameLen, authorizationName)
XdmPrintDataHex ("Accept packet auth", xdmcpauth->data, xdmcpauth->data_length);
XdmPrintDataHex ("Auth file auth", fileauth->data, fileauth->data_length);
/* encrypt the session key for its trip back to the server */
- XdmcpWrap (xdmcpauth->data, &pdpy->key, xdmcpauth->data, 8);
+ XdmcpWrap (xdmcpauth->data, (unsigned char *)&pdpy->key, xdmcpauth->data, 8);
pdpy->fileAuthorization = fileauth;
pdpy->xdmcpAuthorization = xdmcpauth;
}
@@ -203,7 +209,7 @@ XdmGetXdmcpAuth (pdpy,authorizationNameLen, authorizationName)
'a' <= c && c <= 'f' ? c - 'a' + 10 : \
'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
-static
+static int
HexToBinary (key)
char *key;
{
@@ -234,6 +240,7 @@ HexToBinary (key)
* routine accepts either plain ascii strings for keys, or hex-encoded numbers
*/
+int
XdmGetKey (pdpy, displayID)
struct protoDisplay *pdpy;
ARRAY8Ptr displayID;
@@ -275,6 +282,7 @@ XdmGetKey (pdpy, displayID)
}
/*ARGSUSED*/
+int
XdmCheckAuthentication (pdpy, displayID, authenticationName, authenticationData)
struct protoDisplay *pdpy;
ARRAY8Ptr displayID, authenticationName, authenticationData;
@@ -285,14 +293,14 @@ XdmCheckAuthentication (pdpy, displayID, authenticationName, authenticationData)
return FALSE;
if (authenticationData->length != 8)
return FALSE;
- XdmcpUnwrap (authenticationData->data, &pdpy->key,
+ XdmcpUnwrap (authenticationData->data, (unsigned char *)&pdpy->key,
authenticationData->data, 8);
XdmPrintArray8Hex ("Request packet auth", authenticationData);
if (!XdmcpCopyARRAY8(authenticationData, &pdpy->authenticationData))
return FALSE;
incoming = (XdmAuthKeyPtr) authenticationData->data;
XdmcpIncrementKey (incoming);
- XdmcpWrap (authenticationData->data, &pdpy->key,
+ XdmcpWrap (authenticationData->data, (unsigned char *)&pdpy->key,
authenticationData->data, 8);
return TRUE;
}
diff --git a/xdmcp.c b/xdmcp.c
index 6e16575..726902f 100644
--- a/xdmcp.c
+++ b/xdmcp.c
@@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/xdm/xdmcp.c,v 3.21 2002/12/10 22:37:17 tsi Exp $ */
/*
* xdm - display manager daemon
@@ -35,6 +36,8 @@ from The Open Group.
*/
# include "dm.h"
+# include "dm_auth.h"
+# include "dm_error.h"
#ifdef XDMCP
@@ -43,29 +46,51 @@ from The Open Group.
# include <sys/types.h>
# include <ctype.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+# include "dm_socket.h"
+
+#ifndef X_NO_SYS_UN
+#ifndef Lynx
#include <sys/un.h>
+#else
+#include <un.h>
+#endif
+#endif
+#if defined(__SVR4) && defined(__sun)
+ /*
+ * make sure we get the resolver's version of gethostbyname
+ * otherwise we may not get all the addresses!
+ */
+#define gethostbyname res_gethostbyname
+#endif
#include <netdb.h>
-#ifdef X_NOT_STDC_ENV
-#define Time_t long
-extern Time_t time ();
-#else
#include <time.h>
#define Time_t time_t
-#endif
#define getString(name,len) ((name = malloc (len + 1)) ? 1 : 0)
/*
- * interface to policy routines
+ * misc externs
+ */
+extern int Rescan, ChildReady;
+extern int sourceAddress;
+
+/*
+ * Forward reference
*/
+static void broadcast_respond (struct sockaddr *from, int fromlen, int length);
+static void forward_respond (struct sockaddr *from, int fromlen, int length);
+static void manage (struct sockaddr *from, int fromlen, int length);
+static void query_respond (struct sockaddr *from, int fromlen, int length);
+static void request_respond (struct sockaddr *from, int fromlen, int length);
+static void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData);
+static void send_alive (struct sockaddr *from, int fromlen, int length);
+static void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status);
+static void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason);
+static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID);
+static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status);
+static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status);
-extern ARRAY8Ptr ChooseAuthentication ();
-extern int Willing ();
-extern ARRAY8Ptr Accept ();
-extern int SelectConnectionTypeIndex ();
int xdmcpFd = -1;
int chooserFd = -1;
@@ -75,7 +100,8 @@ int WellKnownSocketsMax;
#define pS(s) ((s) ? ((char *) (s)) : "empty string")
-DestroyWellKnownSockets ()
+void
+DestroyWellKnownSockets (void)
{
if (xdmcpFd != -1)
{
@@ -89,7 +115,8 @@ DestroyWellKnownSockets ()
}
}
-AnyWellKnownSockets ()
+int
+AnyWellKnownSockets (void)
{
return xdmcpFd != -1 || chooserFd != -1;
}
@@ -98,10 +125,10 @@ static XdmcpBuffer buffer;
/*ARGSUSED*/
static void
-sendForward (connectionType, address, closure)
- CARD16 connectionType;
- ARRAY8Ptr address;
- char *closure;
+sendForward (
+ CARD16 connectionType,
+ ARRAY8Ptr address,
+ char *closure)
{
#ifdef AF_INET
struct sockaddr_in in_addr;
@@ -134,27 +161,26 @@ sendForward (connectionType, address, closure)
default:
return;
}
- XdmcpFlush (xdmcpFd, &buffer, addr, addrlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) addr, addrlen);
+ return;
}
-extern char *NetaddrAddress();
-extern char *NetaddrPort();
-
static void
-ClientAddress (from, addr, port, type)
- struct sockaddr *from;
- ARRAY8Ptr addr, port; /* return */
- CARD16 *type; /* return */
+ClientAddress (
+ struct sockaddr *from,
+ ARRAY8Ptr addr, /* return */
+ ARRAY8Ptr port, /* return */
+ CARD16 *type) /* return */
{
int length, family;
char *data;
- data = NetaddrPort(from, &length);
+ data = NetaddrPort((XdmcpNetaddr) from, &length);
XdmcpAllocARRAY8 (port, length);
memmove( port->data, data, length);
port->length = length;
- family = ConvertAddr(from, &length, &data);
+ family = ConvertAddr((XdmcpNetaddr) from, &length, &data);
XdmcpAllocARRAY8 (addr, length);
memmove( addr->data, data, length);
addr->length = length;
@@ -163,11 +189,11 @@ ClientAddress (from, addr, port, type)
}
static void
-all_query_respond (from, fromlen, authenticationNames, type)
- struct sockaddr *from;
- int fromlen;
- ARRAYofARRAY8Ptr authenticationNames;
- xdmOpCode type;
+all_query_respond (
+ struct sockaddr *from,
+ int fromlen,
+ ARRAYofARRAY8Ptr authenticationNames,
+ xdmOpCode type)
{
ARRAY8Ptr authenticationName;
ARRAY8 status;
@@ -176,10 +202,10 @@ all_query_respond (from, fromlen, authenticationNames, type)
int family;
int length;
- family = ConvertAddr(from, &length, &(addr.data));
+ family = ConvertAddr((XdmcpNetaddr) from, &length, (char **)&(addr.data));
addr.length = length; /* convert int to short */
Debug ("all_query_respond: conntype=%d, addr=%lx, len=%d\n",
- family, *(addr.data), addr.length);
+ family, (unsigned long) *(addr.data), addr.length);
if (family < 0)
return;
connectionType = family;
@@ -199,10 +225,10 @@ all_query_respond (from, fromlen, authenticationNames, type)
}
static void
-indirect_respond (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+indirect_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
ARRAYofARRAY8 queryAuthenticationNames;
ARRAY8 clientAddress;
@@ -254,15 +280,15 @@ indirect_respond (from, fromlen, length)
}
static void
-ProcessRequestSocket ()
+ProcessRequestSocket (void)
{
XdmcpHeader header;
- struct sockaddr_in addr;
+ struct sockaddr addr;
int addrlen = sizeof addr;
Debug ("ProcessRequestSocket\n");
bzero ((char *) &addr, sizeof (addr));
- if (!XdmcpFill (xdmcpFd, &buffer, &addr, &addrlen)) {
+ if (!XdmcpFill (xdmcpFd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) {
Debug ("XdmcpFill failed\n");
return;
}
@@ -302,11 +328,11 @@ ProcessRequestSocket ()
}
}
-WaitForSomething ()
+void
+WaitForSomething (void)
{
FD_TYPE reads;
int nready;
- extern int Rescan, ChildReady;
Debug ("WaitForSomething\n");
if (AnyWellKnownSockets () && !ChildReady) {
@@ -319,6 +345,11 @@ WaitForSomething ()
if (xdmcpFd >= 0 && FD_ISSET (xdmcpFd, &reads))
ProcessRequestSocket ();
if (chooserFd >= 0 && FD_ISSET (chooserFd, &reads))
+#ifdef ISC
+ if (!ChildReady) {
+ WaitForSomething ();
+ } else
+#endif
ProcessChooserSocket (chooserFd);
}
if (ChildReady)
@@ -336,9 +367,9 @@ WaitForSomething ()
static ARRAY8 Hostname;
void
-registerHostname (name, namelen)
- char *name;
- int namelen;
+registerHostname (
+ char *name,
+ int namelen)
{
int i;
@@ -349,11 +380,11 @@ registerHostname (name, namelen)
}
static void
-direct_query_respond (from, fromlen, length, type)
- struct sockaddr *from;
- int fromlen;
- int length;
- xdmOpCode type;
+direct_query_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length,
+ xdmOpCode type)
{
ARRAYofARRAY8 queryAuthenticationNames;
int expectedLen;
@@ -369,19 +400,21 @@ direct_query_respond (from, fromlen, length, type)
XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames);
}
-query_respond (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+query_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
Debug ("Query respond %d\n", length);
direct_query_respond (from, fromlen, length, QUERY);
}
-broadcast_respond (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+broadcast_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
direct_query_respond (from, fromlen, length, BROADCAST_QUERY);
}
@@ -389,10 +422,11 @@ broadcast_respond (from, fromlen, length)
/* computes an X display name */
static char *
-NetworkAddressToName(connectionType, connectionAddress, displayNumber)
- CARD16 connectionType;
- ARRAY8Ptr connectionAddress;
- CARD16 displayNumber;
+NetworkAddressToName(
+ CARD16 connectionType,
+ ARRAY8Ptr connectionAddress,
+ struct sockaddr *originalAddress,
+ CARD16 displayNumber)
{
switch (connectionType)
{
@@ -401,11 +435,17 @@ NetworkAddressToName(connectionType, connectionAddress, displayNumber)
CARD8 *data;
struct hostent *hostent;
char *name;
- char *localhost, *localHostname();
+ char *localhost;
+ int multiHomed = 0;
data = connectionAddress->data;
hostent = gethostbyaddr ((char *)data,
connectionAddress->length, AF_INET);
+ if (sourceAddress && hostent) {
+ hostent = gethostbyname(hostent->h_name);
+ if (hostent)
+ multiHomed = hostent->h_addr_list[1] != NULL;
+ }
localhost = localHostname ();
@@ -413,7 +453,8 @@ NetworkAddressToName(connectionType, connectionAddress, displayNumber)
* protect against bogus host names
*/
if (hostent && hostent->h_name && hostent->h_name[0]
- && (hostent->h_name[0] != '.'))
+ && (hostent->h_name[0] != '.')
+ && !multiHomed)
{
if (!strcmp (localhost, hostent->h_name))
{
@@ -453,6 +494,9 @@ NetworkAddressToName(connectionType, connectionAddress, displayNumber)
{
if (!getString (name, 25))
return 0;
+ if (multiHomed)
+ data = (CARD8 *) &((struct sockaddr_in *)originalAddress)->
+ sin_addr.s_addr;
sprintf(name, "%d.%d.%d.%d:%d",
data[0], data[1], data[2], data[3], displayNumber);
}
@@ -468,10 +512,11 @@ NetworkAddressToName(connectionType, connectionAddress, displayNumber)
}
/*ARGSUSED*/
-forward_respond (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+forward_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
ARRAY8 clientAddress;
ARRAY8 clientPort;
@@ -547,7 +592,7 @@ forward_respond (from, fromlen, length)
memmove( un_addr.sun_path, clientAddress.data, clientAddress.length);
un_addr.sun_path[clientAddress.length] = '\0';
client = (struct sockaddr *) &un_addr;
-#ifdef BSD44SOCKETS
+#if defined(BSD44SOCKETS) && !defined(Lynx) && defined(UNIXCONN)
un_addr.sun_len = strlen(un_addr.sun_path);
clientlen = SUN_LEN(&un_addr);
#else
@@ -579,11 +624,12 @@ badAddress:
XdmcpDisposeARRAYofARRAY8 (&authenticationNames);
}
-send_willing (from, fromlen, authenticationName, status)
- struct sockaddr *from;
- int fromlen;
- ARRAY8Ptr authenticationName;
- ARRAY8Ptr status;
+static void
+send_willing (
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr authenticationName,
+ ARRAY8Ptr status)
{
XdmcpHeader header;
@@ -601,14 +647,15 @@ send_willing (from, fromlen, authenticationName, status)
XdmcpWriteARRAY8 (&buffer, authenticationName);
XdmcpWriteARRAY8 (&buffer, &Hostname);
XdmcpWriteARRAY8 (&buffer, status);
- XdmcpFlush (xdmcpFd, &buffer, from, fromlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
}
-send_unwilling (from, fromlen, authenticationName, status)
- struct sockaddr *from;
- int fromlen;
- ARRAY8Ptr authenticationName;
- ARRAY8Ptr status;
+static void
+send_unwilling (
+ struct sockaddr *from,
+ int fromlen,
+ ARRAY8Ptr authenticationName,
+ ARRAY8Ptr status)
{
XdmcpHeader header;
@@ -624,14 +671,14 @@ send_unwilling (from, fromlen, authenticationName, status)
XdmcpWriteHeader (&buffer, &header);
XdmcpWriteARRAY8 (&buffer, &Hostname);
XdmcpWriteARRAY8 (&buffer, status);
- XdmcpFlush (xdmcpFd, &buffer, from, fromlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
}
static unsigned long globalSessionID;
#define NextSessionID() (++globalSessionID)
-void init_session_id()
+void init_session_id(void)
{
/* Set randomly so we are unlikely to reuse id's from a previous
* incarnation so we don't say "Alive" to those displays.
@@ -645,10 +692,11 @@ static ARRAY8 noValidAddr = { (CARD16) 16, (CARD8Ptr) "No valid address" };
static ARRAY8 noValidAuth = { (CARD16) 22, (CARD8Ptr) "No valid authorization" };
static ARRAY8 noAuthentic = { (CARD16) 29, (CARD8Ptr) "XDM has no authentication key" };
-request_respond (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+request_respond (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
CARD16 displayNumber;
ARRAY16 connectionTypes;
@@ -657,7 +705,7 @@ request_respond (from, fromlen, length)
ARRAY8 authenticationData;
ARRAYofARRAY8 authorizationNames;
ARRAY8 manufacturerDisplayID;
- ARRAY8Ptr reason;
+ ARRAY8Ptr reason = 0;
int expectlen;
int i, j;
struct protoDisplay *pdpy;
@@ -705,7 +753,7 @@ request_respond (from, fromlen, length)
pdpy = 0;
goto decline;
}
- pdpy = FindProtoDisplay (from, fromlen, displayNumber);
+ pdpy = FindProtoDisplay ((XdmcpNetaddr) from, fromlen, displayNumber);
if (!pdpy) {
/* Check this Display against the Manager's policy */
@@ -723,10 +771,10 @@ request_respond (from, fromlen, length)
/* The Manager considers this a new session */
connectionAddress = &connectionAddresses.data[i];
- pdpy = NewProtoDisplay (from, fromlen, displayNumber,
+ pdpy = NewProtoDisplay ((XdmcpNetaddr) from, fromlen, displayNumber,
connectionTypes.data[i], connectionAddress,
NextSessionID());
- Debug ("NewProtoDisplay 0x%x\n", pdpy);
+ Debug ("NewProtoDisplay %p\n", pdpy);
if (!pdpy) {
reason = &outOfMemory;
goto decline;
@@ -794,18 +842,19 @@ abort:
XdmcpDisposeARRAY8 (&manufacturerDisplayID);
}
-send_accept (to, tolen, sessionID,
- authenticationName, authenticationData,
- authorizationName, authorizationData)
- struct sockaddr *to;
- int tolen;
- CARD32 sessionID;
- ARRAY8Ptr authenticationName, authenticationData;
- ARRAY8Ptr authorizationName, authorizationData;
+static void
+send_accept (
+ struct sockaddr *to,
+ int tolen,
+ CARD32 sessionID,
+ ARRAY8Ptr authenticationName,
+ ARRAY8Ptr authenticationData,
+ ARRAY8Ptr authorizationName,
+ ARRAY8Ptr authorizationData)
{
XdmcpHeader header;
- Debug ("Accept Session ID %d\n", sessionID);
+ Debug ("Accept Session ID %ld\n", (long) sessionID);
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) ACCEPT;
header.length = 4; /* session ID */
@@ -819,14 +868,16 @@ send_accept (to, tolen, sessionID,
XdmcpWriteARRAY8 (&buffer, authenticationData);
XdmcpWriteARRAY8 (&buffer, authorizationName);
XdmcpWriteARRAY8 (&buffer, authorizationData);
- XdmcpFlush (xdmcpFd, &buffer, to, tolen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen);
}
-send_decline (to, tolen, authenticationName, authenticationData, status)
- struct sockaddr *to;
- int tolen;
- ARRAY8Ptr authenticationName, authenticationData;
- ARRAY8Ptr status;
+static void
+send_decline (
+ struct sockaddr *to,
+ int tolen,
+ ARRAY8Ptr authenticationName,
+ ARRAY8Ptr authenticationData,
+ ARRAY8Ptr status)
{
XdmcpHeader header;
@@ -841,13 +892,14 @@ send_decline (to, tolen, authenticationName, authenticationData, status)
XdmcpWriteARRAY8 (&buffer, status);
XdmcpWriteARRAY8 (&buffer, authenticationName);
XdmcpWriteARRAY8 (&buffer, authenticationData);
- XdmcpFlush (xdmcpFd, &buffer, to, tolen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen);
}
-manage (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+manage (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
CARD32 sessionID;
CARD16 displayNumber;
@@ -876,8 +928,8 @@ manage (from, fromlen, length)
Debug ("Manage length error got %d expect %d\n", length, expectlen);
goto abort;
}
- pdpy = FindProtoDisplay (from, fromlen, displayNumber);
- Debug ("Manage Session ID %d, pdpy 0x%x\n", sessionID, pdpy);
+ pdpy = FindProtoDisplay ((XdmcpNetaddr) from, fromlen, displayNumber);
+ Debug ("Manage Session ID %ld, pdpy %p\n", (long) sessionID, pdpy);
if (!pdpy || pdpy->sessionID != sessionID)
{
/*
@@ -889,20 +941,21 @@ manage (from, fromlen, length)
* can be ignored.
*/
if (!pdpy
- && (d = FindDisplayByAddress(from, fromlen, displayNumber))
+ && (d = FindDisplayByAddress((XdmcpNetaddr) from, fromlen, displayNumber))
&& d->sessionID == sessionID) {
Debug("manage: got duplicate pkt, ignoring\n");
goto abort;
}
- Debug ("Session ID %d refused\n", sessionID);
+ Debug ("Session ID %ld refused\n", (long) sessionID);
if (pdpy)
- Debug ("Existing Session ID %d\n", pdpy->sessionID);
+ Debug ("Existing Session ID %ld\n", (long) pdpy->sessionID);
send_refuse (from, fromlen, sessionID);
}
else
{
name = NetworkAddressToName (pdpy->connectionType,
&pdpy->connectionAddress,
+ from,
pdpy->displayNumber);
Debug ("Computed display name: %s\n", name);
if (!name)
@@ -913,8 +966,6 @@ manage (from, fromlen, length)
d = FindDisplayByName (name);
if (d)
{
- extern void StopDisplay ();
-
Debug ("Terminating active session for %s\n", d->name);
StopDisplay (d);
}
@@ -995,28 +1046,30 @@ abort:
if (class) free ((char*) class);
}
-SendFailed (d, reason)
- struct display *d;
- char *reason;
+void
+SendFailed (
+ struct display *d,
+ char *reason)
{
Debug ("Display start failed, sending Failed\n");
- send_failed (d->from, d->fromlen, d->name, d->sessionID, reason);
+ send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, d->sessionID, reason);
}
-send_failed (from, fromlen, name, sessionID, reason)
- struct sockaddr *from;
- int fromlen;
- char *name;
- CARD32 sessionID;
- char *reason;
+static void
+send_failed (
+ struct sockaddr *from,
+ int fromlen,
+ char *name,
+ CARD32 sessionID,
+ char *reason)
{
static char buf[256];
XdmcpHeader header;
ARRAY8 status;
- sprintf (buf, "Session %d failed for display %s: %s",
- sessionID, name, reason);
- Debug ("Send failed %d %s\n", sessionID, buf);
+ sprintf (buf, "Session %ld failed for display %.100s: %.100s",
+ (long) sessionID, name, reason);
+ Debug ("Send failed %ld %s\n", (long) sessionID, buf);
status.length = strlen (buf);
status.data = (CARD8Ptr) buf;
header.version = XDM_PROTOCOL_VERSION;
@@ -1025,29 +1078,31 @@ send_failed (from, fromlen, name, sessionID, reason)
XdmcpWriteHeader (&buffer, &header);
XdmcpWriteCARD32 (&buffer, sessionID);
XdmcpWriteARRAY8 (&buffer, &status);
- XdmcpFlush (xdmcpFd, &buffer, from, fromlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
}
-send_refuse (from, fromlen, sessionID)
- struct sockaddr *from;
- int fromlen;
- CARD32 sessionID;
+static void
+send_refuse (
+ struct sockaddr *from,
+ int fromlen,
+ CARD32 sessionID)
{
XdmcpHeader header;
- Debug ("Send refuse %d\n", sessionID);
+ Debug ("Send refuse %ld\n", (long) sessionID);
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) REFUSE;
header.length = 4;
XdmcpWriteHeader (&buffer, &header);
XdmcpWriteCARD32 (&buffer, sessionID);
- XdmcpFlush (xdmcpFd, &buffer, from, fromlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
}
-send_alive (from, fromlen, length)
- struct sockaddr *from;
- int fromlen;
- int length;
+static void
+send_alive (
+ struct sockaddr *from,
+ int fromlen,
+ int length)
{
CARD32 sessionID;
CARD16 displayNumber;
@@ -1064,7 +1119,7 @@ send_alive (from, fromlen, length)
{
d = FindDisplayBySessionID (sessionID);
if (!d) {
- d = FindDisplayByAddress (from, fromlen, displayNumber);
+ d = FindDisplayByAddress ((XdmcpNetaddr) from, fromlen, displayNumber);
}
sendRunning = 0;
sendSessionID = 0;
@@ -1077,19 +1132,19 @@ send_alive (from, fromlen, length)
header.version = XDM_PROTOCOL_VERSION;
header.opcode = (CARD16) ALIVE;
header.length = 5;
- Debug ("alive: %d %d\n", sendRunning, sendSessionID);
+ Debug ("alive: %d %ld\n", sendRunning, (long) sendSessionID);
XdmcpWriteHeader (&buffer, &header);
XdmcpWriteCARD8 (&buffer, sendRunning);
XdmcpWriteCARD32 (&buffer, sendSessionID);
- XdmcpFlush (xdmcpFd, &buffer, from, fromlen);
+ XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
}
}
}
char *
-NetworkAddressToHostname (connectionType, connectionAddress)
- CARD16 connectionType;
- ARRAY8Ptr connectionAddress;
+NetworkAddressToHostname (
+ CARD16 connectionType,
+ ARRAY8Ptr connectionAddress)
{
char *name = 0;
@@ -1097,16 +1152,29 @@ NetworkAddressToHostname (connectionType, connectionAddress)
{
case FamilyInternet:
{
- struct hostent *hostent;
+ struct hostent *hostent = NULL;
char dotted[20];
- char *local_name;
+ char *local_name = "";
hostent = gethostbyaddr ((char *)connectionAddress->data,
connectionAddress->length, AF_INET);
- if (hostent)
- local_name = hostent->h_name;
- else {
+ if (hostent) {
+ /* check for DNS spoofing */
+ char *s = strdup(hostent->h_name); /* fscking non-reentrancy of getXXX() */
+ if ((hostent = gethostbyname(s))) {
+ if (memcmp((char*)connectionAddress->data, hostent->h_addr,
+ hostent->h_length) != 0) {
+ LogError("Possible DNS spoof attempt.");
+ hostent = NULL; /* so it enters next if() */
+ } else {
+ local_name = hostent->h_name;
+ }
+ }
+ free(s);
+ }
+
+ if (!hostent) {
/* can't get name, so use emergency fallback */
sprintf(dotted, "%d.%d.%d.%d",
connectionAddress->data[0],
@@ -1130,13 +1198,14 @@ NetworkAddressToHostname (connectionType, connectionAddress)
break;
}
return name;
-}
+ }
-static
-HostnameToNetworkAddress (name, connectionType, connectionAddress)
-char *name;
-CARD16 connectionType;
-ARRAY8Ptr connectionAddress;
+#if 0
+static int
+HostnameToNetworkAddress (
+char *name,
+CARD16 connectionType,
+ARRAY8Ptr connectionAddress)
{
switch (connectionType)
{
@@ -1164,13 +1233,12 @@ ARRAY8Ptr connectionAddress;
* converts a display name into a network address, using
* the same rules as XOpenDisplay (algorithm cribbed from there)
*/
-
-static
-NameToNetworkAddress(name, connectionTypep, connectionAddress, displayNumber)
-char *name;
-CARD16Ptr connectionTypep;
-ARRAY8Ptr connectionAddress;
-CARD16Ptr displayNumber;
+static int
+NameToNetworkAddress(
+char *name,
+CARD16Ptr connectionTypep,
+ARRAY8Ptr connectionAddress,
+CARD16Ptr displayNumber)
{
char *colon, *display_number;
char hostname[1024];
@@ -1222,5 +1290,6 @@ CARD16Ptr displayNumber;
*connectionTypep = connectionType;
return TRUE;
}
+#endif
#endif /* XDMCP */
diff --git a/xdmshell.c b/xdmshell.c
index 166e689..30f6345 100644
--- a/xdmshell.c
+++ b/xdmshell.c
@@ -36,12 +36,11 @@ in this Software without prior written authorization from The Open Group.
* bring down X when you are finished.
*/
+/* $XFree86: xc/programs/xdm/xdmshell.c,v 3.7 2001/12/14 20:01:26 dawes Exp $ */
+
#include <stdio.h>
#include "dm.h"
#include <errno.h>
-#ifdef X_NOT_STDC_ENV
-extern int errno;
-#endif
#ifdef macII
#define ON_CONSOLE_ONLY
@@ -64,17 +63,9 @@ extern int errno;
char *ProgramName;
-static char *SysErrorMsg (n)
- int n;
-{
- char *s = strerror(n);
- return (s ? s : "unknown error");
-}
-
-
-static int exec_args (filename, args)
- char *filename;
- char **args;
+static int exec_args (
+ char *filename,
+ char **args)
{
int pid;
waitType status;
@@ -103,9 +94,10 @@ static int exec_args (filename, args)
return waitCode (status);
}
-static int exec_one_arg (filename, arg)
- char *filename;
- char *arg;
+#if defined(macII) || defined(sun)
+static int exec_one_arg (
+ char *filename,
+ char *arg)
{
char *argv[3];
@@ -114,10 +106,12 @@ static int exec_one_arg (filename, arg)
argv[2] = NULL;
return exec_args (filename, argv);
}
+#endif
-main (argc, argv)
- int argc;
- char *argv[];
+int
+main (
+ int argc,
+ char *argv[])
{
int ttyfd;
char cmdbuf[256];
@@ -199,7 +193,7 @@ main (argc, argv)
args[4] = NULL;
if (exec_args (cmdbuf, args) == -1) {
fprintf (stderr, "%s: unable to execute %s (error %d, %s)\r\n",
- ProgramName, cmdbuf, errno, SysErrorMsg(errno));
+ ProgramName, cmdbuf, errno, strerror(errno));
exit (1);
}