diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 22:14:42 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 22:14:42 -0700 |
commit | 3beb4d278caa281ea8ebad55ae2f45ea0d46a6e6 (patch) | |
tree | c8f6bfcc9b11540fd7c102752c343078080513ac | |
parent | b80b263f964031b1edef0a5e0a77a6615dc4be82 (diff) |
Use imdent to show cpp macro nesting more clearly
Also strip trailing whitespace to make git happier.
While many lines are changes, "git diff -w" shows no changes other
than pure whitespace.
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | access.c | 134 | ||||
-rw-r--r-- | auth.c | 216 | ||||
-rw-r--r-- | choose.c | 102 | ||||
-rw-r--r-- | chooser.c | 164 | ||||
-rw-r--r-- | dm.c | 112 | ||||
-rw-r--r-- | dm.h | 246 | ||||
-rw-r--r-- | dm_auth.h | 38 | ||||
-rw-r--r-- | dm_error.h | 12 | ||||
-rw-r--r-- | dm_socket.h | 20 | ||||
-rw-r--r-- | dpylist.c | 6 | ||||
-rw-r--r-- | error.c | 8 | ||||
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | genauth.c | 86 | ||||
-rw-r--r-- | greet.h | 110 | ||||
-rw-r--r-- | greeter/Login.c | 262 | ||||
-rw-r--r-- | greeter/Login.h | 80 | ||||
-rw-r--r-- | greeter/LoginP.h | 58 | ||||
-rw-r--r-- | greeter/greet.c | 102 | ||||
-rw-r--r-- | greeter/verify.c | 102 | ||||
-rw-r--r-- | krb5auth.c | 2 | ||||
-rw-r--r-- | mitauth.c | 8 | ||||
-rw-r--r-- | netaddr.c | 124 | ||||
-rw-r--r-- | policy.c | 32 | ||||
-rw-r--r-- | prngc.c | 20 | ||||
-rw-r--r-- | protodpy.c | 10 | ||||
-rw-r--r-- | reset.c | 12 | ||||
-rw-r--r-- | resource.c | 80 | ||||
-rw-r--r-- | rpcauth.c | 12 | ||||
-rw-r--r-- | server.c | 36 | ||||
-rw-r--r-- | session.c | 50 | ||||
-rw-r--r-- | socket.c | 142 | ||||
-rw-r--r-- | streams.c | 12 | ||||
-rw-r--r-- | util.c | 34 | ||||
-rw-r--r-- | xdmauth.c | 16 | ||||
-rw-r--r-- | xdmcp.c | 264 | ||||
-rw-r--r-- | xdmshell.c | 12 |
36 files changed, 1366 insertions, 1366 deletions
@@ -32,8 +32,8 @@ in this Software without prior written authorization from the copyright holder. * and (potentially) a list of hosts to send ForwardQuery packets to */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" #ifdef XDMCP @@ -51,20 +51,20 @@ in this Software without prior written authorization from the copyright holder. # include <arpa/inet.h> # endif -#define ALIAS_CHARACTER '%' -#define NEGATE_CHARACTER '!' -#define CHOOSER_STRING "CHOOSER" -#define BROADCAST_STRING "BROADCAST" -#define NOBROADCAST_STRING "NOBROADCAST" -#define LISTEN_STRING "LISTEN" -#define WILDCARD_STRING "*" - -#define HOST_ALIAS 0 -#define HOST_ADDRESS 1 -#define HOST_BROADCAST 2 -#define HOST_CHOOSER 3 -#define HOST_NOBROADCAST 4 -#define HOST_ANYADDR 5 +# define ALIAS_CHARACTER '%' +# define NEGATE_CHARACTER '!' +# define CHOOSER_STRING "CHOOSER" +# define BROADCAST_STRING "BROADCAST" +# define NOBROADCAST_STRING "NOBROADCAST" +# define LISTEN_STRING "LISTEN" +# define WILDCARD_STRING "*" + +# define HOST_ALIAS 0 +# define HOST_ADDRESS 1 +# define HOST_BROADCAST 2 +# define HOST_CHOOSER 3 +# define HOST_NOBROADCAST 4 +# define HOST_ANYADDR 5 typedef struct _hostEntry { struct _hostEntry *next; @@ -76,10 +76,10 @@ typedef struct _hostEntry { int hopCount; } HostEntry; -#define DISPLAY_ALIAS 0 -#define DISPLAY_PATTERN 1 -#define DISPLAY_ADDRESS 2 -#define DISPLAY_LISTEN 3 +# define DISPLAY_ALIAS 0 +# define DISPLAY_PATTERN 1 +# define DISPLAY_ADDRESS 2 +# define DISPLAY_LISTEN 3 typedef struct _displayEntry { struct _displayEntry *next; @@ -106,10 +106,10 @@ ARRAY8Ptr getLocalAddress (void) { static int haveLocalAddress; - + if (!haveLocalAddress) { -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai; if (getaddrinfo(localHostname(), NULL, NULL, &ai) != 0) { @@ -121,18 +121,18 @@ getLocalAddress (void) } else { if (ai->ai_addr->sa_family == AF_INET) { XdmcpAllocARRAY8 (&localAddress, sizeof(struct in_addr)); - memcpy(localAddress.data, + memcpy(localAddress.data, &((struct sockaddr_in *)ai->ai_addr)->sin_addr, sizeof(struct in_addr)); } else if (ai->ai_addr->sa_family == AF_INET6) { XdmcpAllocARRAY8 (&localAddress, sizeof(struct in6_addr)); - memcpy(localAddress.data, + memcpy(localAddress.data, &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr, sizeof(struct in6_addr)); - } + } freeaddrinfo(ai); } -#else +# else struct hostent *hostent; hostent = gethostbyname (localHostname()); @@ -147,7 +147,7 @@ getLocalAddress (void) localAddress.data[2] = 0; localAddress.data[3] = 1; } -#endif +# endif } return &localAddress; @@ -207,7 +207,7 @@ FreeAccessDatabase (void) database = NULL; } -#define WORD_LEN 256 +# define WORD_LEN 256 static char wordBuffer[WORD_LEN]; static int nextIsEOF; @@ -314,11 +314,11 @@ tryagain: { void *addr=NULL; size_t addr_length=0; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai = NULL; -#else +# else struct hostent *hostent = gethostbyname (hostOrAlias); -#endif +# endif char *hops = strrchr(hostOrAlias, '/'); if (hops) { @@ -328,7 +328,7 @@ tryagain: h->hopCount = 1; } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (getaddrinfo(hostOrAlias, NULL, NULL, &ai) == 0) { if (ai->ai_addr->sa_family == AF_INET) { addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr; @@ -336,14 +336,14 @@ tryagain: } else if (ai->ai_addr->sa_family == AF_INET6) { addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; addr_length = sizeof(struct in6_addr); - } + } } -#else +# else if (hostent) { addr = hostent->h_addr; addr_length = hostent->h_length; } -#endif +# endif h->type = HOST_ADDRESS; if (!addr) @@ -351,27 +351,27 @@ tryagain: Debug ("No such host %s\n", hostOrAlias); LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias); free ((char *) h); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif goto tryagain; } if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, addr_length)) { LogOutOfMem ("ReadHostEntry\n"); free ((char *) h); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } memmove( h->entry.hostAddress.data, addr, addr_length); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif } return h; } @@ -396,7 +396,7 @@ ReadDisplayEntry (FILE *file) DisplayEntry *d; struct _display *display; HostEntry *h, **prev; - + displayOrAlias = ReadWord (file, FALSE); if (!displayOrAlias) return NULL; @@ -414,7 +414,7 @@ ReadDisplayEntry (FILE *file) return NULL; } } - else if (!strcmp(displayOrAlias, LISTEN_STRING)) + else if (!strcmp(displayOrAlias, LISTEN_STRING)) { d->type = DISPLAY_LISTEN; } @@ -441,7 +441,7 @@ ReadDisplayEntry (FILE *file) size_t addr_length = 0; int addrtype = 0; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai = NULL; if (getaddrinfo(displayOrAlias, NULL, NULL, &ai) == 0) { @@ -452,9 +452,9 @@ ReadDisplayEntry (FILE *file) } else if (addrtype == AF_INET6) { addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; addr_length = sizeof(struct in6_addr); - } + } } -#else +# else struct hostent *hostent; if ((hostent = gethostbyname (displayOrAlias)) != NULL) @@ -464,15 +464,15 @@ ReadDisplayEntry (FILE *file) addrtype = hostent->h_addrtype; addr_length = hostent->h_length; } -#endif +# endif if (addr == NULL) { LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias); free ((char *) d); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } d->type = DISPLAY_ADDRESS; @@ -480,39 +480,39 @@ ReadDisplayEntry (FILE *file) if (!XdmcpAllocARRAY8 (&display->clientAddress, addr_length)) { free ((char *) d); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif return NULL; } memmove( display->clientAddress.data, addr, addr_length); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (ai) freeaddrinfo(ai); -#endif +# endif switch (addrtype) { -#ifdef AF_UNIX +# ifdef AF_UNIX case AF_UNIX: display->connectionType = FamilyLocal; break; -#endif -#ifdef AF_INET +# endif +# ifdef AF_INET case AF_INET: display->connectionType = FamilyInternet; break; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: display->connectionType = FamilyInternet6; break; -#endif -#ifdef AF_DECnet +# endif +# ifdef AF_DECnet case AF_DECnet: display->connectionType = FamilyDECnet; break; -#endif +# endif default: display->connectionType = FamilyLocal; break; @@ -585,7 +585,7 @@ ScanAccessDatabase (void) * the local host exists on any of the lists, else FALSE */ -#define MAX_DEPTH 32 +# define MAX_DEPTH 32 static int indirectAlias ( char *alias, @@ -936,21 +936,21 @@ void ForEachListenAddr ( } if (!listenFound) { (*listenfunction) (NULL, closure); -#if defined(IPv6) && defined(AF_INET6) && defined(XDM_DEFAULT_MCAST_ADDR6) +# if defined(IPv6) && defined(AF_INET6) && defined(XDM_DEFAULT_MCAST_ADDR6) { /* Join default IPv6 Multicast Group */ static ARRAY8 defaultMcastAddress; if (defaultMcastAddress.length == 0) { struct in6_addr addr6; - + if (inet_pton(AF_INET6,XDM_DEFAULT_MCAST_ADDR6,&addr6) == 1) { - if (!XdmcpAllocARRAY8 (&defaultMcastAddress, + if (!XdmcpAllocARRAY8 (&defaultMcastAddress, sizeof(struct in6_addr))) { LogOutOfMem ("ReadHostEntry\n"); defaultMcastAddress.length = -1; } else { - memcpy(defaultMcastAddress.data, &addr6, + memcpy(defaultMcastAddress.data, &addr6, sizeof(struct in6_addr)); } } else { @@ -961,7 +961,7 @@ void ForEachListenAddr ( (*mcastfunction) (&defaultMcastAddress, closure); } } -#endif +# endif } } @@ -57,7 +57,7 @@ from The Open Group. #endif #if defined(hpux) -#include <sys/utsname.h> +# include <sys/utsname.h> #endif #if defined(SYSV) && defined(i386) @@ -78,10 +78,10 @@ from The Open Group. # include <sync/sema.h> #endif #ifdef __GNU__ -#include <netdb.h> -#undef SIOCGIFCONF +# include <netdb.h> +# undef SIOCGIFCONF #else /* __GNU__ */ -#include <net/if.h> +# include <net/if.h> #endif /* __GNU__ */ #if defined(TCPCONN) && !defined(WIN32) @@ -97,26 +97,26 @@ from The Open Group. */ #ifdef SIOCGLIFCONF /* #if defined(sun) */ -#define USE_SIOCGLIFCONF +# define USE_SIOCGLIFCONF /* #endif */ #endif #if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && \ defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) -#define SYSV_SIOCGIFCONF +# define SYSV_SIOCGIFCONF #endif #ifdef CSRG_BASED -#include <sys/param.h> -#if (BSD >= 199103) -#define VARIABLE_IFREQ -#endif +# include <sys/param.h> +# if (BSD >= 199103) +# define VARIABLE_IFREQ +# endif #endif #ifdef __UNIXOS2__ -#define link rename +# define link rename int chown(int a,int b,int c) {} -#include <io.h> +# include <io.h> #endif struct AuthProtocol { @@ -285,9 +285,9 @@ MakeServerAuthFile (struct display *d, FILE ** file) { int len; #if defined(SYSV) && !defined(SVR4) -#define NAMELEN 14 +# define NAMELEN 14 #else -#define NAMELEN 255 +# define NAMELEN 255 #endif char cleanname[NAMELEN]; int r; @@ -696,15 +696,15 @@ DefineLocal (FILE *file, Xauth *auth) */ char tmp_displayname[100]; struct utsname name; - + tmp_displayname[0] = 0; uname(&name); snprintf(tmp_displayname, sizeof(tmp_displayname), "%s", name.nodename); writeAddr (FamilyLocal, strlen (tmp_displayname), tmp_displayname, file, auth); - + /* - * If _XGetHostname() returned the same value as uname(), don't + * If _XGetHostname() returned the same value as uname(), don't * write a duplicate entry. */ if (strcmp (displayname, tmp_displayname)) @@ -714,7 +714,7 @@ DefineLocal (FILE *file, Xauth *auth) } #ifdef HAS_GETIFADDRS -#include <ifaddrs.h> +# include <ifaddrs.h> static void DefineSelf(int fd, FILE *file, Xauth *auth) @@ -722,14 +722,14 @@ DefineSelf(int fd, FILE *file, Xauth *auth) struct ifaddrs *ifap, *ifr; char *addr; int family, len; - + Debug("DefineSelf\n"); - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) < 0) return; for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) { len = sizeof(*(ifr->ifa_addr)); family = ConvertAddr((XdmcpNetaddr)(ifr->ifa_addr), &len, &addr); - if (family == -1 || family == FamilyLocal) + if (family == -1 || family == FamilyLocal) continue; /* * don't write out 'localhost' entries, as @@ -745,27 +745,27 @@ DefineSelf(int fd, FILE *file, Xauth *auth) Debug ("Skipping localhost address\n"); continue; } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if(family == FamilyInternet6) { if (IN6_IS_ADDR_LOOPBACK(((struct in6_addr *)addr))) { Debug ("Skipping IPv6 localhost address\n"); continue; } /* Also skip XDM-AUTHORIZATION-1 */ - if (auth->name_length == 19 && + if (auth->name_length == 19 && strcmp(auth->name, "XDM-AUTHORIZATION-1") == 0) { Debug ("Skipping IPv6 XDM-AUTHORIZATION-1\n"); continue; } } -#endif +# endif writeAddr(family, len, addr, file, auth); - } + } Debug("DefineSelf done\n"); } #else /* GETIFADDRS */ -#ifdef SYSV_SIOCGIFCONF +# ifdef SYSV_SIOCGIFCONF /* Deal with different SIOCGIFCONF ioctl semantics on SYSV, SVR4 */ @@ -782,7 +782,7 @@ ifioctl (int fd, int cmd, char *arg) { ioc.ic_len = ((struct ifconf *) arg)->ifc_len; ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; -#ifdef ISC +# 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 @@ -792,7 +792,7 @@ ifioctl (int fd, int cmd, char *arg) */ ((struct ifconf *) ioc.ic_dp)->ifc_len = ioc.ic_len - sizeof(struct ifconf); -#endif +# endif } else { @@ -801,28 +801,28 @@ ifioctl (int fd, int cmd, char *arg) } ret = ioctl(fd, I_STR, (char *) &ioc); if (ret >= 0 && cmd == SIOCGIFCONF) -#ifdef SVR4 +# ifdef SVR4 ((struct ifconf *) arg)->ifc_len = ioc.ic_len; -#endif -#ifdef ISC +# endif +# ifdef ISC { ((struct ifconf *) arg)->ifc_len = ((struct ifconf *)ioc.ic_dp)->ifc_len; - ((struct ifconf *) arg)->ifc_buf = + ((struct ifconf *) arg)->ifc_buf = (caddr_t)((struct ifconf *)ioc.ic_dp)->ifc_req; } -#endif +# endif return(ret); } -#else /* SYSV_SIOCGIFCONF */ -#define ifioctl ioctl -#endif /* SYSV_SIOCGIFCONF */ +# else /* SYSV_SIOCGIFCONF */ +# define ifioctl ioctl +# endif /* SYSV_SIOCGIFCONF */ -#if defined(STREAMSCONN) && !defined(SYSV_SIOCGIFCONF) && !defined(NCR) +# if defined(STREAMSCONN) && !defined(SYSV_SIOCGIFCONF) && !defined(NCR) -#include <tiuser.h> +# include <tiuser.h> -/* Define this host for access control. Find all the hosts the OS knows about +/* 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. */ @@ -831,7 +831,7 @@ 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) @@ -840,20 +840,20 @@ DefineSelf (int fd, FILE *file, Xauth *auth) writeAddr (FamilyInternet, 4, netb.buf+4, file, auth); } -#else +# else -#ifdef WINTCP /* NCR with Wollongong TCP */ +# ifdef WINTCP /* NCR with Wollongong TCP */ -#include <sys/un.h> -#include <stropts.h> -#include <tiuser.h> +# include <sys/un.h> +# include <stropts.h> +# include <tiuser.h> -#include <sys/stream.h> -#include <net/if.h> -#include <netinet/ip.h> -#include <netinet/ip_var.h> -#include <netinet/in.h> -#include <netinet/in_var.h> +# include <sys/stream.h> +# include <net/if.h> +# include <netinet/ip.h> +# include <netinet/ip_var.h> +# include <netinet/in.h> +# include <netinet/in_var.h> static void DefineSelf (int fd, FILE *file, Xauth *auth) @@ -909,31 +909,31 @@ DefineSelf (int fd, FILE *file, Xauth *auth) continue; writeAddr (FamilyInternet, 4, (char *)&(IA_SIN(&ifaddr)->sin_addr), file, auth); - + } close(ipfd); } -#else /* WINTCP */ +# else /* WINTCP */ -#if defined(SIOCGIFCONF) || defined (USE_SIOCGLIFCONF) +# if defined(SIOCGIFCONF) || defined (USE_SIOCGLIFCONF) -#ifdef USE_SIOCGLIFCONF -#define ifr_type struct lifreq -#else -#define ifr_type struct ifreq -#endif +# ifdef USE_SIOCGLIFCONF +# define ifr_type struct lifreq +# else +# define ifr_type struct ifreq +# endif /* Handle variable length ifreq in BNR2 and later */ -#ifdef VARIABLE_IFREQ -#define ifr_size(p) (sizeof (struct ifreq) + \ +# 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 (ifr_type)) -#endif +# else +# define ifr_size(p) (sizeof (ifr_type)) +# endif -/* Define this host for access control. Find all the hosts the OS knows about +/* 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 void @@ -944,19 +944,19 @@ DefineSelf (int fd, FILE *file, Xauth *auth) char *addr; int family; register ifr_type *ifr; -#ifdef USE_SIOCGLIFCONF +# ifdef USE_SIOCGLIFCONF int n; void * bufptr = buf; size_t buflen = sizeof(buf); struct lifconf ifc; -#ifdef SIOCGLIFNUM +# ifdef SIOCGLIFNUM struct lifnum ifn; -#endif -#else +# endif +# else struct ifconf ifc; -#endif - -#if defined(SIOCGLIFNUM) && defined(SIOCGLIFCONF) +# endif + +# if defined(SIOCGLIFNUM) && defined(SIOCGLIFCONF) ifn.lifn_family = AF_UNSPEC; ifn.lifn_flags = 0; if (ioctl (fd, (int) SIOCGLIFNUM, (char *) &ifn) < 0) @@ -965,43 +965,43 @@ DefineSelf (int fd, FILE *file, Xauth *auth) buflen = ifn.lifn_count * sizeof(struct lifreq); bufptr = malloc(buflen); } -#endif +# endif -#ifdef USE_SIOCGLIFCONF +# ifdef USE_SIOCGLIFCONF ifc.lifc_family = AF_UNSPEC; ifc.lifc_flags = 0; ifc.lifc_len = buflen; ifc.lifc_buf = bufptr; -#define IFC_IOCTL_REQ SIOCGLIFCONF -#define IFC_IFC_REQ ifc.lifc_req -#define IFC_IFC_LEN ifc.lifc_len -#define IFR_IFR_ADDR ifr->lifr_addr -#define IFR_IFR_NAME ifr->lifr_name +# define IFC_IOCTL_REQ SIOCGLIFCONF +# define IFC_IFC_REQ ifc.lifc_req +# define IFC_IFC_LEN ifc.lifc_len +# define IFR_IFR_ADDR ifr->lifr_addr +# define IFR_IFR_NAME ifr->lifr_name -#else +# else ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; -#define IFC_IOCTL_REQ SIOCGIFCONF -#ifdef ISC -#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf -#else -#define IFC_IFC_REQ ifc.ifc_req -#endif -#define IFC_IFC_LEN ifc.ifc_len -#define IFR_IFR_ADDR ifr->ifr_addr -#define IFR_IFR_NAME ifr->ifr_name -#endif +# define IFC_IOCTL_REQ SIOCGIFCONF +# ifdef ISC +# define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf +# else +# define IFC_IFC_REQ ifc.ifc_req +# endif +# define IFC_IFC_LEN ifc.ifc_len +# define IFR_IFR_ADDR ifr->ifr_addr +# define IFR_IFR_NAME ifr->ifr_name +# endif if (ifioctl (fd, IFC_IOCTL_REQ, (char *) &ifc) < 0) { LogError ("Trouble getting network interface configuration"); -#ifdef USE_SIOCGLIFCONF +# ifdef USE_SIOCGLIFCONF if (bufptr != buf) { free(bufptr); } -#endif +# endif return; } @@ -1010,7 +1010,7 @@ DefineSelf (int fd, FILE *file, Xauth *auth) for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) { ifr = (ifr_type *) cp; -#ifdef DNETCONN +# ifdef DNETCONN /* * this is ugly but SIOCGIFCONF returns decnet addresses in * a different form from other decnet calls @@ -1020,7 +1020,7 @@ DefineSelf (int fd, FILE *file, Xauth *auth) addr = (char *)ifr->ifr_addr.sa_data; family = FamilyDECnet; } else -#endif +# endif { family = ConvertAddr ((XdmcpNetaddr) &IFR_IFR_ADDR, &len, &addr); if (family < 0) @@ -1045,29 +1045,29 @@ DefineSelf (int fd, FILE *file, Xauth *auth) Debug ("Skipping localhost address\n"); continue; } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if(family == FamilyInternet6) { if (IN6_IS_ADDR_LOOPBACK(((struct in6_addr *)addr))) { Debug ("Skipping IPv6 localhost address\n"); continue; } /* Also skip XDM-AUTHORIZATION-1 */ - if (auth->name_length == 19 && + if (auth->name_length == 19 && strcmp(auth->name, "XDM-AUTHORIZATION-1") == 0) { Debug ("Skipping IPv6 XDM-AUTHORIZATION-1\n"); continue; } } -#endif +# endif } Debug ("DefineSelf: write network address, length %d\n", len); writeAddr (family, len, addr, file, auth); } } -#else /* SIOCGIFCONF */ +# else /* SIOCGIFCONF */ -/* Define this host for access control. Find all the hosts the OS knows about +/* 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 void @@ -1085,7 +1085,7 @@ DefineSelf (int fd, int file, int auth) struct sockaddr sa; struct sockaddr_in in; } saddr; - + struct sockaddr_in *inetaddr; /* hpux: @@ -1108,10 +1108,10 @@ DefineSelf (int fd, int file, int auth) } } - -#endif /* SIOCGIFCONF else */ -#endif /* WINTCP else */ -#endif /* STREAMSCONN && !SYSV_SIOCGIFCONF else */ + +# endif /* SIOCGIFCONF else */ +# endif /* WINTCP else */ +# endif /* STREAMSCONN && !SYSV_SIOCGIFCONF else */ #endif /* HAS_GETIFADDRS */ static void @@ -1157,10 +1157,10 @@ writeLocalAuth (FILE *file, Xauth *auth, char *name) t_close (fd); #endif #ifdef TCPCONN -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) fd = socket (AF_INET6, SOCK_STREAM, 0); if (fd < 0) -#endif +# endif fd = socket (AF_INET, SOCK_STREAM, 0); DefineSelf (fd, file, auth); close (fd); @@ -1180,7 +1180,7 @@ writeRemoteAuth (FILE *file, Xauth *auth, XdmcpNetaddr peer, int peerlen, char * { int family = FamilyLocal; char *addr; - + Debug ("writeRemoteAuth: %s %.*s\n", name, auth->name_length, auth->name); if (!peer || peerlen < 2) return; @@ -1245,7 +1245,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) } if (new != NULL) (void) fclose (new); - } + } } } if (lockStatus != LOCK_SUCCESS) { @@ -37,29 +37,29 @@ in this Software without prior written authorization from The Open Group. #ifdef XDMCP -#include <X11/X.h> -#include <sys/types.h> +# include <X11/X.h> +# include <sys/types.h> -#include "dm_socket.h" -#include <arpa/inet.h> +# include "dm_socket.h" +# include <arpa/inet.h> -#ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif -#endif +# ifndef X_NO_SYS_UN +# ifndef Lynx +# include <sys/un.h> +# else +# include <un.h> +# endif +# endif -#include <ctype.h> -#include <errno.h> +# include <ctype.h> +# include <errno.h> -#if defined(STREAMSCONN) -# include <tiuser.h> -#endif +# if defined(STREAMSCONN) +# include <tiuser.h> +# endif -#include <time.h> -#define Time_t time_t +# include <time.h> +# define Time_t time_t static int FormatBytes ( @@ -200,35 +200,35 @@ FormatChooserArgument (char *buf, int len) netfamily = NetaddrFamily((XdmcpNetaddr)addr_buf); switch (netfamily) { case AF_INET: -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: -#endif +# endif { char *port; int portlen; ARRAY8Ptr localAddress = getLocalAddress (); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (localAddress->length == 16) netfamily = AF_INET6; else netfamily = AF_INET; -#endif +# endif port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen); result_buf[0] = netfamily >> 8; result_buf[1] = netfamily & 0xFF; result_buf[2] = port[0]; result_buf[3] = port[1]; - memmove( (char *)result_buf+4, (char *)localAddress->data, + memmove( (char *)result_buf+4, (char *)localAddress->data, localAddress->length); result_len = 4 + localAddress->length; } break; -#ifdef AF_DECnet +# ifdef AF_DECnet case AF_DECnet: break; -#endif +# endif default: Debug ("Chooser family %d isn't known\n", netfamily); return 0; @@ -293,24 +293,24 @@ RegisterIndirectChoice ( { ChoicePtr c; int insert; -#if 0 +# if 0 int found = 0; -#endif +# endif Debug ("Got indirect choice back\n"); for (c = choices; c; c = c->next) { if (XdmcpARRAY8Equal (clientAddress, &c->client) && connectionType == c->connectionType) { -#if 0 +# if 0 found = 1; -#endif +# endif break; } } -#if 0 +# if 0 if (!found) return 0; -#endif +# endif insert = 0; if (!c) @@ -345,7 +345,7 @@ RegisterIndirectChoice ( return 1; } -#ifdef notdef +# ifdef notdef static RemoveIndirectChoice (clientAddress, connectionType) ARRAY8Ptr clientAddress; @@ -371,7 +371,7 @@ RemoveIndirectChoice (clientAddress, connectionType) prev = c; } } -#endif +# endif /*ARGSUSED*/ static void @@ -389,13 +389,13 @@ AddChooserHost ( { *argp = parseArgs (*argp, "BROADCAST"); } -#if defined(IPv6) && defined(AF_INET6) - else if ( (addr->length == 16) && +# if defined(IPv6) && defined(AF_INET6) + else if ( (addr->length == 16) && (inet_ntop(AF_INET6, addr->data, hostbuf, sizeof(hostbuf)))) { *argp = parseArgs (*argp, hostbuf); } -#endif +# endif else if (ARRAY8ToDottedDecimal (addr, hostbuf, sizeof (hostbuf))) { *argp = parseArgs (*argp, hostbuf); @@ -412,14 +412,14 @@ ProcessChooserSocket (int fd) ARRAY8 clientAddress = {0, NULL}; CARD16 connectionType; ARRAY8 choice = {0, NULL}; -#if defined(STREAMSCONN) +# if defined(STREAMSCONN) struct t_call *call; int flags=0; -#endif +# endif Debug ("Process chooser socket\n"); len = sizeof (buf); -#if defined(STREAMSCONN) +# if defined(STREAMSCONN) call = (struct t_call *)t_alloc( fd, T_CALL, T_ALL ); if( call == NULL ) { @@ -459,21 +459,21 @@ ProcessChooserSocket (int fd) t_close (client_fd); return; } -#else +# else client_fd = accept (fd, (struct sockaddr *)buf, (void *)&len); if (client_fd == -1) { LogError ("Cannot accept chooser connection\n"); return; } -#endif +# endif Debug ("Accepted %d\n", client_fd); - -#if defined(STREAMSCONN) + +# if defined(STREAMSCONN) len = t_rcv (client_fd, buf, sizeof (buf),&flags); -#else +# else len = read (client_fd, buf, sizeof (buf)); -#endif +# endif Debug ("Read returns %d\n", len); if (len > 0) { @@ -503,13 +503,13 @@ ProcessChooserSocket (int fd) LogError ("Choice response read error: %s\n", strerror(errno)); } -#if defined(STREAMSCONN) +# if defined(STREAMSCONN) t_unbind (client_fd); t_free( (char *)call, T_CALL ); t_close (client_fd); -#else +# else close (client_fd); -#endif +# endif } void @@ -520,11 +520,11 @@ RunChooser (struct display *d) char **env; Debug ("RunChooser %s\n", d->name); -#ifndef HAS_SETPROCTITLE +# ifndef HAS_SETPROCTITLE SetTitle (d->name, "chooser", (char *) 0); -#else +# else setproctitle("chooser %s", d->name); -#endif +# endif LoadXloginResources (d); args = parseArgs ((char **) 0, d->chooser); strcpy (buf, "-xdmaddress "); @@ -69,21 +69,21 @@ in this Software without prior written authorization from The Open Group. #include <ctype.h> #ifdef USE_XINERAMA -#include <X11/extensions/Xinerama.h> +# include <X11/extensions/Xinerama.h> #endif #if defined(SVR4) -#include <sys/sockio.h> +# include <sys/sockio.h> #endif #if defined(SVR4) && defined(PowerMAX_OS) -#include <sys/stropts.h> +# 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 +# include <sys/stream.h> +# ifdef ISC +# include <sys/sioctl.h> +# include <sys/stropts.h> +# endif #endif #include "dm_socket.h" @@ -92,30 +92,30 @@ in this Software without prior written authorization from The Open Group. #include <sys/ioctl.h> #ifdef STREAMSCONN -#ifdef WINTCP /* NCR with Wollongong TCP */ -#include <netinet/ip.h> -#endif -#include <stropts.h> -#include <tiuser.h> -#include <netconfig.h> -#include <netdir.h> +# ifdef WINTCP /* NCR with Wollongong TCP */ +# include <netinet/ip.h> +# endif +# include <stropts.h> +# include <tiuser.h> +# include <netconfig.h> +# include <netdir.h> #endif #ifdef CSRG_BASED -#include <sys/param.h> -#if (BSD >= 199103) -#define VARIABLE_IFREQ -#endif +# include <sys/param.h> +# if (BSD >= 199103) +# define VARIABLE_IFREQ +# endif #endif #ifdef XKB -#include <X11/extensions/XKBbells.h> +# include <X11/extensions/XKBbells.h> #endif #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 @@ -124,11 +124,11 @@ in this Software without prior written authorization from The Open Group. # include <net/if.h> # endif #else -#ifdef __convex__ -# include <sync/queue.h> -# include <sync/sema.h> -#endif -#include <net/if.h> +# ifdef __convex__ +# include <sync/queue.h> +# include <sync/sema.h> +# endif +# include <net/if.h> #endif /* hpux */ #include <netdb.h> @@ -221,7 +221,7 @@ ifioctl (int fd, int cmd, char *arg) { ioc.ic_len = ((struct ifconf *) arg)->ifc_len; ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; -#ifdef ISC +# 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 @@ -231,7 +231,7 @@ ifioctl (int fd, int cmd, char *arg) */ ((struct ifconf *) ioc.ic_dp)->ifc_len = ioc.ic_len - sizeof(struct ifconf); -#endif +# endif } else { @@ -240,21 +240,21 @@ ifioctl (int fd, int cmd, char *arg) } ret = ioctl(fd, I_STR, (char *) &ioc); if (ret >= 0 && cmd == SIOCGIFCONF) -#ifdef SVR4 +# ifdef SVR4 ((struct ifconf *) arg)->ifc_len = ioc.ic_len; -#endif -#ifdef ISC +# endif +# ifdef ISC { ((struct ifconf *) arg)->ifc_len = ((struct ifconf *)ioc.ic_dp)->ifc_len; - ((struct ifconf *) arg)->ifc_buf = + ((struct ifconf *) arg)->ifc_buf = (caddr_t)((struct ifconf *)ioc.ic_dp)->ifc_req; } -#endif +# endif return(ret); } #else /* ((SVR4 && !sun && !NCR) || ISC) && SIOCGIFCONF */ -#define ifioctl ioctl +# define ifioctl ioctl #endif /* ((SVR4 && !sun) || ISC) && SIOCGIFCONF */ @@ -274,10 +274,10 @@ PingHosts (XtPointer closure, XtIntervalId *id) sfd = socketFD; #endif if (hosts->type == QUERY) - XdmcpFlush (sfd, &directBuffer, + XdmcpFlush (sfd, &directBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen); else - XdmcpFlush (sfd, &broadcastBuffer, + XdmcpFlush (sfd, &broadcastBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen); } if (++pingTry < TRIES) @@ -373,7 +373,7 @@ AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int wi { struct hostent *hostent; char *host; - + hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family); if (hostent) { @@ -571,11 +571,11 @@ RegisterHostaddr (struct sockaddr *addr, int len, xdmOpCode type) /* Handle variable length ifreq in BNR2 and later */ #ifdef VARIABLE_IFREQ -#define ifr_size(p) (sizeof (struct 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)) +# define ifr_size(p) (sizeof (struct ifreq)) #endif static void @@ -629,11 +629,11 @@ RegisterHostname (char *name) if (ifioctl (socketFD, (int) SIOCGIFCONF, (char *) &ifc) < 0) return; -#ifdef ISC -#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf -#else -#define IFC_IFC_REQ ifc.ifc_req -#endif +# ifdef ISC +# define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf +# else +# define IFC_IFC_REQ ifc.ifc_req +# endif cplim = (char *) IFC_IFC_REQ + ifc.ifc_len; @@ -652,33 +652,33 @@ RegisterHostname (char *name) #ifdef SIOCGIFBRDADDR { struct ifreq broad_req; - + broad_req = *ifr; -#ifdef WINTCP /* NCR with Wollongong TCP */ +# ifdef WINTCP /* NCR with Wollongong TCP */ ioc.ic_cmd = IPIOC_GETIFFLAGS; ioc.ic_timout = 0; ioc.ic_len = sizeof( broad_req ); ioc.ic_dp = (char *)&broad_req; if (ioctl (ipfd, I_STR, (char *) &ioc) != -1 && -#else /* WINTCP */ +# else /* WINTCP */ if (ifioctl (socketFD, SIOCGIFFLAGS, (char *) &broad_req) != -1 && -#endif /* WINTCP */ +# endif /* WINTCP */ (broad_req.ifr_flags & IFF_BROADCAST) && (broad_req.ifr_flags & IFF_UP) ) { broad_req = *ifr; -#ifdef WINTCP /* NCR with Wollongong TCP */ +# ifdef WINTCP /* NCR with Wollongong TCP */ ioc.ic_cmd = IPIOC_GETIFBRDADDR; ioc.ic_timout = 0; ioc.ic_len = sizeof( broad_req ); ioc.ic_dp = (char *)&broad_req; if (ioctl (ipfd, I_STR, (char *) &ioc) != -1) -#else /* WINTCP */ +# else /* WINTCP */ if (ifioctl (socketFD, SIOCGIFBRDADDR, &broad_req) != -1) -#endif /* WINTCP */ +# endif /* WINTCP */ broad_addr = broad_req.ifr_addr; else continue; @@ -719,20 +719,20 @@ RegisterHostname (char *name) snprintf(sport, sizeof(sport), "%d", XDM_UDP_PORT); if (getaddrinfo(name, sport, &hints, &ai) == 0) { for (nai = ai ; nai != NULL ; nai = nai->ai_next) { - if ((nai->ai_family == AF_INET) || + if ((nai->ai_family == AF_INET) || (nai->ai_family == AF_INET6)) { - if (((nai->ai_family == AF_INET) && + if (((nai->ai_family == AF_INET) && IN_MULTICAST(((struct sockaddr_in *) nai->ai_addr) ->sin_addr.s_addr)) - || ((nai->ai_family == AF_INET6) && + || ((nai->ai_family == AF_INET6) && IN6_IS_ADDR_MULTICAST( &((struct sockaddr_in6 *) nai->ai_addr) - ->sin6_addr))) + ->sin6_addr))) { - RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, + RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, BROADCAST_QUERY); } else { - RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, + RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, QUERY); } } @@ -755,9 +755,9 @@ RegisterHostname (char *name) memmove( &in_addr.sin_addr, hostent->h_addr, 4); } in_addr.sin_port = htons (XDM_UDP_PORT); -#ifdef BSD44SOCKETS +# ifdef BSD44SOCKETS in_addr.sin_len = sizeof(in_addr); -#endif +# endif RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr), QUERY); #endif /* IPv6 */ @@ -840,18 +840,18 @@ InitXDMCP (char **argv) #else if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0) return 0; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) socket6FD = socket (AF_INET6, SOCK_DGRAM, 0); -#endif +# endif #endif #ifndef STREAMSCONN -#ifdef SO_BROADCAST +# ifdef SO_BROADCAST soopts = 1; if (setsockopt (socketFD, SOL_SOCKET, SO_BROADCAST, (char *)&soopts, sizeof (soopts)) < 0) perror ("setsockopt"); +# endif #endif -#endif - + XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket, (XtPointer) &socketFD); #if defined(IPv6) && defined(AF_INET6) @@ -905,9 +905,9 @@ Choose (HostName *h) #if defined(IPv6) && defined(AF_INET6) case AF_INET6: bzero(&in6_addr, sizeof(in6_addr)); -#ifdef SIN6_LEN +# ifdef SIN6_LEN in6_addr.sin6_len = sizeof(in6_addr); -#endif +# endif in6_addr.sin6_family = family; memmove( &in6_addr.sin6_port, xdm + 2, 2); memmove( &in6_addr.sin6_addr, xdm + 4, 16); @@ -1000,7 +1000,7 @@ Choose (HostName *h) (0, 1, 2, 3, 0, 1, 2, 3 ....) */ -static int +static int next_line(unsigned int current, unsigned int size, int event) { switch(event) { @@ -1012,11 +1012,11 @@ next_line(unsigned int current, unsigned int size, int event) return (current + 1) % size; case XK_Up: return (current + size - 1) % size; - } + } return -1; } -/* +/* Hostselect selects a given chooser line. Returns 1 when host is willing and 0 if not */ @@ -1061,17 +1061,17 @@ Hostselect (int line) XawViewportSetCoordinates(viewport, 0, (liney + lineheight) - portheight); } - + XtFree((char *) r); return 1; } } } XtFree((char *) r); - return 0; + return 0; } -/* +/* Selectfirst selects the first willing host in the chooser list (so you can select a host without presence of mouse, but with pressing space or return, @@ -1082,12 +1082,12 @@ static void Selectfirst (void) { int line; - + for (line = 0; line < NameTableSize; line++) { if (Hostselect(line)) return; - } + } return; } @@ -1105,7 +1105,7 @@ Storeold (Widget w, XEvent *event, String *params, Cardinal *num_params) } /* - Setold restores the global int oldentry + Setold restores the global int oldentry when you try to select a host with your mouse who is unwilling as follows: <Btn1Down>: Store() Set() CheckWilling() Setold() \n\ @@ -1154,13 +1154,13 @@ Switch_Key (Widget w, XEvent *event, String *params, Cardinal *num_params) XawListReturnStruct *r; XLookupString (&event->xkey, strbuf, sizeof (strbuf), - &keysym, &compose_status); + &keysym, &compose_status); if (keysym != XK_Up && keysym != XK_Down) return; r = XawListShowCurrent (list); - + if (r->list_index == XAW_LIST_NONE) Selectfirst(); else @@ -1182,12 +1182,12 @@ Switch_Btn (Widget w, XEvent *event, String *params, Cardinal *num_params) { XawListReturnStruct *r; r = XawListShowCurrent (list); - + if (r->list_index == XAW_LIST_NONE) Selectfirst(); else HostCycle(r->list_index,NameTableSize,event->xbutton.button); - + XtFree((char *) r); return; } @@ -1225,7 +1225,7 @@ DoCheckWilling (Widget w, XEvent *event, String *params, Cardinal *num_params) { XawListReturnStruct *r; HostName *h; - + r = XawListShowCurrent (list); if (r->list_index != XAW_LIST_NONE) { for (h = hostNamedb; h; h = h->next) @@ -1260,7 +1260,7 @@ static XtActionsRec app_actions[] = { { "KeySwitch", Switch_Key }, { "BtnSwitch", Switch_Btn }, { "Store", Storeold }, - { "Setold", Setold }, + { "Setold", Setold }, }; int @@ -1309,7 +1309,7 @@ main (int argc, char **argv) { 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 @@ -33,46 +33,46 @@ from The Open Group. * display manager */ -# include "dm.h" -# include "dm_auth.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_auth.h" +#include "dm_error.h" -# include <stdio.h> +#include <stdio.h> #ifdef X_POSIX_C_SOURCE -#define _POSIX_C_SOURCE X_POSIX_C_SOURCE -#include <signal.h> -#undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE X_POSIX_C_SOURCE +# include <signal.h> +# undef _POSIX_C_SOURCE #else -#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) -#include <signal.h> -#else -#define _POSIX_SOURCE -#include <signal.h> -#undef _POSIX_SOURCE -#endif +# if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +# include <signal.h> +# else +# define _POSIX_SOURCE +# include <signal.h> +# undef _POSIX_SOURCE +# endif #endif #ifdef __NetBSD__ -#include <sys/param.h> +# include <sys/param.h> #endif #ifdef USESECUREWARE -#include <prot.h> +# include <prot.h> #endif #ifndef sigmask -#define sigmask(m) (1 << ((m - 1))) +# define sigmask(m) (1 << ((m - 1))) #endif -# include <sys/stat.h> -# include <errno.h> -# include <X11/Xfuncproto.h> -# include <X11/Xatom.h> -# include <stdarg.h> -# include <stdint.h> +#include <sys/stat.h> +#include <errno.h> +#include <X11/Xfuncproto.h> +#include <X11/Xatom.h> +#include <stdarg.h> +#include <stdint.h> #ifndef F_TLOCK -#ifndef X_NOT_POSIX -# include <unistd.h> -#endif +# ifndef X_NOT_POSIX +# include <unistd.h> +# endif #endif @@ -370,7 +370,7 @@ StopAll (int n) if (parent_pid != getpid()) { - /* + /* * We are a child xdm process that was killed by the * master xdm before we were able to return from fork() * and remove this signal handler. @@ -411,9 +411,9 @@ ChildNotify (int n) int olderrno = errno; ChildReady = 1; -#ifdef ISC +# ifdef ISC (void) Signal (SIGCHLD, ChildNotify); -#endif +# endif errno = olderrno; } #endif @@ -434,28 +434,28 @@ WaitForChild (void) /* XXX classic System V signal race condition here with RescanNotify */ if ((pid = wait (&status)) != -1) #else -#ifndef X_NOT_POSIX +# ifndef X_NOT_POSIX sigemptyset(&mask); sigaddset(&mask, SIGCHLD); sigaddset(&mask, SIGHUP); sigprocmask(SIG_BLOCK, &mask, &omask); Debug ("signals blocked\n"); -#else +# else omask = sigblock (sigmask (SIGCHLD) | sigmask (SIGHUP)); Debug ("signals blocked, mask was 0x%x\n", omask); -#endif +# endif if (!ChildReady && !Rescan) -#ifndef X_NOT_POSIX +# ifndef X_NOT_POSIX sigsuspend(&omask); -#else +# else sigpause (omask); -#endif +# endif ChildReady = 0; -#ifndef X_NOT_POSIX +# ifndef X_NOT_POSIX sigprocmask(SIG_SETMASK, &omask, (sigset_t *)NULL); -#else +# else sigsetmask (omask); -#endif +# endif while ((pid = waitpid (-1, &status, WNOHANG)) > 0) #endif { @@ -515,7 +515,7 @@ WaitForChild (void) Time_t Time; time(&Time); Debug("time %i %i\n",Time,d->lastCrash); - if (d->lastCrash && + if (d->lastCrash && ((Time - d->lastCrash) < XDM_BROKEN_INTERVAL)) { Debug("Server crash frequency too high:" " removing display %s\n",d->name); @@ -525,7 +525,7 @@ WaitForChild (void) AddTimerEntropy(); #endif RemoveDisplay (d); - } else + } else d->lastCrash = Time; } break; @@ -640,8 +640,8 @@ SetWindowPath(struct display *d) fprintf(stderr, "no XFree86_VT atom\n"); return; } - if (XGetWindowProperty(d->dpy, DefaultRootWindow(d->dpy), prop, 0, 1, - False, AnyPropertyType, &actualtype, &actualformat, + if (XGetWindowProperty(d->dpy, DefaultRootWindow(d->dpy), prop, 0, 1, + False, AnyPropertyType, &actualtype, &actualformat, &nitems, &bytes_after, &buf)) { fprintf(stderr, "no XFree86_VT property\n"); return; @@ -866,9 +866,9 @@ StorePid (void) if (lockPidFile) { #ifdef F_SETLK -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif +# ifndef SEEK_SET +# define SEEK_SET 0 +# endif struct flock lock_data; lock_data.l_type = F_WRLCK; lock_data.l_whence = SEEK_SET; @@ -881,7 +881,7 @@ StorePid (void) return -1; } #else -#ifdef LOCK_EX +# ifdef LOCK_EX if (flock (pidFd, LOCK_EX|LOCK_NB) == -1) { if (errno == EWOULDBLOCK) @@ -889,7 +889,7 @@ StorePid (void) else return -1; } -#else +# else if (lockf (pidFd, F_TLOCK, 0) == -1) { if (errno == EACCES) @@ -897,7 +897,7 @@ StorePid (void) else return -1; } -#endif +# endif #endif } fprintf (pidFilePtr, "%5ld\n", (long)getpid ()); @@ -912,7 +912,7 @@ void UnlockPidFile (void) { if (lockPidFile) -#ifdef F_SETLK +# ifdef F_SETLK { struct flock lock_data; lock_data.l_type = F_UNLCK; @@ -920,13 +920,13 @@ UnlockPidFile (void) lock_data.l_start = lock_data.l_len = 0; (void) fcntl(pidFd, F_SETLK, &lock_data); } -#else -#ifdef F_ULOCK +# else +# ifdef F_ULOCK lockf (pidFd, F_ULOCK, 0); -#else +# else flock (pidFd, LOCK_UN); -#endif -#endif +# endif +# endif close (pidFd); fclose (pidFilePtr); } @@ -935,7 +935,7 @@ UnlockPidFile (void) #ifndef HAS_SETPROCTITLE void SetTitle (char *name, ...) { -#ifndef NOXDMTITLE +# ifndef NOXDMTITLE char *p = Title; int left = TitleLen; char *s; @@ -960,6 +960,6 @@ void SetTitle (char *name, ...) --left; } va_end(args); -#endif +# endif } #endif @@ -36,104 +36,104 @@ from The Open Group. */ #ifndef _DM_H_ -#define _DM_H_ 1 - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <X11/Xos.h> -#include <X11/Xfuncs.h> -#include <X11/Xfuncproto.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 -#else -#include <setjmp.h> -#include <limits.h> -#endif -#include <time.h> -#define Time_t time_t +# define _DM_H_ 1 + +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif + +# include <X11/Xos.h> +# include <X11/Xfuncs.h> +# include <X11/Xfuncproto.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 +# else +# include <setjmp.h> +# include <limits.h> +# endif +# include <time.h> +# define Time_t time_t /* If XDMCP symbol defined, compile to run XDMCP protocol */ -#define XDMCP - -#ifdef XDMCP -#include <X11/Xdmcp.h> -#endif - -#ifdef pegasus -#undef dirty /* Some bozo put a macro called dirty in sys/param.h */ -#endif /* pegasus */ - -#ifndef X_NOT_POSIX -#ifdef _POSIX_SOURCE -#include <sys/wait.h> -#else -#define _POSIX_SOURCE -#ifdef __SCO__ -#include <sys/procset.h> -#include <sys/siginfo.h> -#endif -#include <sys/wait.h> -#undef _POSIX_SOURCE -#endif -# define waitCode(w) (WIFEXITED(w) ? WEXITSTATUS(w) : 0) -# define waitSig(w) (WIFSIGNALED(w) ? WTERMSIG(w) : 0) -# define waitCore(w) 0 /* not in POSIX. so what? */ +# define XDMCP + +# ifdef XDMCP +# include <X11/Xdmcp.h> +# endif + +# ifdef pegasus +# undef dirty /* Some bozo put a macro called dirty in sys/param.h */ +# endif /* pegasus */ + +# ifndef X_NOT_POSIX +# ifdef _POSIX_SOURCE +# include <sys/wait.h> +# else +# define _POSIX_SOURCE +# ifdef __SCO__ +# include <sys/procset.h> +# include <sys/siginfo.h> +# endif +# include <sys/wait.h> +# undef _POSIX_SOURCE +# endif +# define waitCode(w) (WIFEXITED(w) ? WEXITSTATUS(w) : 0) +# define waitSig(w) (WIFSIGNALED(w) ? WTERMSIG(w) : 0) +# define waitCore(w) 0 /* not in POSIX. so what? */ typedef int waitType; -#else /* X_NOT_POSIX */ -#ifdef SYSV -# define waitCode(w) (((w) >> 8) & 0x7f) -# define waitSig(w) ((w) & 0xff) -# define waitCore(w) (((w) >> 15) & 0x01) +# else /* X_NOT_POSIX */ +# ifdef SYSV +# define waitCode(w) (((w) >> 8) & 0x7f) +# define waitSig(w) ((w) & 0xff) +# define waitCore(w) (((w) >> 15) & 0x01) typedef int waitType; -#else /* SYSV */ -# include <sys/wait.h> -# define waitCode(w) ((w).w_T.w_Retcode) -# define waitSig(w) ((w).w_T.w_Termsig) -# define waitCore(w) ((w).w_T.w_Coredump) +# else /* SYSV */ +# include <sys/wait.h> +# define waitCode(w) ((w).w_T.w_Retcode) +# define waitSig(w) ((w).w_T.w_Termsig) +# define waitCore(w) ((w).w_T.w_Coredump) 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 +# 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)) typedef enum displayStatus { running, notRunning, zombie, phoenix } DisplayStatus; -#ifndef FD_ZERO +# ifndef FD_ZERO typedef struct my_fd_set { int fds_bits[1]; } my_fd_set; -# define FD_ZERO(fdp) bzero ((fdp), sizeof (*(fdp))) -# define FD_SET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] |= (1 << ((f) % (sizeof (int) * 8)))) -# define FD_CLR(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] &= ~(1 << ((f) % (sizeof (int) * 8)))) -# define FD_ISSET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] & (1 << ((f) % (sizeof (int) * 8)))) -# define FD_TYPE my_fd_set -#else -# define FD_TYPE fd_set -#endif +# define FD_ZERO(fdp) bzero ((fdp), sizeof (*(fdp))) +# define FD_SET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] |= (1 << ((f) % (sizeof (int) * 8)))) +# define FD_CLR(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] &= ~(1 << ((f) % (sizeof (int) * 8)))) +# define FD_ISSET(f,fdp) ((fdp)->fds_bits[(f) / (sizeof (int) * 8)] & (1 << ((f) % (sizeof (int) * 8)))) +# define FD_TYPE my_fd_set +# else +# define FD_TYPE fd_set +# endif /* * local - server runs on local host @@ -178,7 +178,7 @@ struct display { FileState state; /* state during HUP processing */ int startTries; /* current start try */ Time_t lastCrash; /* time of last crash */ -#ifdef XDMCP +# ifdef XDMCP /* XDMCP state */ CARD32 sessionID; /* ID of active session */ XdmcpNetaddr peer; /* display peer address */ @@ -190,7 +190,7 @@ struct display { ARRAY8 clientAddr; /* for chooser picking */ CARD16 connectionType; /* ... */ int xdmcpFd; -#endif +# endif /* server management resources */ int serverAttempts; /* number of attempts at running X */ int openDelay; /* open delay time */ @@ -244,10 +244,10 @@ struct display { char *windowPath; /* path to server "window" */ }; -#ifdef XDMCP +# ifdef XDMCP -#define PROTO_TIMEOUT (30 * 60) /* 30 minutes should be long enough */ -#define XDM_BROKEN_INTERVAL (120) /* server crashing more than once within */ +# 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; @@ -264,7 +264,7 @@ struct protoDisplay { ARRAY8 authenticationData; XdmAuthKeyRec key; }; -#endif /* XDMCP */ +# endif /* XDMCP */ struct greet_info { char *name; /* user name */ @@ -298,10 +298,10 @@ struct verify_info { # define RESERVER_DISPLAY 3 /* force server termination */ # define OPENFAILED_DISPLAY 4 /* XOpenDisplay failed, retry */ -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif +# ifndef TRUE +# define TRUE 1 +# define FALSE 0 +# endif extern char *config; @@ -318,11 +318,11 @@ extern int removeDomainname; extern char *keyFile; extern char *accessFile; extern char **exportList; -#if !defined(ARC4_RANDOM) +# if !defined(ARC4_RANDOM) extern char *randomFile; extern char *prngdSocket; extern int prngdPort; -#endif +# endif extern char *greeterLib; extern char *willing; @@ -378,9 +378,9 @@ extern void BecomeOrphan (void); extern void CloseOnFork (void); extern void RegisterCloseOnFork (int fd); extern void StartDisplay (struct display *d); -#ifndef HAS_SETPROCTITLE +# ifndef HAS_SETPROCTITLE extern void SetTitle (char *name, ...); -#endif +# endif /* in dpylist.c */ extern int AnyDisplaysLeft (void); @@ -398,9 +398,9 @@ extern int NetaddrFamily (XdmcpNetaddr netaddrp); extern int addressEqual (XdmcpNetaddr a1, int len1, XdmcpNetaddr a2, int len2); /* in policy.c */ -#if 0 +# if 0 extern ARRAY8Ptr Accept (/* struct sockaddr *from, int fromlen, CARD16 displayNumber */); -#endif +# 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); @@ -421,10 +421,10 @@ extern void LoadSessionResources (struct display *d); extern void ReinitResources (void); /* in session.c */ -#ifdef USE_PAM +# ifdef USE_PAM extern pam_handle_t **thepamhp(void); extern pam_handle_t *thepamh(void); -#endif +# endif extern char **defaultEnv (void); extern char **systemEnv (struct display *d, char *user, char *home); extern int PingServer(struct display *d, Display *alternateDpy); @@ -454,11 +454,11 @@ extern void CloseListenSockets (void); extern void ProcessListenSockets (fd_set *readmask); /* in util.c */ -#ifndef HAVE_ASPRINTF -# define asprintf Asprintf +# ifndef HAVE_ASPRINTF +# define asprintf Asprintf extern int Asprintf(char ** ret, const char *restrict format, ...) _X_ATTRIBUTE_PRINTF(2,3); -#endif +# endif extern char *localHostname (void); extern char **parseArgs (char **argv, char *string); extern char **setEnv (char **e, char *name, char *value); @@ -491,23 +491,23 @@ extern void ProcessRequestSocket(int fd); # define CLOSE_ALWAYS 0 # define LEAVE_FOR_DISPLAY 1 -#include <stdlib.h> - -#define SIGVAL RETSIGTYPE - -#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 -#define Setjmp(e) setjmp(e) -#define Longjmp(e,v) longjmp(e,v) -#define Jmp_buf jmp_buf -#else -#define Setjmp(e) sigsetjmp(e,1) -#define Longjmp(e,v) siglongjmp(e,v) -#define Jmp_buf sigjmp_buf -#endif +# include <stdlib.h> + +# define SIGVAL RETSIGTYPE + +# 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 +# define Setjmp(e) setjmp(e) +# define Longjmp(e,v) longjmp(e,v) +# define Jmp_buf jmp_buf +# else +# define Setjmp(e) sigsetjmp(e,1) +# define Longjmp(e,v) siglongjmp(e,v) +# define Jmp_buf sigjmp_buf +# endif typedef SIGVAL (*SIGFUNC)(int); @@ -17,7 +17,7 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE @@ -31,44 +31,44 @@ authorization. ********************************************************/ #ifndef _DM_AUTH_H_ -#define _DM_AUTH_H_ 1 +# define _DM_AUTH_H_ 1 -#include "dm.h" /* for struct display */ +# include "dm.h" /* for struct display */ extern void MitInitAuth (unsigned short name_len, char *name); extern Xauth *MitGetAuth (unsigned short namelen, char *name); -#ifdef HASXDMAUTH +# ifdef HASXDMAUTH extern void XdmInitAuth (unsigned short name_len, char *name); extern Xauth *XdmGetAuth (unsigned short namelen, char *name); -#ifdef XDMCP +# ifdef XDMCP extern void XdmGetXdmcpAuth ( struct protoDisplay *pdpy, unsigned short authorizationNameLen, char *authorizationName); -extern int XdmCheckAuthentication (struct protoDisplay *pdpy, - ARRAY8Ptr displayID, ARRAY8Ptr authenticationName, +extern int XdmCheckAuthentication (struct protoDisplay *pdpy, + ARRAY8Ptr displayID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData); -#else -#define XdmGetXdmcpAuth NULL -#endif -#endif +# else +# define XdmGetXdmcpAuth NULL +# endif +# endif -#ifdef SECURE_RPC +# ifdef SECURE_RPC extern void SecureRPCInitAuth (unsigned short name_len, char *name); extern Xauth *SecureRPCGetAuth (unsigned short namelen, char *name); -#endif +# endif -#ifdef K5AUTH +# ifdef K5AUTH extern void Krb5InitAuth (unsigned short name_len, char *name); extern Xauth *Krb5GetAuth (unsigned short namelen, char *name); -#endif +# endif /* auth.c */ extern int ValidAuthorization (unsigned short name_length, char *name); -#ifdef XDMCP +# ifdef XDMCP extern void SetProtoDisplayAuthorization ( @@ -76,7 +76,7 @@ SetProtoDisplayAuthorization ( unsigned short authorizationNameLen, char *authorizationName); -#endif /* XDMCP */ +# endif /* XDMCP */ extern int SaveServerAuthorizations (struct display *d, Xauth **auths, int count); extern void CleanUpFileName (char *src, char *dst, int len); @@ -87,11 +87,11 @@ extern void SetUserAuthorization (struct display *d, struct verify_info *verify) /* genauth.c */ extern int GenerateAuthData (char *auth, int len); -#if !defined(ARC4_RANDOM) +# if !defined(ARC4_RANDOM) extern void AddPreGetEntropy (void); extern void AddOtherEntropy (void); extern void AddTimerEntropy (void); -#endif +# endif /* prngc.c */ extern int get_prngd_bytes(char *, int, unsigned short, char *); @@ -32,13 +32,13 @@ authorization. #ifndef _DM_ERROR_H_ -#define _DM_ERROR_H_ 1 +# define _DM_ERROR_H_ 1 -#if defined(GCC_PRINTFLIKE) && defined(__GNUC__) -# define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) -#else -# define GCC_PRINTFLIKE(fmt,var) /*nothing*/ -#endif +# if defined(GCC_PRINTFLIKE) && defined(__GNUC__) +# define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) +# else +# define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +# endif extern void Debug (char * fmt, ...) GCC_PRINTFLIKE(1,2); extern void InitErrorLog (void); diff --git a/dm_socket.h b/dm_socket.h index 62889e7..b56882c 100644 --- a/dm_socket.h +++ b/dm_socket.h @@ -17,7 +17,7 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE @@ -31,17 +31,17 @@ authorization. ********************************************************/ #ifndef _DM_SOCKET_H_ -#define _DM_SOCKET_H_ 1 +# define _DM_SOCKET_H_ 1 -#include <X11/Xmd.h> -#include <X11/Xdmcp.h> +# include <X11/Xmd.h> +# include <X11/Xdmcp.h> -#ifndef Lynx -# include <sys/socket.h> -#else -# include <socket.h> -#endif -#include <netinet/in.h> +# ifndef Lynx +# include <sys/socket.h> +# else +# include <socket.h> +# endif +# include <netinet/in.h> /* ugly, but we need this after socket.h */ extern ARRAY8Ptr Accept (struct sockaddr *from, int fromlen, CARD16 displayNumber); @@ -33,8 +33,8 @@ from The Open Group. * a simple linked list of known displays */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" static struct display *displays; @@ -119,7 +119,7 @@ FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, CARD16 displayNumber) #endif /* XDMCP */ #define IfFree(x) if (x) free ((char *) x) - + void RemoveDisplay (struct display *old) { @@ -36,11 +36,11 @@ from The Open Group. * we generally do not have a terminal to talk to */ -# include <stdio.h> -# include <stdarg.h> +#include <stdio.h> +#include <stdarg.h> -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" #define WRITES(fd, buf) write(fd, buf, strlen(buf)) @@ -33,10 +33,10 @@ from The Open Group. * file.c */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" -# include <ctype.h> +#include <ctype.h> static int DisplayTypeMatch (DisplayType d1, DisplayType d2) @@ -214,7 +214,7 @@ ParseDisplay (char *source, DisplayType *acceptableTypes, int numAcceptable) else { d = NewDisplay (name, class); - Debug ("Found new display: %s %s %s", + Debug ("Found new display: %s %s %s", d->name, d->class ? d->class : "", type); } d->displayType = displayType; @@ -31,12 +31,12 @@ from The Open Group. * Author: Keith Packard, MIT X Consortium */ -# include <X11/Xauth.h> -# include <X11/Xos.h> +#include <X11/Xauth.h> +#include <X11/Xos.h> -# include "dm.h" -# include "dm_auth.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_auth.h" +#include "dm_error.h" #include <errno.h> @@ -58,7 +58,7 @@ typedef unsigned char auth_cblock[8]; /* block size */ typedef struct auth_ks_struct { auth_cblock _; } auth_wrapper_schedule[16]; extern int _XdmcpAuthSetup(unsigned char *, auth_wrapper_schedule); -extern int _XdmcpAuthDoIt(unsigned char *, unsigned char *, +extern int _XdmcpAuthDoIt(unsigned char *, unsigned char *, auth_wrapper_schedule, int); extern void _XdmcpWrapperToOddParity(unsigned char *, unsigned char *); @@ -74,7 +74,7 @@ longtochars (long l, unsigned char *c) #endif #ifdef POLL_DEV_RANDOM -#include <poll.h> +# include <poll.h> static int pollRandomDevice (int fd) { @@ -86,7 +86,7 @@ pollRandomDevice (int fd) return poll(&fds, 1, 5000); } #else -#define pollRandomDevice(fd) 1 +# define pollRandomDevice(fd) 1 #endif #if !defined(ARC4_RANDOM) @@ -163,20 +163,20 @@ add_entropy (const CARD32 *in, int nwords) */ /* The four core functions - F1 is optimized somewhat */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1 (z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) +# define F1(x, y, z) (z ^ (x & (y ^ z))) +# define F2(x, y, z) F1 (z, x, y) +# define F3(x, y, z) (x ^ y ^ z) +# define F4(x, y, z) (y ^ (x | ~z)) /* This is the central step in the MD5 algorithm. */ -#define pmd5_step(f, w, x, y, z, data, s) \ +# define pmd5_step(f, w, x, y, z, data, s) \ ( w += (f(x, y, z) + data) & 0xffffffff, w = w<<s | w>>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to * reflect the addition of 16 longwords of new data. */ -static void +static void pmd5_hash (CARD32 *out, const CARD32 in[16]) { CARD32 a, b, c, d; @@ -202,7 +202,7 @@ pmd5_hash (CARD32 *out, const CARD32 in[16]) pmd5_step(F1, d, a, b, c, in[13] + 0xfd987193, 12); pmd5_step(F1, c, d, a, b, in[14] + 0xa679438e, 17); pmd5_step(F1, b, c, d, a, in[15] + 0x49b40821, 22); - + pmd5_step(F2, a, b, c, d, in[1] + 0xf61e2562, 5); pmd5_step(F2, d, a, b, c, in[6] + 0xc040b340, 9); pmd5_step(F2, c, d, a, b, in[11] + 0x265e5a51, 14); @@ -219,7 +219,7 @@ pmd5_hash (CARD32 *out, const CARD32 in[16]) pmd5_step(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); pmd5_step(F2, c, d, a, b, in[7] + 0x676f02d9, 14); pmd5_step(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - + pmd5_step(F3, a, b, c, d, in[5] + 0xfffa3942, 4); pmd5_step(F3, d, a, b, c, in[8] + 0x8771f681, 11); pmd5_step(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); @@ -236,7 +236,7 @@ pmd5_hash (CARD32 *out, const CARD32 in[16]) pmd5_step(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); pmd5_step(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); pmd5_step(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - + pmd5_step(F4, a, b, c, d, in[0] + 0xf4292244, 6); pmd5_step(F4, d, a, b, c, in[7] + 0x432aff97, 10); pmd5_step(F4, c, d, a, b, in[14] + 0xab9423a7, 15); @@ -279,7 +279,7 @@ sumFile (const char *name, int len, int whence, off_t offset) break; if (cnt < 0) { close (fd); - Debug("cannot read entropy source \"%s\", errno=%d\n", + Debug("cannot read entropy source \"%s\", errno=%d\n", name, errno); return -1; } @@ -299,7 +299,7 @@ AddTimerEntropy (void) add_entropy((CARD32 *)&now, sizeof(now)/sizeof(CARD32)); } -#define BSIZ 0x10000 +# define BSIZ 0x10000 void AddOtherEntropy (void) @@ -322,14 +322,14 @@ AddPreGetEntropy (void) AddTimerEntropy(); if ((readlen = sumFile (randomFile, BSIZ, SEEK_SET, offset)) == BSIZ) { offset += readlen; -#ifdef FRAGILE_DEV_MEM +# ifdef FRAGILE_DEV_MEM if (!strcmp (randomFile, "/dev/mem")) { if (offset == 0xa0000) /* skip 640kB-1MB ROM mappings */ offset = 0x100000; else if (offset == 0xf00000) /* skip 15-16MB memory hole */ offset = 0x1000000; } -#endif +# endif return; } else if (readlen >= 0 && offset) { if ((offset = sumFile (randomFile, BSIZ, SEEK_SET, 0)) == BSIZ) @@ -346,35 +346,35 @@ InitXdmcpWrapper (void) { CARD32 sum[4]; -#ifdef ARC4_RANDOM +# ifdef ARC4_RANDOM sum[0] = arc4random(); sum[1] = arc4random(); *(u_char *)sum = 0; _XdmcpWrapperToOddParity((unsigned char *)sum, key); -#else +# else unsigned char tmpkey[8]; -#ifdef DEV_RANDOM +# ifdef DEV_RANDOM int fd; - + if ((fd = open(randomDevice, O_RDONLY)) >= 0) { if (pollRandomDevice(fd) && read(fd, tmpkey, 8) == 8) { tmpkey[0] = 0; _XdmcpWrapperToOddParity(tmpkey, key); close(fd); - return; + return; } else { close(fd); } } else { - LogError("Cannot open randomDevice \"%s\", errno = %d\n", + LogError("Cannot open randomDevice \"%s\", errno = %d\n", randomDevice, errno); } -#endif +# endif /* Try some pseudo-random number genrator daemon next */ if (prngdSocket != NULL || prngdPort != 0) { - if (get_prngd_bytes((char *)tmpkey, sizeof(tmpkey), prngdPort, + if (get_prngd_bytes((char *)tmpkey, sizeof(tmpkey), prngdPort, prngdSocket) == 0) { tmpkey[0] = 0; _XdmcpWrapperToOddParity(tmpkey, key); @@ -392,7 +392,7 @@ InitXdmcpWrapper (void) longtochars (sum[1], tmpkey+4); tmpkey[0] = 0; _XdmcpWrapperToOddParity (tmpkey, key); -#endif +# endif } #endif @@ -408,17 +408,17 @@ GenerateAuthData (char *auth, int len) static int xdmcpAuthInited; long ldata[2]; -#ifdef ITIMER_REAL +# ifdef ITIMER_REAL struct timeval now; X_GETTIMEOFDAY (&now); ldata[0] = now.tv_usec; ldata[1] = now.tv_sec; -#else +# else ldata[0] = time ((long *) 0); ldata[1] = getpid (); -#endif - +# endif + longtochars (ldata[0], data+0); longtochars (ldata[1], data+4); if (!xdmcpAuthInited) @@ -437,20 +437,20 @@ GenerateAuthData (char *auth, int len) } return 1; #else /* !XDMAUTH */ -#ifdef ARC4_RANDOM +# ifdef ARC4_RANDOM CARD32 *rnd = (CARD32 *)auth; int i; for (i = 0; i < len; i += 4) rnd[i / 4] = arc4random(); return 1; -#else /* !ARC4_RANDOM */ +# else /* !ARC4_RANDOM */ CARD32 tmp[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; -#ifdef DEV_RANDOM +# ifdef DEV_RANDOM int fd; - + if ((fd = open(randomDevice, O_RDONLY)) >= 0) { - if (pollRandomDevice(fd) && + if (pollRandomDevice(fd) && read(fd, auth, len) == len) { close(fd); return 1; @@ -458,10 +458,10 @@ GenerateAuthData (char *auth, int len) close(fd); LogError("Cannot read randomDevice \"%s\", errno=%d\n", randomDevice, errno); - } else - LogError("Cannot open randomDevice \"%s\", errno = %d\n", + } else + LogError("Cannot open randomDevice \"%s\", errno = %d\n", randomDevice, errno); -#endif /* DEV_RANDOM */ +# endif /* DEV_RANDOM */ /* Try some pseudo-random number genrator daemon next */ if (prngdSocket != NULL || prngdPort != 0) { if (get_prngd_bytes(auth, len, prngdPort, prngdSocket) == 0) { @@ -476,6 +476,6 @@ GenerateAuthData (char *auth, int len) add_entropy (tmp + 2, 1); memcpy (auth, tmp, len); return 1; -#endif /* !ARC4_RANDOM */ +# endif /* !ARC4_RANDOM */ #endif /* !HASXDMAUTH */ } @@ -36,19 +36,19 @@ from The Open Group. * Do this rather than break a build over a const-mismatch */ #if defined(__linux__) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4)) -#define CRYPT_ARGS const char *s1, const char *s2 -#define GETSPNAM_ARGS const char *name -#define GETPWNAM_ARGS const char *name +# 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*/ +# define CRYPT_ARGS /*unknown*/ +# define GETSPNAM_ARGS /*unknown*/ +# define GETPWNAM_ARGS /*unknown*/ #endif #if defined(__FreeBSD__) || defined(__bsdi__) || defined(__osf__) -#define SETGRENT_TYPE int +# define SETGRENT_TYPE int #else -#define SETGRENT_TYPE void +# define SETGRENT_TYPE void #endif struct dlfuncs { @@ -106,15 +106,15 @@ typedef enum { * GreetUser can either handle the user's session or allow xdm to do it. * The return or exit status of GreetUser indicates to xdm whether it * should start a session. - * + * * GreetUser is passed the xdm struct display pointer, a pointer to a * Display, and pointers to greet and verify structs. If it expectes xdm * to run the session, it fills in the Display pointer and the fields * of the greet and verify structs. - * + * * The verify struct includes the uid, gid, arguments to run the session, * environment for the session, and environment for startup/reset. - * + * * The greet struct includes the user's name and password but these are * really only needed if xdm is compiled with a user-based authorization * option such as SECURE_RPC or K5AUTH. @@ -158,61 +158,61 @@ extern void (*__xdm_LogOutOfMem)(char * fmt, ...); extern void (*__xdm_setgrent)(void); extern struct group *(*__xdm_getgrent)(void); extern void (*__xdm_endgrent)(void); -#ifdef USESHADOW +# ifdef USESHADOW extern struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS); -# ifndef QNX4 +# ifndef QNX4 extern void (*__xdm_endspent)(void); -# endif /* QNX4 doesn't use endspent */ -#endif +# endif /* QNX4 doesn't use endspent */ +# endif extern struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS); -#if defined(linux) || defined(__GLIBC__) +# if defined(linux) || defined(__GLIBC__) extern void (*__xdm_endpwent)(void); -#endif +# endif extern char *(*__xdm_crypt)(CRYPT_ARGS); -#ifdef USE_PAM +# ifdef USE_PAM extern pam_handle_t **(*__xdm_thepamhp)(void); -#endif +# endif /* * Force the shared library to call through the function pointer * initialized during the initial call into the library. */ -#define PingServer (*__xdm_PingServer) -#define SessionPingFailed (*__xdm_SessionPingFailed) -#define Debug (*__xdm_Debug) -#define RegisterCloseOnFork (*__xdm_RegisterCloseOnFork) -#define SecureDisplay (*__xdm_SecureDisplay) -#define UnsecureDisplay (*__xdm_UnsecureDisplay) -#define ClearCloseOnFork (*__xdm_ClearCloseOnFork) -#define SetupDisplay (*__xdm_SetupDisplay) -#define LogError (*__xdm_LogError) -#define SessionExit (*__xdm_SessionExit) -#define DeleteXloginResources (*__xdm_DeleteXloginResources) -#define source (*__xdm_source) -#define defaultEnv (*__xdm_defaultEnv) -#define setEnv (*__xdm_setEnv) -#define putEnv (*__xdm_putEnv) -#define parseArgs (*__xdm_parseArgs) -#define printEnv (*__xdm_printEnv) -#define systemEnv (*__xdm_systemEnv) -#define LogOutOfMem (*__xdm_LogOutOfMem) -#define setgrent (*__xdm_setgrent) -#define getgrent (*__xdm_getgrent) -#define endgrent (*__xdm_endgrent) -#ifdef USESHADOW -# define getspnam (*__xdm_getspnam) -# ifndef QNX4 -# define endspent (*__xdm_endspent) -# endif /* QNX4 doesn't use endspent */ -#endif -#define getpwnam (*__xdm_getpwnam) -#if defined(linux) || defined(__GLIBC__) -# define endpwent (*__xdm_endpwent) -#endif -#define crypt (*__xdm_crypt) -#ifdef USE_PAM -# define thepamhp (*__xdm_thepamhp) -#endif +# define PingServer (*__xdm_PingServer) +# define SessionPingFailed (*__xdm_SessionPingFailed) +# define Debug (*__xdm_Debug) +# define RegisterCloseOnFork (*__xdm_RegisterCloseOnFork) +# define SecureDisplay (*__xdm_SecureDisplay) +# define UnsecureDisplay (*__xdm_UnsecureDisplay) +# define ClearCloseOnFork (*__xdm_ClearCloseOnFork) +# define SetupDisplay (*__xdm_SetupDisplay) +# define LogError (*__xdm_LogError) +# define SessionExit (*__xdm_SessionExit) +# define DeleteXloginResources (*__xdm_DeleteXloginResources) +# define source (*__xdm_source) +# define defaultEnv (*__xdm_defaultEnv) +# define setEnv (*__xdm_setEnv) +# define putEnv (*__xdm_putEnv) +# define parseArgs (*__xdm_parseArgs) +# define printEnv (*__xdm_printEnv) +# define systemEnv (*__xdm_systemEnv) +# define LogOutOfMem (*__xdm_LogOutOfMem) +# define setgrent (*__xdm_setgrent) +# define getgrent (*__xdm_getgrent) +# define endgrent (*__xdm_endgrent) +# ifdef USESHADOW +# define getspnam (*__xdm_getspnam) +# ifndef QNX4 +# define endspent (*__xdm_endspent) +# endif /* QNX4 doesn't use endspent */ +# endif +# define getpwnam (*__xdm_getpwnam) +# if defined(linux) || defined(__GLIBC__) +# define endpwent (*__xdm_endpwent) +# endif +# define crypt (*__xdm_crypt) +# ifdef USE_PAM +# define thepamhp (*__xdm_thepamhp) +# endif #endif /* GREET_LIB */ diff --git a/greeter/Login.c b/greeter/Login.c index 67a3d42..4903ea2 100644 --- a/greeter/Login.c +++ b/greeter/Login.c @@ -61,34 +61,34 @@ from The Open Group. * Login.c */ -# include <X11/IntrinsicP.h> -# include <X11/StringDefs.h> -# include <X11/keysym.h> -# include <X11/DECkeysym.h> -# include <X11/Xfuncs.h> - -# include <stdio.h> -# include <ctype.h> -# include <time.h> -# include <string.h> - -# include "dm.h" -# include "dm_error.h" -# include "greet.h" -# include "LoginP.h" +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/keysym.h> +#include <X11/DECkeysym.h> +#include <X11/Xfuncs.h> + +#include <stdio.h> +#include <ctype.h> +#include <time.h> +#include <string.h> + +#include "dm.h" +#include "dm_error.h" +#include "greet.h" +#include "LoginP.h" #ifdef XPM -#include <sys/stat.h> -#include <unistd.h> -#include <X11/Xlib.h> -#include <X11/xpm.h> -#include <X11/extensions/shape.h> +# include <sys/stat.h> +# include <unistd.h> +# include <X11/Xlib.h> +# include <X11/xpm.h> +# include <X11/extensions/shape.h> #endif /* XPM */ #include <X11/cursorfont.h> #ifdef USE_XINERAMA -#include <X11/extensions/Xinerama.h> +# include <X11/extensions/Xinerama.h> #endif #ifndef DEBUG @@ -123,7 +123,7 @@ static XtResource resources[] = { goffset(x), XtRImmediate, (XtPointer) -1}, {XtNy, XtCY, XtRPosition, sizeof (Position), goffset(y), XtRImmediate, (XtPointer) -1}, -#ifndef USE_XFT +#ifndef USE_XFT {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(textpixel), XtRString, XtDefaultForeground}, {XtNpromptColor, XtCForeground, XtRPixel, sizeof(Pixel), @@ -141,7 +141,7 @@ static XtResource resources[] = { /* end (caolan) */ #endif /* DANCING */ -#ifdef XPM +#ifdef XPM /* added by Ivan Griffin (ivan.griffin@ul.ie) */ {XtNlogoFileName, XtCLogoFileName, XtRString, sizeof(char*), offset(logoFileName), XtRImmediate, (XtPointer)0}, @@ -165,7 +165,7 @@ static XtResource resources[] = { offset(sepwidth), XtRImmediate, (XtPointer) 1}, /* end (amit) */ -#ifndef USE_XFT +#ifndef USE_XFT {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), offset (textFont), XtRString, "*-new century schoolbook-medium-r-normal-*-180-*"}, {XtNpromptFont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), @@ -240,33 +240,33 @@ static XtResource resources[] = { # define F_DESCENT(f) ((w)->login.f##Font->max_bounds.descent) #endif -# define TEXT_X_INC(w) F_MAX_WIDTH(text) -# define TEXT_Y_INC(w) (F_ASCENT(text) + F_DESCENT(text)) +#define TEXT_X_INC(w) F_MAX_WIDTH(text) +#define TEXT_Y_INC(w) (F_ASCENT(text) + F_DESCENT(text)) -# define PROMPT_X_INC(w) F_MAX_WIDTH(prompt) -# define PROMPT_Y_INC(w) (F_ASCENT(prompt) + F_DESCENT(prompt)) +#define PROMPT_X_INC(w) F_MAX_WIDTH(prompt) +#define PROMPT_Y_INC(w) (F_ASCENT(prompt) + F_DESCENT(prompt)) -# define GREET_X_INC(w) F_MAX_WIDTH(greet) -# define GREET_Y_INC(w) (F_ASCENT(greet) + F_DESCENT(greet)) +#define GREET_X_INC(w) F_MAX_WIDTH(greet) +#define GREET_Y_INC(w) (F_ASCENT(greet) + F_DESCENT(greet)) -# define FAIL_X_INC(w) F_MAX_WIDTH(fail) -# define FAIL_Y_INC(w) (F_ASCENT(fail) + F_DESCENT(fail)) +#define FAIL_X_INC(w) F_MAX_WIDTH(fail) +#define FAIL_Y_INC(w) (F_ASCENT(fail) + F_DESCENT(fail)) -# define Y_INC(w) max (TEXT_Y_INC(w), PROMPT_Y_INC(w)) +#define Y_INC(w) max (TEXT_Y_INC(w), PROMPT_Y_INC(w)) -# define PROMPT_TEXT(w,n) ((w)->login.prompts[n].promptText) -# define DEF_PROMPT_TEXT(w,n) ((w)->login.prompts[n].defaultPrompt) -# define VALUE_TEXT(w,n) ((w)->login.prompts[n].valueText) -# define VALUE_TEXT_MAX(w,n) ((w)->login.prompts[n].valueTextMax) -# define VALUE_SHOW_START(w,n) ((w)->login.prompts[n].valueShownStart) -# define VALUE_SHOW_END(w,n) ((w)->login.prompts[n].valueShownEnd) -# define PROMPT_STATE(w,n) ((w)->login.prompts[n].state) -# define PROMPT_CURSOR(w,n) ((w)->login.prompts[n].cursor) +#define PROMPT_TEXT(w,n) ((w)->login.prompts[n].promptText) +#define DEF_PROMPT_TEXT(w,n) ((w)->login.prompts[n].defaultPrompt) +#define VALUE_TEXT(w,n) ((w)->login.prompts[n].valueText) +#define VALUE_TEXT_MAX(w,n) ((w)->login.prompts[n].valueTextMax) +#define VALUE_SHOW_START(w,n) ((w)->login.prompts[n].valueShownStart) +#define VALUE_SHOW_END(w,n) ((w)->login.prompts[n].valueShownEnd) +#define PROMPT_STATE(w,n) ((w)->login.prompts[n].state) +#define PROMPT_CURSOR(w,n) ((w)->login.prompts[n].cursor) -# define CUR_PROMPT_CURSOR(w) PROMPT_CURSOR(w,w->login.activePrompt) +#define CUR_PROMPT_CURSOR(w) PROMPT_CURSOR(w,w->login.activePrompt) -# define CUR_PROMPT_TEXT(w, n) (PROMPT_TEXT(w,n) != NULL ? \ +#define CUR_PROMPT_TEXT(w, n) (PROMPT_TEXT(w,n) != NULL ? \ PROMPT_TEXT(w,n) : DEF_PROMPT_TEXT(w,n)) #ifdef USE_XFT @@ -295,23 +295,23 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len); #endif -# define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s)) +#define STRING_WIDTH(f, s) TEXT_WIDTH (f, s, strlen(s)) -# define TEXT_PROMPT_W(w, m) (STRING_WIDTH(prompt, m) + w->login.inframeswidth) +#define TEXT_PROMPT_W(w, m) (STRING_WIDTH(prompt, m) + w->login.inframeswidth) -# define DEF_PROMPT_W(w,n) TEXT_PROMPT_W(w, w->login.prompts[n].defaultPrompt) -# define CUR_PROMPT_W(w,n) (max(MAX_DEF_PROMPT_W(w), PROMPT_TEXT(w,n) ? \ +#define DEF_PROMPT_W(w,n) TEXT_PROMPT_W(w, w->login.prompts[n].defaultPrompt) +#define CUR_PROMPT_W(w,n) (max(MAX_DEF_PROMPT_W(w), PROMPT_TEXT(w,n) ? \ TEXT_PROMPT_W(w, PROMPT_TEXT(w,n)) : 0)) -# define MAX_DEF_PROMPT_W(w) (max(DEF_PROMPT_W(w,0), DEF_PROMPT_W(w,1))) +#define MAX_DEF_PROMPT_W(w) (max(DEF_PROMPT_W(w,0), DEF_PROMPT_W(w,1))) -# define GREETING(w) ((w)->login.secure_session && !(w)->login.allow_access ?\ +#define GREETING(w) ((w)->login.secure_session && !(w)->login.allow_access ?\ (w)->login.greeting : (w)->login.unsecure_greet) -# define GREET_X(w) ((int)((w->core.width - \ +#define GREET_X(w) ((int)((w->core.width - \ STRING_WIDTH (greet, GREETING(w))) / 2)) -# define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0) +#define GREET_Y(w) (GREETING(w)[0] ? 2 * GREET_Y_INC (w) : 0) #ifndef XPM # define GREET_W(w) (max (STRING_WIDTH (greet, w->login.greeting), \ STRING_WIDTH (greet, w->login.unsecure_greet))) @@ -320,18 +320,18 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len); STRING_WIDTH (greet, w->login.unsecure_greet)) \ + w->login.logoWidth + (2*w->login.logoPadding)) #endif /* XPM */ -# define PROMPT_X(w) (2 * PROMPT_X_INC(w)) -# define PROMPT_Y(w,n) ((GREET_Y(w) + GREET_Y_INC(w) +\ +#define PROMPT_X(w) (2 * PROMPT_X_INC(w)) +#define PROMPT_Y(w,n) ((GREET_Y(w) + GREET_Y_INC(w) +\ F_ASCENT(greet) + Y_INC(w)) + \ (n * PROMPT_SPACE_Y(w))) -# define PROMPT_W(w) (w->core.width - (2 * TEXT_X_INC(w))) -# define PROMPT_H(w) (3 * Y_INC(w) / 2) -# define VALUE_X(w,n) (PROMPT_X(w) + CUR_PROMPT_W(w,n)) -# define PROMPT_SPACE_Y(w) (10 * Y_INC(w) / 5) +#define PROMPT_W(w) (w->core.width - (2 * TEXT_X_INC(w))) +#define PROMPT_H(w) (3 * Y_INC(w) / 2) +#define VALUE_X(w,n) (PROMPT_X(w) + CUR_PROMPT_W(w,n)) +#define PROMPT_SPACE_Y(w) (10 * Y_INC(w) / 5) -# define ERROR_X(w,m) ((int)(w->core.width - STRING_WIDTH (fail, m)) / 2) -# define FAIL_X(w) ERROR_X(w, w->login.fail) -# define FAIL_Y(w) (PROMPT_Y(w,1) + 2 * FAIL_Y_INC (w) + F_ASCENT(fail)) +#define ERROR_X(w,m) ((int)(w->core.width - STRING_WIDTH (fail, m)) / 2) +#define FAIL_X(w) ERROR_X(w, w->login.fail) +#define FAIL_Y(w) (PROMPT_Y(w,1) + 2 * FAIL_Y_INC (w) + F_ASCENT(fail)) #ifndef XPM # define ERROR_W(w,m) STRING_WIDTH (fail, m) @@ -340,14 +340,14 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len); + w->login.logoWidth + (2*w->login.logoPadding)) #endif /* XPM */ -# define FAIL_W(w) max(ERROR_W(w, w->login.failMsg), \ +#define FAIL_W(w) max(ERROR_W(w, w->login.failMsg), \ ERROR_W(w, w->login.passwdChangeMsg)) -# define PAD_X(w) (2 * (PROMPT_X(w) + max (GREET_X_INC(w), FAIL_X_INC(w)))) +#define PAD_X(w) (2 * (PROMPT_X(w) + max (GREET_X_INC(w), FAIL_X_INC(w)))) -# define PAD_Y(w) (max (max (Y_INC(w), GREET_Y_INC(w)),\ +#define PAD_Y(w) (max (max (Y_INC(w), GREET_Y_INC(w)),\ FAIL_Y_INC(w))) - + #ifndef max static inline int max (int a, int b) { return a > b ? a : b; } #endif @@ -388,7 +388,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc) int textwidth; int offset = max(cursor, VALUE_SHOW_START(w, promptNum)); int textlen = strlen (text + offset); - + textwidth = TEXT_WIDTH (text, text + offset, textlen); if (textwidth > (width - curoff)) { @@ -403,7 +403,7 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc) } textlen--; textwidth = TEXT_WIDTH (text, text + offset, textlen); - } + } VALUE_SHOW_START(w, promptNum) = offset; VALUE_SHOW_END(w, promptNum) = offset + textlen; @@ -445,7 +445,7 @@ realizeCursor (LoginWidget w, GC gc) if (w->login.state != PROMPTING) { return; } - + x = VALUE_X (w, w->login.activePrompt); y = PROMPT_Y (w, w->login.activePrompt); height = (F_ASCENT(text) + F_DESCENT(text)); @@ -470,7 +470,7 @@ realizeCursor (LoginWidget w, GC gc) x += PROMPT_CURSOR(w, w->login.activePrompt); break; } - + XFillRectangle (XtDisplay (w), XtWindow (w), gc, x, y+1 - F_ASCENT(text), width, height-1); XDrawPoint (XtDisplay (w), XtWindow (w), gc, @@ -490,23 +490,23 @@ realizeCursor (LoginWidget w, GC gc) XDrawPoint (XtDisplay (w), XtWindow (w), gc, x+2 , y - F_ASCENT(text)+height); - XFlush (XtDisplay(w)); + XFlush (XtDisplay(w)); } static void EraseFail (LoginWidget w) { -#ifdef USE_XFT +#ifdef USE_XFT w->login.failUp = 0; RedrawFail(w); -#else +#else XSetForeground (XtDisplay (w), w->login.failGC, w->core.background_pixel); RedrawFail(w); w->login.failUp = 0; XSetForeground (XtDisplay (w), w->login.failGC, TEXT_COLOR(fail)); -#endif +#endif } static void @@ -558,9 +558,9 @@ RedrawFail (LoginWidget w) int y = FAIL_Y(w); int maxw = w->core.width - PAD_X(w); -#ifndef USE_XFT +#ifndef USE_XFT if (w->login.failUp) -#endif +#endif { Debug("RedrawFail('%s', %d)\n", w->login.fail, w->login.failUp); if (ERROR_W(w, w->login.fail) > maxw) { @@ -571,7 +571,7 @@ RedrawFail (LoginWidget w) char lastspace = ' '; y = PROMPT_Y(w,LAST_PROMPT) + (2 * PROMPT_Y_INC(w)); - + for (start = next = tempCopy; start != NULL ; start = next) { /* search for longest string broken by whitespace that will fit on a single line */ @@ -591,14 +591,14 @@ RedrawFail (LoginWidget w) next = NULL; } } while ((next != NULL) && ERROR_W(w, start) < maxw); - + x = ERROR_X(w, start); #ifdef USE_XFT if (w->login.failUp == 0) { XClearArea(XtDisplay(w), XtWindow(w), x, y, ERROR_W(w, start), FAIL_Y_INC(w), False); } else -#endif +#endif DRAW_STRING (fail, x, y, start, strlen(start)); if (next != NULL) { @@ -619,7 +619,7 @@ RedrawFail (LoginWidget w) XClearArea(XtDisplay(w), XtWindow(w), x, y, ERROR_W(w, w->login.fail), FAIL_Y_INC(w), False); } else -#endif +#endif DRAW_STRING (fail, x, y, w->login.fail, strlen (w->login.fail)); } } @@ -683,7 +683,7 @@ draw_it (LoginWidget w) XDrawLine(XtDisplay (w), XtWindow (w), w->login.shdGC, i-1,w->core.height-i,w->core.width-i,w->core.height-i); } - + /* make separator line */ gr_line_x = w->login.outframewidth; gr_line_y = GREET_Y(w) + GREET_Y_INC(w); @@ -709,16 +709,16 @@ draw_it (LoginWidget w) int in_frame_x = VALUE_X(w,p) - w->login.inframeswidth - 3; int in_frame_y = PROMPT_Y(w,p) - w->login.inframeswidth - 1 - TEXT_Y_INC(w); - + int in_width = PROMPT_W(w) - VALUE_X(w,p); int in_height = PROMPT_H(w) + w->login.inframeswidth + 2; - + GC topLeftGC, botRightGC; -#ifdef XPM +#ifdef XPM in_width -= (w->login.logoWidth + 2*(w->login.logoPadding)); #endif /* XPM */ - + if ((PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_ON) || (PROMPT_STATE(w, p) == LOGIN_PROMPT_ECHO_OFF)) { topLeftGC = w->login.shdGC; @@ -732,16 +732,16 @@ draw_it (LoginWidget w) /* Make top/left sides */ XDrawLine(XtDisplay (w), XtWindow (w), topLeftGC, in_frame_x + i-1, in_frame_y + i-1, - in_frame_x + in_width-i, in_frame_y + i-1); + in_frame_x + in_width-i, in_frame_y + i-1); XDrawLine(XtDisplay (w), XtWindow (w), topLeftGC, in_frame_x + i-1, in_frame_y + i-1, - in_frame_x + i-1, in_frame_y + in_height-i); + in_frame_x + i-1, in_frame_y + in_height-i); /* Make bottom/right sides */ XDrawLine(XtDisplay (w), XtWindow (w), botRightGC, in_frame_x + in_width-i, in_frame_y + i-1, - in_frame_x + in_width-i, in_frame_y + in_height-i); + in_frame_x + in_width-i, in_frame_y + in_height-i); XDrawLine(XtDisplay (w), XtWindow (w), botRightGC, in_frame_x + i-1, in_frame_y + in_height-i, @@ -754,7 +754,7 @@ draw_it (LoginWidget w) #ifdef XPM gx -= ((w->login.logoWidth/2) + w->login.logoPadding); -#endif +#endif DRAW_STRING (greet, gx, GREET_Y(w), GREETING(w), strlen (GREETING(w))); } for (p = 0; p < NUM_PROMPTS ; p++) { @@ -795,12 +795,12 @@ SetPrompt (Widget ctx, int promptNum, const char *message, "LOGIN_PROMPT_NOT_SHOWN", "LOGIN_PROMPT_ECHO_ON", "LOGIN_PROMPT_ECHO_OFF", "LOGIN_TEXT_INFO" }; loginPromptState priorState; - + Debug("SetPrompt(%d, %s, %s(%d))\n", promptNum, message ? message : "<NULL>", stateNames[state], state); XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if (PROMPT_TEXT(w, promptNum) != NULL) { XtFree(PROMPT_TEXT(w, promptNum)); PROMPT_TEXT(w, promptNum) = NULL; @@ -818,18 +818,18 @@ SetPrompt (Widget ctx, int promptNum, const char *message, } messageLen = strlen(message); - + prompt = XtMalloc(messageLen + 3); if (prompt == NULL) { LogOutOfMem ("SetPrompt"); return -1; } - + strncpy(prompt, message, messageLen); - + /* Make sure text prompts have at least two spaces at end */ e = messageLen; - + if (!isspace(message[messageLen - 2])) { prompt[e] = ' '; e++; @@ -845,11 +845,11 @@ SetPrompt (Widget ctx, int promptNum, const char *message, if (w->login.state == INITIALIZING) { return 0; } - + if ((priorState == LOGIN_TEXT_INFO) && (w->login.msgTimeout != 0)) { time_t now = time(NULL); int timeleft = w->login.msgTimeout - now; - + if (timeleft > 0) { sleep(timeleft); } @@ -866,7 +866,7 @@ SetPrompt (Widget ctx, int promptNum, const char *message, w->login.activePrompt = promptNum; w->login.state = PROMPTING; } - + PROMPT_CURSOR(w, promptNum) = 0; XClearArea (XtDisplay(w), XtWindow(w), 0, 0, 0, 0, FALSE); draw_it(w); @@ -880,7 +880,7 @@ GetPrompt(Widget ctx, int promptNum) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + return CUR_PROMPT_TEXT(w,promptNum); } @@ -891,12 +891,12 @@ SetValue(Widget ctx, int promptNum, char *value) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if ((promptNum < 0) || (promptNum > LAST_PROMPT)) return -1; XDM_ASSERT(VALUE_TEXT(w, promptNum) != NULL); - + if (VALUE_TEXT(w, promptNum) == NULL) return -1; @@ -910,7 +910,7 @@ SetValue(Widget ctx, int promptNum, char *value) VALUE_SHOW_START(w, promptNum) = 0; VALUE_SHOW_END(w, promptNum) = 0; PROMPT_CURSOR(w, promptNum) = 0; - + return 0; } @@ -921,7 +921,7 @@ GetValue(Widget ctx, int promptNum) LoginWidget w = (LoginWidget) ctx; XDM_ASSERT(promptNum >= 0 && promptNum <= LAST_PROMPT); - + if ((promptNum < 0) || (promptNum > LAST_PROMPT)) return NULL; @@ -937,7 +937,7 @@ realizeDeleteChar (LoginWidget ctx) if (ctx->login.state == PROMPTING) { int promptNum = ctx->login.activePrompt; int redrawFrom = PROMPT_CURSOR(ctx, promptNum); - + if (PROMPT_CURSOR(ctx,promptNum) < (int)strlen(VALUE_TEXT(ctx,promptNum))) { if (redrawFrom < VALUE_SHOW_START(ctx, ctx->login.activePrompt)) { redrawFrom = 0; @@ -971,7 +971,7 @@ DeleteBackwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_pa CUR_PROMPT_CURSOR(ctx) -= 1; realizeDeleteChar(ctx); } - XorCursor (ctx); + XorCursor (ctx); } /*ARGSUSED*/ @@ -988,7 +988,7 @@ DeleteForwardChar (Widget ctxw, XEvent *event, String *params, Cardinal *num_par XorCursor (ctx); realizeDeleteChar(ctx); - XorCursor (ctx); + XorCursor (ctx); } /*ARGSUSED*/ @@ -1194,7 +1194,7 @@ TabField(Widget ctxw, XEvent *event, String *params, Cardinal *num_params) if (nextPrompt > LAST_PROMPT) { nextPrompt = 0; } - + if ((PROMPT_STATE(ctx, nextPrompt) == LOGIN_PROMPT_ECHO_ON) || (PROMPT_STATE(ctx, nextPrompt) == LOGIN_PROMPT_ECHO_OFF)) { ctx->login.activePrompt = nextPrompt; @@ -1412,7 +1412,7 @@ InsertChar ( break; } - if (ctx->login.state == PROMPTING) { + if (ctx->login.state == PROMPTING) { if ((len + (int)strlen(VALUE_TEXT(ctx, promptNum)) >= (VALUE_TEXT_MAX(ctx,promptNum) - 1))) { len = VALUE_TEXT_MAX(ctx,promptNum) - @@ -1447,7 +1447,7 @@ static XtConvertArgRec xftColorConvertArgs[] = { sizeof(Colormap)} }; -#define donestr(type, value, tstr) \ +# define donestr(type, value, tstr) \ { \ if (toVal->addr != NULL) { \ if (toVal->size < sizeof(type)) { \ @@ -1474,7 +1474,7 @@ XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure, Screen *screen; Colormap colormap; XftColor *color; - + if (*num_args != 2) { XtAppErrorMsg (app, @@ -1493,7 +1493,7 @@ XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure, XScreenNumberOfScreen (screen)), colormap, color); } - + static Boolean XmuCvtStringToXftColor(Display *dpy, XrmValue *args, Cardinal *num_args, @@ -1505,7 +1505,7 @@ XmuCvtStringToXftColor(Display *dpy, XftColor xftColor; Screen *screen; Colormap colormap; - + if (*num_args != 2) { XtAppErrorMsg (XtDisplayToApplicationContext (dpy), @@ -1536,14 +1536,14 @@ XmuCvtStringToXftColor(Display *dpy, } else if (!XRenderParseColor (dpy, spec, &renderColor)) return False; - if (!XftColorAllocValue (dpy, + if (!XftColorAllocValue (dpy, DefaultVisual (dpy, XScreenNumberOfScreen (screen)), colormap, &renderColor, &xftColor)) return False; - + donestr (XftColor, xftColor, XtRXftColor); } @@ -1553,7 +1553,7 @@ XmuFreeXftFont (XtAppContext app, XrmValuePtr toVal, XtPointer closure, { Screen *screen; XftFont *font; - + if (*num_args != 1) { XtAppErrorMsg (app, @@ -1579,7 +1579,7 @@ XmuCvtStringToXftFont(Display *dpy, char *name; XftFont *font; Screen *screen; - + if (*num_args != 1) { XtAppErrorMsg (XtDisplayToApplicationContext (dpy), @@ -1592,7 +1592,7 @@ XmuCvtStringToXftFont(Display *dpy, screen = *((Screen **) args[0].addr); name = (char *) fromVal->addr; - + font = XftFontOpenName (dpy, XScreenNumberOfScreen (screen), name); @@ -1622,12 +1622,12 @@ XmuXftTextWidth(Display *dpy, XftFont *font, FcChar8 *string, int len) #endif /* USE_XFT */ -static void +static void ClassInitialize(void) { #ifdef USE_XFT - XtSetTypeConverter (XtRString, XtRXftColor, - XmuCvtStringToXftColor, + XtSetTypeConverter (XtRString, XtRXftColor, + XmuCvtStringToXftColor, xftColorConvertArgs, XtNumber(xftColorConvertArgs), XtCacheByDisplay, XmuFreeXftColor); XtSetTypeConverter (XtRString, XtRXftFont, @@ -1655,7 +1655,7 @@ static void Initialize ( int s_num; #endif int rv = 0; - + myXGCV.foreground = w->login.hipixel; myXGCV.background = w->core.background_pixel; valuemask = GCForeground | GCBackground; @@ -1674,7 +1674,7 @@ static void Initialize ( myXGCV.font = w->login.textFont->fid; valuemask |= GCFont; } -#endif +#endif w->login.textGC = XtGetGC(gnew, valuemask, &myXGCV); myXGCV.foreground = w->core.background_pixel; w->login.bgGC = XtGetGC(gnew, valuemask, &myXGCV); @@ -1751,7 +1751,7 @@ static void Initialize ( &(w->login.logoPixmap), /* pixmap */ &(w->login.logoMask), /* pixmap mask */ &myAttributes); /* XPM attributes */ - + if ( rv < 0 ) { LogError("Cannot load xpm file %s: %s.\n", w->login.logoFileName, @@ -1793,7 +1793,7 @@ SkipXpmLoad: VALUE_TEXT(w, LOGIN_PROMPT_USERNAME) = w->login.data.name; VALUE_TEXT_MAX(w, LOGIN_PROMPT_USERNAME) = sizeof(w->login.data.name); VALUE_SHOW_START(w, LOGIN_PROMPT_USERNAME) = 0; - + PROMPT_TEXT(w, LOGIN_PROMPT_PASSWORD) = NULL; DEF_PROMPT_TEXT(w, LOGIN_PROMPT_PASSWORD) = w->login.passwdPrompt; VALUE_TEXT(w, LOGIN_PROMPT_PASSWORD) = w->login.data.passwd; @@ -1802,7 +1802,7 @@ SkipXpmLoad: SetPrompt(gnew, LOGIN_PROMPT_PASSWORD, NULL, LOGIN_PROMPT_ECHO_OFF, False); SetPrompt(gnew, LOGIN_PROMPT_USERNAME, NULL, LOGIN_PROMPT_ECHO_ON, False); - + if (w->core.width == 0) w->core.width = max (GREET_W(w), FAIL_W(w)) + PAD_X(w); if (w->core.height == 0) { @@ -1816,7 +1816,7 @@ SkipXpmLoad: w->core.height = max(fy + pady, (w->login.logoHeight + (2*w->login.logoPadding)) + pady); - + #endif /* XPM */ } #ifdef USE_XINERAMA @@ -1829,7 +1829,7 @@ SkipXpmLoad: x = screens[0].x_org + (int)(screens[0].width - w->core.width) / 2; if ((y = w->core.y) == -1) y = screens[0].y_org + (int)(screens[0].height - w->core.height) / 3; - + XFree(screens); } else @@ -1847,7 +1847,7 @@ SkipXpmLoad: w->login.state = PROMPTING; } - + static void Realize ( Widget gw, XtValueMask *valueMask, @@ -1871,13 +1871,13 @@ static void Realize ( XDefineCursor(XtDisplay(gw), DefaultRootWindow(XtDisplay(gw)), cursor); #ifdef XPM - /* + /* * Check if Pixmap was valid */ if (True == w->login.logoValid) { /* - * Create pixmap window + * Create pixmap window */ { unsigned long valueMask = CWBackPixel | CWBackPixmap; @@ -1934,8 +1934,8 @@ static void Destroy (Widget gw) XftDrawDestroy(w->login.draw); w->login.draw = NULL; } -#endif - +#endif + XtReleaseGC(gw, w->login.textGC); XtReleaseGC(gw, w->login.bgGC); XtReleaseGC(gw, w->login.xorGC); @@ -1977,7 +1977,7 @@ static Boolean SetValues ( Cardinal *num_args) { LoginWidget currentL, newL; - + currentL = (LoginWidget) current; newL = (LoginWidget) new; if (GREETING (currentL) != GREETING (newL)) diff --git a/greeter/Login.h b/greeter/Login.h index c6f9341..7d04a1a 100644 --- a/greeter/Login.h +++ b/greeter/Login.h @@ -60,7 +60,7 @@ from The Open Group. #ifndef _XtLogin_h -#define _XtLogin_h +# define _XtLogin_h /*********************************************************************** * @@ -119,21 +119,21 @@ from The Open Group. # define XtNinnerFramesWidth "innerFramesWidth" # define XtNsepWidth "sepWidth" -#ifdef DANCING +# ifdef DANCING /* caolan begin */ -#define XtNlastEventTime "lastEventTime" -#define XtCLastEventTime "LastEventTime" +# define XtNlastEventTime "lastEventTime" +# define XtCLastEventTime "LastEventTime" /* caolan end */ -#endif /* DANCING */ +# endif /* DANCING */ -#ifdef XPM -#define XtNuseShape "useShape" -#define XtCUseShape "UseShape" -#define XtNlogoFileName "logoFileName" -#define XtCLogoFileName "LogoFileName" -#define XtNlogoPadding "logoPadding" -#define XtCLogoPadding "LogoPadding" -#endif /* XPM */ +# ifdef XPM +# define XtNuseShape "useShape" +# define XtCUseShape "UseShape" +# define XtNlogoFileName "logoFileName" +# define XtCLogoFileName "LogoFileName" +# define XtNlogoPadding "logoPadding" +# define XtCLogoPadding "LogoPadding" +# endif /* XPM */ # define XtCGreeting "Greeting" # define XtCNamePrompt "NamePrompt" @@ -151,43 +151,43 @@ from The Open Group. /* notifyDone interface definition */ -#ifdef __OpenBSD__ -# include <sys/param.h> -#endif +# ifdef __OpenBSD__ +# include <sys/param.h> +# endif -#include <pwd.h> -#include <limits.h> +# include <pwd.h> +# include <limits.h> -#ifdef USE_PAM -# define NAME_LEN PAM_MAX_RESP_SIZE -# define PASSWORD_LEN PAM_MAX_RESP_SIZE -#endif +# ifdef USE_PAM +# define NAME_LEN PAM_MAX_RESP_SIZE +# define PASSWORD_LEN PAM_MAX_RESP_SIZE +# endif /* Defined to be in <limits.h> by SUSv2 */ -#if !defined(PASSWORD_LEN) && defined(PASS_MAX) -# define PASSWORD_LEN PASS_MAX -#endif +# if !defined(PASSWORD_LEN) && defined(PASS_MAX) +# define PASSWORD_LEN PASS_MAX +# endif /* _PW_NAME_LEN is found in <pwd.h> on OpenBSD > 2.8 (200012) */ -#if !defined(NAME_LEN) && defined(_PW_NAME_LEN) -# define NAME_LEN (_PW_NAME_LEN + 2) -#endif +# if !defined(NAME_LEN) && defined(_PW_NAME_LEN) +# define NAME_LEN (_PW_NAME_LEN + 2) +# endif /* _PASSWORD_LEN appears to come from 4.4BSD-Lite <pwd.h> */ -#if !defined(PASSWORD_LEN) && defined(_PASSWORD_LEN) -# define PASSWORD_LEN (_PASSWORD_LEN + 2) -#endif +# if !defined(PASSWORD_LEN) && defined(_PASSWORD_LEN) +# define PASSWORD_LEN (_PASSWORD_LEN + 2) +# endif /* Fallbacks if no other definition found */ -#ifndef NAME_LEN -# define NAME_LEN 32 -#endif +# ifndef NAME_LEN +# define NAME_LEN 32 +# endif -#ifndef PASSWORD_LEN -# define PASSWORD_LEN 32 -#endif +# ifndef PASSWORD_LEN +# define PASSWORD_LEN 32 +# endif -typedef struct _LoginData { +typedef struct _LoginData { char name[NAME_LEN], passwd[PASSWORD_LEN]; } LoginData; @@ -213,8 +213,8 @@ typedef enum { } loginPromptState; /* Default prompt meanings for simple username/password auth systems */ -#define LOGIN_PROMPT_USERNAME 0 -#define LOGIN_PROMPT_PASSWORD 1 +# define LOGIN_PROMPT_USERNAME 0 +# define LOGIN_PROMPT_PASSWORD 1 extern int SetPrompt(Widget ctx, int promptId, const char *message, loginPromptState state, Boolean minimumTime); diff --git a/greeter/LoginP.h b/greeter/LoginP.h index ba9c997..d73a9a1 100644 --- a/greeter/LoginP.h +++ b/greeter/LoginP.h @@ -59,20 +59,20 @@ from The Open Group. */ #ifndef _LoginP_h -#define _LoginP_h +# define _LoginP_h -#include "Login.h" -#include <X11/IntrinsicP.h> -#include <X11/CoreP.h> -#include <X11/Xlib.h> -#ifdef USE_XFT -# include <X11/Xft/Xft.h> -#endif +# include "Login.h" +# include <X11/IntrinsicP.h> +# include <X11/CoreP.h> +# include <X11/Xlib.h> +# ifdef USE_XFT +# include <X11/Xft/Xft.h> +# endif -#define INITIALIZING 0 -#define PROMPTING 1 -#define SHOW_MESSAGE 2 -#define DONE 3 +# define INITIALIZING 0 +# define PROMPTING 1 +# define SHOW_MESSAGE 2 +# define DONE 3 typedef void (*LoginFunc)(LoginWidget, LoginData *, int); @@ -83,31 +83,31 @@ typedef struct { size_t valueTextMax; /* Size of valueText buffer */ int valueShownStart;/* Amount of string shown if too */ int valueShownEnd; /* long to fit in field */ - int cursor; /* current cursor position */ + int cursor; /* current cursor position */ loginPromptState state; } loginPromptData; -#define NUM_PROMPTS 2 /* Currently only 2 prompt fields supported */ -#define LAST_PROMPT (NUM_PROMPTS - 1) +# define NUM_PROMPTS 2 /* Currently only 2 prompt fields supported */ +# define LAST_PROMPT (NUM_PROMPTS - 1) /* New fields for the login widget instance record */ typedef struct { -#ifndef USE_XFT +# ifndef USE_XFT Pixel textpixel; /* foreground pixel */ Pixel promptpixel; /* prompt pixel */ Pixel greetpixel; /* greeting pixel */ Pixel failpixel; /* failure pixel */ -#endif +# endif Pixel hipixel; /* frame hilite pixel */ Pixel shdpixel; /* shadow frame pixel */ GC textGC; /* pointer to GraphicsContext */ GC bgGC; /* pointer to GraphicsContext */ GC xorGC; /* pointer to GraphicsContext */ -#ifndef USE_XFT +# ifndef USE_XFT GC promptGC; GC greetGC; GC failGC; -#endif +# endif GC hiGC; /* for hilight part of frame */ GC shdGC; /* for shaded part of frame */ char *greeting; /* greeting */ @@ -117,12 +117,12 @@ typedef struct { char *failMsg; /* failure message */ char *fail; /* current error message */ char *passwdChangeMsg; /* message when passwd expires */ -#ifndef USE_XFT +# ifndef USE_XFT XFontStruct *textFont; /* font for text */ XFontStruct *promptFont; /* font for prompts */ XFontStruct *greetFont; /* font for greeting */ XFontStruct *failFont; /* font for failure message */ -#endif /* USE_XFT */ +# endif /* USE_XFT */ int state; /* state */ int activePrompt; /* which prompt is active */ int failUp; /* failure message displayed */ @@ -139,35 +139,35 @@ typedef struct { loginPromptData prompts[NUM_PROMPTS]; time_t msgTimeout; -#ifdef DANCING +# ifdef DANCING /*caolan begin*/ int lastEventTime; /*caolan end*/ -#endif /* DANCING */ - +# endif /* DANCING */ + int outframewidth; /* outer frame thickness */ int inframeswidth; /* inner frames thickness */ int sepwidth; /* width of separator line */ -#ifdef XPM +# ifdef XPM char *logoFileName; unsigned int logoWidth, logoHeight, logoPadding, logoBorderWidth; int logoX, logoY; Window logoWindow; Boolean useShape, logoValid; Pixmap logoPixmap, logoMask; -#endif /* XPM */ -#ifdef USE_XFT +# endif /* XPM */ +# ifdef USE_XFT XftDraw *draw; XftFont *textFace; /* font for text */ XftFont *promptFace; /* font for prompts */ XftFont *greetFace; /* font for greeting */ - XftFont *failFace; /* font for failure message */ + XftFont *failFace; /* font for failure message */ XftColor textcolor; /* foreground color */ XftColor promptcolor; /* prompt color */ XftColor greetcolor; /* greeting color */ XftColor failcolor; /* failure color */ -#endif +# endif } LoginPart; /* Full instance record declaration */ diff --git a/greeter/greet.c b/greeter/greet.c index 9e2dee5..a34ebf7 100644 --- a/greeter/greet.c +++ b/greeter/greet.c @@ -72,7 +72,7 @@ from The Open Group. #include <X11/XKBlib.h> #ifdef USE_XINERAMA -#include <X11/extensions/Xinerama.h> +# include <X11/extensions/Xinerama.h> #endif #include "dm.h" @@ -81,14 +81,14 @@ from The Open Group. #include "Login.h" #if defined(HAVE_OPENLOG) && defined(HAVE_SYSLOG_H) -#define USE_SYSLOG -#include <syslog.h> -#ifndef LOG_AUTHPRIV -#define LOG_AUTHPRIV LOG_AUTH -#endif -#ifndef LOG_PID -#define LOG_PID 0 -#endif +# define USE_SYSLOG +# include <syslog.h> +# ifndef LOG_AUTHPRIV +# define LOG_AUTHPRIV LOG_AUTH +# endif +# ifndef LOG_PID +# define LOG_PID 0 +# endif #endif #include <string.h> @@ -125,30 +125,30 @@ void (*__xdm_LogOutOfMem)(char * fmt, ...) = NULL; void (*__xdm_setgrent)(void) = NULL; struct group *(*__xdm_getgrent)(void) = NULL; void (*__xdm_endgrent)(void) = NULL; -#ifdef USESHADOW +# ifdef USESHADOW struct spwd *(*__xdm_getspnam)(GETSPNAM_ARGS) = NULL; -# ifndef QNX4 +# ifndef QNX4 void (*__xdm_endspent)(void) = NULL; -# endif /* QNX4 doesn't use endspent */ -#endif +# endif /* QNX4 doesn't use endspent */ +# endif struct passwd *(*__xdm_getpwnam)(GETPWNAM_ARGS) = NULL; -#if defined(linux) || defined(__GLIBC__) +# if defined(linux) || defined(__GLIBC__) void (*__xdm_endpwent)(void) = NULL; -#endif +# endif char *(*__xdm_crypt)(CRYPT_ARGS) = NULL; -#ifdef USE_PAM +# ifdef USE_PAM pam_handle_t **(*__xdm_thepamhp)(void) = NULL; -#endif +# endif #endif #ifdef SECURE_RPC -#include <rpc/rpc.h> -#include <rpc/key_prot.h> +# include <rpc/rpc.h> +# include <rpc/key_prot.h> #endif #ifdef K5AUTH -#include <krb5/krb5.h> +# include <krb5/krb5.h> #endif extern Display *dpy; @@ -164,9 +164,9 @@ static XtIntervalId pingTimeout; #ifdef USE_PAM static int pamconv(int num_msg, -#ifndef sun +# ifndef sun const -#endif +# endif struct pam_message **msg, struct pam_response **response, void *appdata_ptr); @@ -384,7 +384,7 @@ Greet (struct display *d, struct greet_info *greet) #ifndef USE_PAM char *ptr; unsigned int c,state = WHITESPACE; - + /* * Process the name string to get rid of white spaces. */ @@ -462,20 +462,20 @@ greet_user_rtn GreetUser( __xdm_setgrent = dlfuncs->_setgrent; __xdm_getgrent = dlfuncs->_getgrent; __xdm_endgrent = dlfuncs->_endgrent; -#ifdef USESHADOW +# ifdef USESHADOW __xdm_getspnam = dlfuncs->_getspnam; -# ifndef QNX4 +# ifndef QNX4 __xdm_endspent = dlfuncs->_endspent; -# endif /* QNX4 doesn't use endspent */ -#endif +# endif /* QNX4 doesn't use endspent */ +# endif __xdm_getpwnam = dlfuncs->_getpwnam; -#if defined(linux) || defined(__GLIBC__) +# if defined(linux) || defined(__GLIBC__) __xdm_endpwent = dlfuncs->_endpwent; -#endif +# endif __xdm_crypt = dlfuncs->_crypt; -#ifdef USE_PAM +# ifdef USE_PAM __xdm_thepamhp = dlfuncs->_thepamhp; -#endif +# endif #endif *dpy = InitGreet (d); @@ -510,16 +510,16 @@ greet_user_rtn GreetUser( SetPrompt(login, 0, NULL, LOGIN_PROMPT_NOT_SHOWN, False); login_prompt = GetPrompt(login, LOGIN_PROMPT_USERNAME); SetPrompt(login, 1, NULL, LOGIN_PROMPT_NOT_SHOWN, False); - -#define RUN_AND_CHECK_PAM_ERROR(function, args) \ + +# define RUN_AND_CHECK_PAM_ERROR(function, args) \ do { \ pam_error = function args; \ if (pam_error != PAM_SUCCESS) { \ PAM_ERROR_PRINT(#function, *pamhp); \ goto pam_done; \ } \ - } while (0) - + } while (0) + RUN_AND_CHECK_PAM_ERROR(pam_start, ("xdm", NULL, &pc, pamhp)); @@ -537,23 +537,23 @@ greet_user_rtn GreetUser( LogOutOfMem("GreetUser"); } else { char *colon = strrchr(hostname, ':'); - + if (colon != NULL) *colon = '\0'; - + RUN_AND_CHECK_PAM_ERROR(pam_set_item, (*pamhp, PAM_RHOST, hostname)); free(hostname); } } else RUN_AND_CHECK_PAM_ERROR(pam_set_item, (*pamhp, PAM_TTY, d->name)); - + if (!greet->allow_null_passwd) { pam_flags |= PAM_DISALLOW_NULL_AUTHTOK; } RUN_AND_CHECK_PAM_ERROR(pam_authenticate, (*pamhp, pam_flags)); - + /* handle expired passwords */ pam_error = pam_acct_mgmt(*pamhp, pam_flags); pam_fname = "pam_acct_mgmt"; @@ -569,7 +569,7 @@ greet_user_rtn GreetUser( PAM_ERROR_PRINT(pam_fname, *pamhp); goto pam_done; } - + RUN_AND_CHECK_PAM_ERROR(pam_setcred, (*pamhp, 0)); RUN_AND_CHECK_PAM_ERROR(pam_get_item, @@ -579,7 +579,7 @@ greet_user_rtn GreetUser( greet->name = username; greet->password = NULL; } - + pam_done: if (code != 0) { @@ -639,7 +639,7 @@ greet_user_rtn GreetUser( XHostAddress addr; char netname[MAXNETNAMELEN+1]; char domainname[MAXNETNAMELEN+1]; - + getdomainname(domainname, sizeof domainname); user2netname (netname, verify->uid, domainname); addr.family = FamilyNetname; @@ -663,7 +663,7 @@ greet_user_rtn GreetUser( d->authorizations[i] = Krb5GetAuthFor(14, "MIT-KERBEROS-5", d->name); SaveServerAuthorizations (d, d->authorizations, d->authNum); - } + } #endif } @@ -673,9 +673,9 @@ greet_user_rtn GreetUser( #ifdef USE_PAM static int pamconv(int num_msg, -#ifndef sun +# ifndef sun const -#endif +# endif struct pam_message **msg, struct pam_response **response, void *appdata_ptr) { @@ -686,14 +686,14 @@ static int pamconv(int num_msg, = { "<invalid pam msg style>", "PAM_PROMPT_ECHO_OFF", "PAM_PROMPT_ECHO_ON", "PAM_ERROR_MSG", "PAM_TEXT_INFO" } ; - + struct pam_message *m; struct pam_response *r; struct myconv_data *d = (struct myconv_data *) appdata_ptr; pam_handle_t **pamhp = thepamhp(); - + *response = calloc(num_msg, sizeof (struct pam_response)); if (*response == NULL) return (PAM_BUF_ERR); @@ -712,8 +712,8 @@ static int pamconv(int num_msg, NULL, LOGIN_TEXT_INFO, False); SetValue(login, LOGIN_PROMPT_USERNAME, username); promptId = 1; - } - + } + Debug("pam_msg: %s (%d): '%s'\n", ((m->msg_style > 0) && (m->msg_style <= 4)) ? pam_msg_styles[m->msg_style] : pam_msg_styles[0], @@ -728,7 +728,7 @@ static int pamconv(int num_msg, SetPrompt (login, promptId, m->msg, LOGIN_TEXT_INFO, True); SetValue (login, promptId, NULL); break; - + case PAM_PROMPT_ECHO_ON: pStyle = LOGIN_PROMPT_ECHO_ON; /* FALLTHROUGH */ @@ -754,7 +754,7 @@ static int pamconv(int num_msg, LogError("Unknown PAM msg_style: %d\n", m->msg_style); } } - pam_error: + pam_error: if (status != PAM_SUCCESS) { /* free responses */ r = *response; diff --git a/greeter/verify.c b/greeter/verify.c index f50341b..b4fb850 100644 --- a/greeter/verify.c +++ b/greeter/verify.c @@ -55,7 +55,7 @@ from The Open Group. # include <prot.h> #endif -# include "greet.h" +#include "greet.h" #ifdef QNX4 extern char *crypt(const char *, const char *); @@ -81,12 +81,12 @@ static char *envvars[] = { }; #ifdef KERBEROS -#include <sys/param.h> -#include <kerberosIV/krb.h> +# include <sys/param.h> +# include <kerberosIV/krb.h> /* OpenBSD 2.8 needs this. */ -#if defined(OpenBSD) && (OpenBSD <= 200012) -#include <kerberosIV/kafs.h> -#endif +# if defined(OpenBSD) && (OpenBSD <= 200012) +# include <kerberosIV/kafs.h> +# endif static char krbtkfile[MAXPATHLEN]; #endif @@ -175,7 +175,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) /* Build path of the auth script and call it */ snprintf(path, sizeof(path), _PATH_AUTHPROG "%s", style); - auth_call(as, path, style, "-s", "response", greet->name, + auth_call(as, path, style, "-s", "response", greet->name, lc->lc_class, (void *)NULL); authok = auth_getstate(as); @@ -209,12 +209,12 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) } /* - * Shell must be in /etc/shells + * Shell must be in /etc/shells */ for (;;) { s = getusershell(); if (s == NULL) { - /* did not found the shell in /etc/shells + /* did not found the shell in /etc/shells -> failure */ Debug("shell not in /etc/shells\n"); bzero(greet->password, strlen(greet->password)); @@ -226,7 +226,7 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) endusershell(); break; } - } + } #elif defined(USESECUREWARE) /* !USE_BSDAUTH */ /* * This is a global variable and will be referenced in at least session.c @@ -325,16 +325,16 @@ int Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) { struct passwd *p; -#ifndef USE_PAM -#ifdef USESHADOW +# ifndef USE_PAM +# ifdef USESHADOW struct spwd *sp; -#endif +# endif char *user_pass = NULL; -#endif -#ifdef __OpenBSD__ +# endif +# ifdef __OpenBSD__ char *s; struct timeval tp; -#endif +# endif char *shell, *home; char **argv; @@ -350,18 +350,18 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) return 0; } -#if defined(sun) && defined(SVR4) - /* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, +# if defined(sun) && defined(SVR4) + /* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, then root can only login on system console */ -# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login" +# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login" if (p->pw_uid == 0) { char *console = NULL, *tmp = NULL; FILE *fs; if ((fs= fopen(SOLARIS_LOGIN_DEFAULTS, "r")) != NULL) - { + { char str[120]; while (!feof(fs)) { @@ -372,8 +372,8 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) console = strdup((tmp+8)); } fclose(fs); - if ( console != NULL && - (strncmp(console, "/dev/console", 12) == 0) && + if ( console != NULL && + (strncmp(console, "/dev/console", 12) == 0) && (strncmp(d->name,":0",2) != 0) ) { Debug("Not on system console\n"); @@ -387,26 +387,26 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) else { Debug("Could not open %s\n", SOLARIS_LOGIN_DEFAULTS); - } + } } -#endif +# endif -#ifndef USE_PAM /* PAM authentication happened in GreetUser already */ -#ifdef linux +# ifndef USE_PAM /* PAM authentication happened in GreetUser already */ +# ifdef linux if (!strcmp(p->pw_passwd, "!") || !strcmp(p->pw_passwd, "*")) { Debug ("The account is locked, no login allowed.\n"); bzero(greet->password, strlen(greet->password)); return 0; } -#endif +# endif user_pass = p->pw_passwd; -#ifdef KERBEROS +# ifdef KERBEROS if(strcmp(greet->name, "root") != 0){ char name[ANAME_SZ]; char realm[REALM_SZ]; char *q; int ret; - + if(krb_get_lrealm(realm, 1)){ Debug ("Can't get Kerberos realm.\n"); } else { @@ -415,10 +415,10 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) TKT_ROOT, d->name); krb_set_tkt_string(krbtkfile); unlink(krbtkfile); - - ret = krb_verify_user(greet->name, "", realm, + + ret = krb_verify_user(greet->name, "", realm, greet->password, 1, "rcmd"); - + if(ret == KSUCCESS){ chown(krbtkfile, p->pw_uid, p->pw_gid); Debug("kerberos verify succeeded\n"); @@ -426,9 +426,9 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) if (k_setpag() == -1) LogError ("setpag() failed for %s\n", greet->name); - + if((ret = k_afsklog(NULL, NULL)) != KSUCCESS) - LogError("Warning %s\n", + LogError("Warning %s\n", krb_get_err_text(ret)); } goto done; @@ -439,8 +439,8 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) } } } -#endif -#ifdef USESHADOW +# endif +# ifdef USESHADOW errno = 0; sp = getspnam(greet->name); if (sp == NULL) { @@ -448,15 +448,15 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) } else { user_pass = sp->sp_pwdp; } -#ifndef QNX4 +# ifndef QNX4 endspent(); -#endif /* QNX4 doesn't need endspent() to end shadow passwd ops */ -#endif /* USESHADOW */ -#if defined(ultrix) || defined(__ultrix__) +# endif /* QNX4 doesn't need endspent() to end shadow passwd ops */ +# endif /* USESHADOW */ +# if defined(ultrix) || defined(__ultrix__) if (authenticate_user(p, greet->password, NULL) < 0) -#else +# else if (strcmp (crypt (greet->password, user_pass), user_pass)) -#endif +# endif { if(!greet->allow_null_passwd || strlen(p->pw_passwd) > 0) { Debug ("password verify failed\n"); @@ -464,10 +464,10 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify) return 0; } /* else: null passwd okay */ } -#ifdef KERBEROS +# ifdef KERBEROS done: -#endif -#ifdef __OpenBSD__ +# endif +# ifdef __OpenBSD__ /* * Only accept root logins if allowRootLogin resource is set */ @@ -477,12 +477,12 @@ done: return 0; } /* - * Shell must be in /etc/shells + * Shell must be in /etc/shells */ for (;;) { s = getusershell(); if (s == NULL) { - /* did not found the shell in /etc/shells + /* did not found the shell in /etc/shells -> failure */ Debug("shell not in /etc/shells\n"); bzero(greet->password, strlen(greet->password)); @@ -494,7 +494,7 @@ done: endusershell(); break; } - } + } /* * Test for expired password */ @@ -512,12 +512,12 @@ done: Debug("account has expired.\n"); bzero(greet->password, strlen(greet->password)); return 0; - } + } } -#endif /* __OpenBSD__ */ +# endif /* __OpenBSD__ */ bzero(user_pass, strlen(user_pass)); /* in case shadow password */ -#endif /* USE_PAM */ +# endif /* USE_PAM */ #endif /* USE_BSDAUTH */ Debug ("verify succeeded\n"); @@ -145,7 +145,7 @@ Krb5GetAuth (unsigned short namelen, char *name) } int preauth_search_list[] = { - 0, + 0, KRB5_PADATA_ENC_TIMESTAMP, -1 }; @@ -36,12 +36,12 @@ from The Open Group. * for MIT-MAGIC-COOKIE-1 type authorization */ -# include <X11/Xos.h> +#include <X11/Xos.h> -# include "dm.h" -# include "dm_auth.h" +#include "dm.h" +#include "dm_auth.h" -# define AUTH_DATA_LEN 16 /* bytes of authorization data */ +#define AUTH_DATA_LEN 16 /* bytes of authorization data */ static char auth_name[256]; void @@ -39,32 +39,32 @@ from The Open Group. #ifdef XDMCP -#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 */ -#endif +# 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 */ +# endif /* given an XdmcpNetaddr, returns the socket protocol family used, e.g., AF_INET */ int NetaddrFamily(XdmcpNetaddr netaddrp) { -#ifdef STREAMSCONN +# ifdef STREAMSCONN short family = *(short *)netaddrp; return family; -#else +# else return ((struct sockaddr *)netaddrp)->sa_family; -#endif +# endif } @@ -74,25 +74,25 @@ int NetaddrFamily(XdmcpNetaddr netaddrp) char * NetaddrPort(XdmcpNetaddr netaddrp, int *lenp) { -#ifdef STREAMSCONN +# ifdef STREAMSCONN *lenp = 2; return netaddrp+2; -#else +# else switch (NetaddrFamily(netaddrp)) { case AF_INET: *lenp = 2; return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: *lenp = 2; return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port); -#endif +# endif default: *lenp = 0; return NULL; } -#endif +# endif } @@ -101,21 +101,21 @@ char * NetaddrPort(XdmcpNetaddr netaddrp, int *lenp) char * NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp) { -#ifdef STREAMSCONN +# ifdef STREAMSCONN *lenp = 4; return netaddrp+4; -#else +# else switch (NetaddrFamily(netaddrp)) { -#ifdef UNIXCONN +# ifdef UNIXCONN case AF_UNIX: *lenp = strlen(((struct sockaddr_un *)netaddrp)->sun_path); return (char *) (((struct sockaddr_un *)netaddrp)->sun_path); -#endif -#ifdef TCPCONN +# endif +# ifdef TCPCONN case AF_INET: *lenp = sizeof (struct in_addr); return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr); -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: { struct in6_addr *a = &(((struct sockaddr_in6 *)netaddrp)->sin6_addr); @@ -127,21 +127,21 @@ char * NetaddrAddress(XdmcpNetaddr netaddrp, int *lenp) return (char *) &(a->s6_addr); } } -#endif -#endif -#ifdef DNETCONN +# endif +# endif +# ifdef DNETCONN case AF_DECnet: *lenp = sizeof (struct dn_naddr); return (char *) &(((struct sockaddr_dn *)netaddrp)->sdn_add); -#endif -#ifdef AF_CHAOS +# endif +# ifdef AF_CHAOS case AF_CHAOS: -#endif +# endif default: *lenp = 0; return NULL; } -#endif /* STREAMSCONN else */ +# endif /* STREAMSCONN else */ } @@ -156,53 +156,53 @@ int ConvertAddr (XdmcpNetaddr saddr, int *len, char **addr) if ((len == NULL) || (saddr == NULL)) return -1; *addr = NetaddrAddress(saddr, len); -#ifdef STREAMSCONN +# ifdef STREAMSCONN /* kludge */ if (NetaddrFamily(saddr) == 2) retval = FamilyInternet; -#else +# else switch (NetaddrFamily(saddr)) { -#ifdef AF_UNSPEC +# ifdef AF_UNSPEC case AF_UNSPEC: retval = FamilyLocal; break; -#endif -#ifdef AF_UNIX -#ifndef hpux +# endif +# ifdef AF_UNIX +# ifndef hpux case AF_UNIX: retval = FamilyLocal; break; -#endif -#endif -#ifdef TCPCONN +# endif +# endif +# ifdef TCPCONN case AF_INET: retval = FamilyInternet; break; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: - if (*len == sizeof(struct in_addr)) + if (*len == sizeof(struct in_addr)) retval = FamilyInternet; - else + else retval = FamilyInternet6; break; -#endif -#endif -#ifdef DNETCONN +# endif +# endif +# ifdef DNETCONN case AF_DECnet: retval = FamilyDECnet; break; -#endif -#ifdef AF_CHAOS +# endif +# ifdef AF_CHAOS case AF_CHAOS: retval = FamilyChaos; break; -#endif +# endif default: retval = -1; break; } -#endif /* STREAMSCONN else */ +# endif /* STREAMSCONN else */ Debug ("ConvertAddr returning %d for family %d\n", retval, NetaddrFamily(saddr)); return retval; @@ -237,7 +237,7 @@ addressEqual (XdmcpNetaddr a1, int len1, XdmcpNetaddr a2, int len2) return TRUE; } -#ifdef DEBUG +# ifdef DEBUG /*ARGSUSED*/ void PrintSockAddr (struct sockaddr *a, int len) @@ -246,7 +246,7 @@ PrintSockAddr (struct sockaddr *a, int len) Debug ("family %d, ", a->sa_family); switch (a->sa_family) { -#ifdef AF_INET +# ifdef AF_INET case AF_INET: p = (unsigned char *) &((struct sockaddr_in *) a)->sin_port; @@ -255,22 +255,22 @@ PrintSockAddr (struct sockaddr *a, int len) Debug ("port %d, host %d.%d.%d.%d\n", (p[0] << 8) + p[1], t[0], t[1], t[2], t[3]); break; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: { char astr[INET6_ADDRSTRLEN] = ""; - + inet_ntop(a->sa_family, &((struct sockaddr_in6 *) a)->sin6_addr, astr, sizeof(astr)); p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port; - + Debug ("port %d, host %s\n", (p[0] << 8) + p[1], astr); break; } -#endif +# endif } } -#endif +# endif #endif /* XDMCP */ @@ -33,8 +33,8 @@ from The Open Group. * policy.c. Implement site-dependent policy for XDMCP connections */ -# include "dm.h" -# include "dm_auth.h" +#include "dm.h" +#include "dm_auth.h" #include <errno.h> @@ -52,17 +52,17 @@ typedef struct _XdmAuth { } XdmAuthRec, *XdmAuthPtr; static XdmAuthRec auth[] = { -#ifdef HASXDMAUTH +# ifdef HASXDMAUTH { {(CARD16) 20, (CARD8 *) "XDM-AUTHENTICATION-1"}, {(CARD16) 19, (CARD8 *) "XDM-AUTHORIZATION-1"}, }, -#endif +# endif { {(CARD16) 0, (CARD8 *) 0}, {(CARD16) 0, (CARD8 *) 0}, } }; -#define NumAuth (sizeof auth / sizeof auth[0]) +# define NumAuth (sizeof auth / sizeof auth[0]) ARRAY8Ptr ChooseAuthentication (ARRAYofARRAY8Ptr authenticationNames) @@ -84,10 +84,10 @@ CheckAuthentication ( ARRAY8Ptr name, ARRAY8Ptr data) { -#ifdef HASXDMAUTH +# ifdef HASXDMAUTH if (name->length && !strncmp ((char *)name->data, "XDM-AUTHENTICATION-1", 20)) return XdmCheckAuthentication (pdpy, displayID, name, data); -#endif +# endif return TRUE; } @@ -127,7 +127,7 @@ Willing ( { char statusBuf[256]; int ret; - + ret = AcceptableDisplayAddress (addr, connectionType, type); if (!ret) snprintf (statusBuf, sizeof(statusBuf), @@ -183,22 +183,22 @@ SelectConnectionTypeIndex ( { int i; - /* - * Select one supported connection type + /* + * Select one supported connection type */ for (i = 0; i < connectionTypes->length; i++) { switch (connectionTypes->data[i]) { case FamilyLocal: -#if defined(TCPCONN) +# if defined(TCPCONN) case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case FamilyInternet6: -#endif /* IPv6 */ -#endif /* TCPCONN */ -#if defined(DNETCONN) +# endif /* IPv6 */ +# endif /* TCPCONN */ +# if defined(DNETCONN) case FamilyDECnet: -#endif /* DNETCONN */ +# endif /* DNETCONN */ return i; } } /* for */ @@ -27,11 +27,11 @@ #include <sys/socket.h> #include <X11/Xos.h> #ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif +# ifndef Lynx +# include <sys/un.h> +# else +# include <un.h> +# endif #endif #include <netinet/in.h> #include <errno.h> @@ -44,25 +44,25 @@ #include "dm_error.h" #ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7F000001U +# define INADDR_LOOPBACK 0x7F000001U #endif static ssize_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); #ifndef offsetof -# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif /* * Collect 'len' bytes of entropy into 'buf' from PRNGD/EGD daemon * listening either on 'tcp_port', or via Unix domain socket at * * 'socket_path'. - * Either a non-zero tcp_port or a non-null socket_path must be + * Either a non-zero tcp_port or a non-null socket_path must be * supplied. * Returns 0 on success, -1 on error */ int -get_prngd_bytes(char *buf, int len, +get_prngd_bytes(char *buf, int len, unsigned short tcp_port, char *socket_path) { int fd, addr_len, rval, errors; @@ -178,7 +178,7 @@ atomicio(ssize_t (*f)(int, void *, size_t), int fd, void *_s, size_t n) switch (res) { case -1: #ifdef EWOULDBLOCK - if (errno == EINTR || errno == EAGAIN + if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) #else if (errno == EINTR || errno == EAGAIN) @@ -38,13 +38,13 @@ in this Software without prior written authorization from The Open Group. #ifdef XDMCP -#include <sys/types.h> -#include <time.h> -#define Time_t time_t +# include <sys/types.h> +# include <time.h> +# define Time_t time_t static struct protoDisplay *protoDisplays; -#ifdef DEBUG +# ifdef DEBUG static PrintProtoDisplay (struct protoDisplay *pdpy) { @@ -55,7 +55,7 @@ PrintProtoDisplay (struct protoDisplay *pdpy) Debug ("\tdisplay Number %d\n", pdpy->displayNumber); Debug ("\tsessionID %d\n", pdpy->sessionID); } -#endif +# endif struct protoDisplay * FindProtoDisplay ( @@ -35,11 +35,11 @@ from The Open Group. * a client remains connected with no windows. */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" -# include <X11/Xlib.h> -# include <signal.h> +#include <X11/Xlib.h> +#include <signal.h> /*ARGSUSED*/ static int @@ -61,7 +61,7 @@ killWindows (Display *dpy, Window window) Window root, parent, *children; int child; unsigned int nchildren = 0; - + while (XQueryTree (dpy, window, &root, &parent, &children, &nchildren) && nchildren > 0) { @@ -85,7 +85,7 @@ abortReset (int n) /* * this display connection better not have any windows... */ - + void pseudoReset (Display *dpy) { @@ -33,11 +33,11 @@ from The Open Group. * resource.c */ -# include "dm.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_error.h" -# include <X11/Intrinsic.h> -# include <X11/Xmu/CharSet.h> +#include <X11/Intrinsic.h> +#include <X11/Xmu/CharSet.h> char *config; @@ -70,76 +70,76 @@ char *greeterLib; char *willing; int choiceTimeout; /* chooser choice timeout */ -# define DM_STRING 0 -# define DM_INT 1 -# define DM_BOOL 2 -# define DM_ARGV 3 +#define DM_STRING 0 +#define DM_INT 1 +#define DM_BOOL 2 +#define DM_ARGV 3 /* * The following constants are supposed to be set in Makefile or config.h * from parameters set in configure. DO NOT CHANGE THESE DEFINITIONS! */ -#ifndef DEF_SERVER_LINE -#define DEF_SERVER_LINE ":0 local /usr/bin/X11/X :0" +#ifndef DEF_SERVER_LINE +# define DEF_SERVER_LINE ":0 local /usr/bin/X11/X :0" #endif #ifndef XRDB_PROGRAM -#define XRDB_PROGRAM "/usr/bin/X11/xrdb" +# define XRDB_PROGRAM "/usr/bin/X11/xrdb" #endif #ifndef DEF_SESSION -#define DEF_SESSION "/usr/bin/X11/xterm -ls" +# define DEF_SESSION "/usr/bin/X11/xterm -ls" #endif #ifndef DEF_USER_PATH -#define DEF_USER_PATH ":/bin:/usr/bin:/usr/bin/X11:/usr/ucb" +# define DEF_USER_PATH ":/bin:/usr/bin:/usr/bin/X11:/usr/ucb" #endif #ifndef DEF_SYSTEM_PATH -#define DEF_SYSTEM_PATH "/etc:/bin:/usr/bin:/usr/bin/X11:/usr/ucb" +# define DEF_SYSTEM_PATH "/etc:/bin:/usr/bin:/usr/bin/X11:/usr/ucb" #endif #ifndef DEF_SYSTEM_SHELL -#define DEF_SYSTEM_SHELL "/bin/sh" +# define DEF_SYSTEM_SHELL "/bin/sh" #endif #ifndef DEF_FAILSAFE_CLIENT -#define DEF_FAILSAFE_CLIENT "/usr/bin/X11/xterm" +# define DEF_FAILSAFE_CLIENT "/usr/bin/X11/xterm" #endif #ifndef DEF_XDM_CONFIG -#define DEF_XDM_CONFIG "/usr/lib/X11/xdm/xdm-config" +# define DEF_XDM_CONFIG "/usr/lib/X11/xdm/xdm-config" #endif #ifndef DEF_CHOOSER -#define DEF_CHOOSER "/usr/lib/X11/xdm/chooser" +# define DEF_CHOOSER "/usr/lib/X11/xdm/chooser" #endif #ifndef DEF_AUTH_NAME -#ifdef HASXDMAUTH -#define DEF_AUTH_NAME "XDM-AUTHORIZATION-1 MIT-MAGIC-COOKIE-1" -#else -#define DEF_AUTH_NAME "MIT-MAGIC-COOKIE-1" -#endif +# ifdef HASXDMAUTH +# define DEF_AUTH_NAME "XDM-AUTHORIZATION-1 MIT-MAGIC-COOKIE-1" +# else +# define DEF_AUTH_NAME "MIT-MAGIC-COOKIE-1" +# endif #endif #ifndef DEF_AUTH_DIR -#define DEF_AUTH_DIR "/usr/lib/X11/xdm" +# define DEF_AUTH_DIR "/usr/lib/X11/xdm" #endif #ifndef DEF_USER_AUTH_DIR -#define DEF_USER_AUTH_DIR "/tmp" +# define DEF_USER_AUTH_DIR "/tmp" #endif #ifndef DEF_KEY_FILE -#define DEF_KEY_FILE "" +# define DEF_KEY_FILE "" #endif #ifndef DEF_ACCESS_FILE -#define DEF_ACCESS_FILE "" +# define DEF_ACCESS_FILE "" #endif #ifndef DEF_RANDOM_FILE -#define DEF_RANDOM_FILE "/dev/mem" +# define DEF_RANDOM_FILE "/dev/mem" #endif #ifdef __SCO__ -#define DEF_PRNGD_SOCKET "/etc/egd-pool" +# define DEF_PRNGD_SOCKET "/etc/egd-pool" #else -#ifndef DEF_PRNGD_SOCKET -#define DEF_PRNGD_SOCKET "/tmp/entropy" -#endif +# ifndef DEF_PRNGD_SOCKET +# define DEF_PRNGD_SOCKET "/tmp/entropy" +# endif #endif #ifndef DEF_PRNGD_PORT -#define DEF_PRNGD_PORT "0" +# define DEF_PRNGD_PORT "0" #endif #ifndef DEF_GREETER_LIB -#define DEF_GREETER_LIB "/usr/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 */ @@ -179,7 +179,7 @@ struct dmResources { #if !defined(ARC4_RANDOM) { "randomFile", "RandomFile", DM_STRING, &randomFile, DEF_RANDOM_FILE} , -{ "prngdSocket", "PrngdSocket", DM_STRING, &prngdSocket, +{ "prngdSocket", "PrngdSocket", DM_STRING, &prngdSocket, DEF_PRNGD_SOCKET}, { "prngdPort", "PrngdPort", DM_INT, (char **) &prngdPort, DEF_PRNGD_PORT}, @@ -198,9 +198,9 @@ struct dmResources { ""} , }; -# define NUM_DM_RESOURCES (sizeof DmResources / sizeof DmResources[0]) +#define NUM_DM_RESOURCES (sizeof DmResources / sizeof DmResources[0]) -# define boffset(f) XtOffsetOf(struct display, f) +#define boffset(f) XtOffsetOf(struct display, f) struct displayResource { char *name, *class; @@ -248,7 +248,7 @@ struct displayResource serverResources[] = { "" }, }; -# define NUM_SERVER_RESOURCES (sizeof serverResources/\ +#define NUM_SERVER_RESOURCES (sizeof serverResources/\ sizeof serverResources[0]) /* resources which control the session behaviour */ @@ -280,7 +280,7 @@ struct displayResource sessionResources[] = { DEF_CHOOSER }, }; -# define NUM_SESSION_RESOURCES (sizeof sessionResources/\ +#define NUM_SESSION_RESOURCES (sizeof sessionResources/\ sizeof sessionResources[0]) XrmDatabase DmResourceDB; @@ -486,7 +486,7 @@ LoadDisplayResources ( CleanUpName (d->name, dpyName, sizeof (dpyName)); CleanUpName (d->class ? d->class : d->name, dpyClass, sizeof (dpyClass)); for (i = 0; i < numResources; i++) { - snprintf (name, sizeof(name), "DisplayManager.%s.%s", + snprintf (name, sizeof(name), "DisplayManager.%s.%s", dpyName, resources[i].name); snprintf (class, sizeof(class), "DisplayManager.%s.%s", dpyClass, resources[i].class); @@ -35,13 +35,13 @@ from The Open Group. * generate SecureRPC authorization records */ -# include <X11/Xos.h> -# include <rpc/rpc.h> -# include <rpc/key_prot.h> +#include <X11/Xos.h> +#include <rpc/rpc.h> +#include <rpc/key_prot.h> -# include "dm.h" -# include "dm_auth.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_auth.h" +#include "dm_error.h" /*ARGSUSED*/ void @@ -33,16 +33,16 @@ from The Open Group. * server.c - manage the X server */ -# include "dm.h" -# include "dm_error.h" -# include "dm_socket.h" +#include "dm.h" +#include "dm_error.h" +#include "dm_socket.h" -# include <X11/Xlib.h> -# include <X11/Xos.h> -# include <stdio.h> -# include <signal.h> -# include <errno.h> -# include <sys/socket.h> +#include <X11/Xlib.h> +#include <X11/Xos.h> +#include <stdio.h> +#include <signal.h> +#include <errno.h> +#include <sys/socket.h> static int receivedUsr1; @@ -239,30 +239,30 @@ abortOpen (int n) #ifdef XDMCP -#ifdef STREAMSCONN -#include <tiuser.h> -#endif +# ifdef STREAMSCONN +# include <tiuser.h> +# endif static void GetRemoteAddress (struct display *d, int fd) { char buf[512]; int len = sizeof (buf); -#ifdef STREAMSCONN +# ifdef STREAMSCONN struct netbuf netb; -#endif +# endif if (d->peer) free ((char *) d->peer); -#ifdef STREAMSCONN +# ifdef STREAMSCONN netb.maxlen = sizeof(buf); netb.buf = buf; t_getname(fd, &netb, REMOTENAME); len = 8; /* lucky for us, t_getname returns something that looks like a sockaddr */ -#else +# else getpeername (fd, (struct sockaddr *) buf, (void *)&len); -#endif +# endif d->peerlen = 0; if (len) { @@ -378,7 +378,7 @@ PingServer (struct display *d, Display *alternateDpy) SIGVAL (*oldSig)(int); int oldAlarm; static Display *aDpy; - + aDpy = (alternateDpy != NULL ? alternateDpy : d->dpy); oldError = XSetIOErrorHandler (PingLostIOErr); oldAlarm = alarm (0); @@ -51,20 +51,20 @@ from The Open Group. #endif #ifndef USE_PAM /* PAM modules should handle these */ -#ifdef SECURE_RPC -# include <rpc/rpc.h> -# include <rpc/key_prot.h> -# if !HAVE_DECL_KEY_SETNET +# ifdef SECURE_RPC +# include <rpc/rpc.h> +# include <rpc/key_prot.h> +# if !HAVE_DECL_KEY_SETNET extern int key_setnet(struct key_netstarg *arg); +# endif +# endif +# ifdef K5AUTH +# include <krb5/krb5.h> # endif -#endif -#ifdef K5AUTH -# include <krb5/krb5.h> -#endif #endif /* USE_PAM */ #ifdef __SCO__ -#include <prot.h> +# include <prot.h> #endif #ifndef GREET_USER_STATIC @@ -606,27 +606,27 @@ StartClient ( #endif #ifndef AIXV3 -#ifndef HAS_SETUSERCONTEXT +# ifndef HAS_SETUSERCONTEXT if (setgid(verify->gid) < 0) { LogError ("setgid %d (user \"%s\") failed, errno=%d\n", verify->gid, name, errno); return (0); } -#if defined(BSD) && (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 +# 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() */ -#endif /* !HAS_SETUSERCONTEXT */ +# endif /* QNX4 doesn't support multi-groups, no initgroups() */ +# endif /* !HAS_SETUSERCONTEXT */ -#ifdef USE_PAM +# ifdef USE_PAM if (pamh) { long i; char **pam_env; @@ -645,15 +645,15 @@ StartClient ( } } -#endif +# endif -#ifndef HAS_SETUSERCONTEXT +# ifndef HAS_SETUSERCONTEXT if (setuid(verify->uid) < 0) { LogError ("setuid %d (user \"%s\") failed, errno=%d\n", verify->uid, name, errno); return (0); } -#else /* HAS_SETUSERCONTEXT */ +# else /* HAS_SETUSERCONTEXT */ /* * Set the user's credentials: uid, gid, groups, * environment variables, resource limits, and umask. @@ -670,7 +670,7 @@ StartClient ( LogError ("getpwnam for \"%s\" failed, errno=%d\n", name, errno); return (0); } -#endif /* HAS_SETUSERCONTEXT */ +# endif /* HAS_SETUSERCONTEXT */ #else /* AIXV3 */ /* * Set the user's credentials: uid, gid, groups, @@ -687,7 +687,7 @@ StartClient ( * for user-based authorization schemes, * use the password to get the user's credentials. */ -#ifdef SECURE_RPC +# ifdef SECURE_RPC /* do like "keylogin" program */ { char netname[MAXNETNAMELEN+1], secretkey[HEXKEYBYTES+1]; @@ -710,7 +710,7 @@ StartClient ( if (key_setnet(&netst) < 0) { Debug ("Could not set secret key.\n"); } - free(netst.st_netname); + free(netst.st_netname); /* is there a key, and do we have the right password? */ if (keyret == 1) { if (*secretkey) { @@ -741,8 +741,8 @@ StartClient ( } bzero(secretkey, strlen(secretkey)); } -#endif -#ifdef K5AUTH +# endif +# ifdef K5AUTH /* do like "kinit" program */ { int i, j; @@ -768,7 +768,7 @@ StartClient ( } } } -#endif /* K5AUTH */ +# endif /* K5AUTH */ #endif /* !USE_PAM */ if (d->windowPath) @@ -38,20 +38,20 @@ from the copyright holder. #include "dm_error.h" #ifdef XDMCP -#ifndef STREAMSCONN +# ifndef STREAMSCONN -#include <errno.h> -#include "dm_socket.h" +# include <errno.h> +# include "dm_socket.h" -#ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif -#endif -#include <netdb.h> -#include <arpa/inet.h> +# ifndef X_NO_SYS_UN +# ifndef Lynx +# include <sys/un.h> +# else +# include <un.h> +# endif +# endif +# include <netdb.h> +# include <arpa/inet.h> extern int chooserFd; @@ -67,10 +67,10 @@ CreateWellKnownSockets (void) if (request_port == 0) return; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) chooserFd = socket (AF_INET6, SOCK_STREAM, 0); if (chooserFd == -1) -#endif +# endif chooserFd = socket (AF_INET, SOCK_STREAM, 0); Debug ("Created chooser socket %d\n", chooserFd); if (chooserFd == -1) @@ -89,28 +89,28 @@ GetChooserAddr ( char *addr, int *lenp) { -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct sockaddr_storage in_addr; -#else +# else struct sockaddr_in in_addr; -#endif +# endif int len; int retval = 0; len = sizeof in_addr; - if (chooserFd < 0) + if (chooserFd < 0) return -1; /* TODO check other listening sockets */ if (getsockname (chooserFd, (struct sockaddr *)&in_addr, (void *)&len) < 0) return -1; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (((struct sockaddr *)&in_addr)->sa_family == AF_INET6) - Debug ("Chooser socket port: %d (IPv6)\n", + Debug ("Chooser socket port: %d (IPv6)\n", ntohs(((struct sockaddr_in6 *) &in_addr)->sin6_port)); else -#endif - Debug ("Chooser socket port: %d\n", +# endif + Debug ("Chooser socket port: %d\n", ntohs(((struct sockaddr_in *) &in_addr)->sin_port)); - if (*lenp < len) + if (*lenp < len) retval = -2; else memmove( addr, (char *) &in_addr, len); @@ -124,15 +124,15 @@ CreateListeningSocket (struct sockaddr *sock_addr, int salen) { int fd; const char *addrstring = "unknown"; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) char addrbuf[INET6_ADDRSTRLEN]; -#endif +# endif if (request_port == 0) return -1; if (debugLevel > 0) { -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) void *ipaddr; if (sock_addr->sa_family == AF_INET6) { ipaddr = & ((struct sockaddr_in6 *) sock_addr)->sin6_addr; @@ -142,11 +142,11 @@ CreateListeningSocket (struct sockaddr *sock_addr, int salen) addrstring = inet_ntop(sock_addr->sa_family, ipaddr, addrbuf, sizeof(addrbuf)); -#else +# else addrstring = inet_ntoa(((struct sockaddr_in *) sock_addr)->sin_addr); -#endif +# endif - Debug ("creating socket to listen on port %d of address %s\n", + Debug ("creating socket to listen on port %d of address %s\n", request_port,addrstring); } @@ -222,16 +222,16 @@ FindInList(struct socklist *list, ARRAY8Ptr addr) addrdata = (char *) &(((struct sockaddr_in *)s->addr)->sin_addr.s_addr); break; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: addrdata = (char *) &(((struct sockaddr_in6 *)s->addr)->sin6_addr.s6_addr); break; -#endif +# endif default: /* Unrecognized address family */ continue; - } + } if (memcmp(addrdata, addr->data, addr->length) == 0) { return s; } @@ -251,7 +251,7 @@ CreateSocklistEntry(ARRAY8Ptr addr) bzero(s, sizeof(struct socklist)); - if (addr->length == 4) /* IPv4 */ + if (addr->length == 4) /* IPv4 */ { struct sockaddr_in *sin; sin = malloc (sizeof(struct sockaddr_in)); @@ -263,38 +263,38 @@ CreateSocklistEntry(ARRAY8Ptr addr) s->addr = (struct sockaddr *) sin; bzero (sin, sizeof (struct sockaddr_in)); -#ifdef BSD44SOCKETS +# ifdef BSD44SOCKETS sin->sin_len = sizeof(struct sockaddr_in); -#endif +# endif s->salen = sizeof(struct sockaddr_in); s->addrlen = sizeof(struct in_addr); sin->sin_family = AF_INET; sin->sin_port = htons ((short) request_port); memcpy(&sin->sin_addr, addr->data, addr->length); } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) else if (addr->length == 16) /* IPv6 */ { struct sockaddr_in6 *sin6; sin6 = malloc (sizeof(struct sockaddr_in6)); if (sin6 == NULL) { LogOutOfMem("CreateSocklistEntry"); - free(s); + free(s); return NULL; } s->addr = (struct sockaddr *) sin6; bzero (sin6, sizeof (struct sockaddr_in6)); -#ifdef SIN6_LEN +# ifdef SIN6_LEN sin6->sin6_len = sizeof(struct sockaddr_in6); -#endif +# endif s->salen = sizeof(struct sockaddr_in6); s->addrlen = sizeof(struct in6_addr); sin6->sin6_family = AF_INET6; sin6->sin6_port = htons ((short) request_port); memcpy(&sin6->sin6_addr, addr->data, addr->length); - } -#endif + } +# endif else { /* Unknown address type */ free(s); @@ -303,7 +303,7 @@ CreateSocklistEntry(ARRAY8Ptr addr) return s; } -static void +static void UpdateListener(ARRAY8Ptr addr, void **closure) { struct socklist *s; @@ -313,20 +313,20 @@ UpdateListener(ARRAY8Ptr addr, void **closure) if (addr == NULL || addr->length == 0) { ARRAY8 tmpaddr; struct in_addr in; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct in6_addr in6 = in6addr_any; tmpaddr.length = sizeof(in6); tmpaddr.data = (CARD8Ptr) &in6; UpdateListener(&tmpaddr, closure); if (*closure) return; -#endif +# endif in.s_addr = htonl (INADDR_ANY); tmpaddr.length = sizeof(in); tmpaddr.data = (CARD8Ptr) ∈ UpdateListener(&tmpaddr, closure); return; } - + s = FindInList(listensocks, addr); if (s) { @@ -334,7 +334,7 @@ UpdateListener(ARRAY8Ptr addr, void **closure) s->ref = 1; return; } - + s = CreateSocklistEntry(addr); if (s == NULL) @@ -352,24 +352,24 @@ UpdateListener(ARRAY8Ptr addr, void **closure) *closure = (void *) s; } -#define JOIN_MCAST_GROUP 0 -#define LEAVE_MCAST_GROUP 1 +# define JOIN_MCAST_GROUP 0 +# define LEAVE_MCAST_GROUP 1 static void ChangeMcastMembership(struct socklist *s, struct socklist *g, int op) { int sockopt; - switch (s->addr->sa_family) + switch (s->addr->sa_family) { case AF_INET: { struct ip_mreq mreq; - memcpy(&mreq.imr_multiaddr, - &((struct sockaddr_in *) g->addr)->sin_addr, + memcpy(&mreq.imr_multiaddr, + &((struct sockaddr_in *) g->addr)->sin_addr, sizeof(struct in_addr)); memcpy(&mreq.imr_interface, - &((struct sockaddr_in *) s->addr)->sin_addr, + &((struct sockaddr_in *) s->addr)->sin_addr, sizeof(struct in_addr)); if (op == JOIN_MCAST_GROUP) { sockopt = IP_ADD_MEMBERSHIP; @@ -383,24 +383,24 @@ ChangeMcastMembership(struct socklist *s, struct socklist *g, int op) inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr), errno); } else if (debugLevel > 0) { - Debug ("XDMCP socket multicast %s to %s succeeded\n", + Debug ("XDMCP socket multicast %s to %s succeeded\n", (op == JOIN_MCAST_GROUP) ? "join" : "drop", inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr)); } return; } -#if defined(IPv6) && defined(AF_INET6) -#ifndef IPV6_JOIN_GROUP -#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP -#endif -#ifndef IPV6_LEAVE_GROUP -#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP -#endif +# if defined(IPv6) && defined(AF_INET6) +# ifndef IPV6_JOIN_GROUP +# define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP +# endif +# ifndef IPV6_LEAVE_GROUP +# define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP +# endif case AF_INET6: { struct ipv6_mreq mreq6; - memcpy(&mreq6.ipv6mr_multiaddr, - &((struct sockaddr_in6 *) g->addr)->sin6_addr, + memcpy(&mreq6.ipv6mr_multiaddr, + &((struct sockaddr_in6 *) g->addr)->sin6_addr, sizeof(struct in6_addr)); mreq6.ipv6mr_interface = 0; /* TODO: fix this */ if (op == JOIN_MCAST_GROUP) { @@ -413,7 +413,7 @@ ChangeMcastMembership(struct socklist *s, struct socklist *g, int op) int saveerr = errno; char addrbuf[INET6_ADDRSTRLEN]; - inet_ntop(s->addr->sa_family, + inet_ntop(s->addr->sa_family, &((struct sockaddr_in6 *) g->addr)->sin6_addr, addrbuf, sizeof(addrbuf)); @@ -423,26 +423,26 @@ ChangeMcastMembership(struct socklist *s, struct socklist *g, int op) } else if (debugLevel > 0) { char addrbuf[INET6_ADDRSTRLEN]; - inet_ntop(s->addr->sa_family, + inet_ntop(s->addr->sa_family, &((struct sockaddr_in6 *) g->addr)->sin6_addr, addrbuf, sizeof(addrbuf)); - Debug ("XDMCP socket multicast %s to %s succeeded\n", + Debug ("XDMCP socket multicast %s to %s succeeded\n", (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf); } return; } -#endif +# endif } } -static void +static void UpdateMcastGroup(ARRAY8Ptr addr, void **closure) { struct socklist *s = (struct socklist *) *closure; struct socklist *g; - if (s == NULL) + if (s == NULL) return; g = FindInList(s->mcastgroups, addr); @@ -497,7 +497,7 @@ void UpdateListenSockets (void) } } } - } + } } /* Close all additional listening sockets beyond the basic chooserFd and @@ -523,8 +523,8 @@ void ProcessListenSockets (fd_set *readmask) for (s = listensocks; s != NULL; s = s->next) { if (FD_ISSET(s->fd, readmask)) ProcessRequestSocket(s->fd); - } + } } -#endif /* !STREAMSCONN */ +# endif /* !STREAMSCONN */ #endif /* XDMCP */ @@ -37,12 +37,12 @@ from The Open Group. #include "dm_error.h" #ifdef XDMCP -#ifdef STREAMSCONN +# ifdef STREAMSCONN -#include <fcntl.h> -#include <tiuser.h> -#include <netconfig.h> -#include <netdir.h> +# include <fcntl.h> +# include <tiuser.h> +# include <netconfig.h> +# include <netdir.h> extern int xdmcpFd; extern int chooserFd; @@ -163,5 +163,5 @@ void ProcessListenSockets (fd_set *readmask) return; } -#endif /* STREAMSCONN */ +# endif /* STREAMSCONN */ #endif /* XDMCP */ @@ -35,23 +35,23 @@ from The Open Group. * various utility routines */ -# include "dm.h" -# include "dm_error.h" +#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> -#undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE X_POSIX_C_SOURCE +# include <signal.h> +# undef _POSIX_C_SOURCE #else -#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) -#include <signal.h> -#else -#define _POSIX_SOURCE -#include <signal.h> -#undef _POSIX_SOURCE -#endif +# if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +# include <signal.h> +# else +# define _POSIX_SOURCE +# include <signal.h> +# undef _POSIX_SOURCE +# endif #endif #ifndef HAVE_ASPRINTF @@ -171,21 +171,21 @@ 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; @@ -204,7 +204,7 @@ freeEnv (char **env) } } -# define isblank(c) ((c) == ' ' || c == '\t') +#define isblank(c) ((c) == ' ' || c == '\t') char ** parseArgs (char **argv, char *string) @@ -54,13 +54,13 @@ XdmPrintDataHex (char *s, char *a, int l) Debug ("\n"); } -#ifdef XDMCP +# ifdef XDMCP static void XdmPrintArray8Hex (char *s, ARRAY8Ptr a) { XdmPrintDataHex (s, (char *) a->data, a->length); } -#endif +# endif void XdmInitAuth (unsigned short name_len, char *name) @@ -72,7 +72,7 @@ XdmInitAuth (unsigned short name_len, char *name) } /* - * Generate authorization for XDM-AUTHORIZATION-1 + * Generate authorization for XDM-AUTHORIZATION-1 * * When being used with XDMCP, 8 bytes are generated for the session key * (sigma), as the random number (rho) is already shared between xdm and @@ -135,10 +135,10 @@ XdmGetAuth (unsigned short namelen, char *name) return XdmGetAuthHelper (namelen, name, TRUE); } -#ifdef XDMCP +# ifdef XDMCP void -XdmGetXdmcpAuth (struct protoDisplay *pdpy, +XdmGetXdmcpAuth (struct protoDisplay *pdpy, unsigned short authorizationNameLen, char *authorizationName) { Xauth *fileauth, *xdmcpauth; @@ -186,7 +186,7 @@ XdmGetXdmcpAuth (struct protoDisplay *pdpy, pdpy->xdmcpAuthorization = xdmcpauth; } -#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \ +# define atox(c) ('0' <= c && c <= '9' ? c - '0' : \ 'a' <= c && c <= 'f' ? c - 'a' + 10 : \ 'A' <= c && c <= 'F' ? c - 'A' + 10 : -1) @@ -261,7 +261,7 @@ XdmGetKey(struct protoDisplay *pdpy, ARRAY8Ptr displayID) /*ARGSUSED*/ int -XdmCheckAuthentication(struct protoDisplay *pdpy, ARRAY8Ptr displayID, +XdmCheckAuthentication(struct protoDisplay *pdpy, ARRAY8Ptr displayID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData) { XdmAuthKeyPtr incoming; @@ -282,5 +282,5 @@ XdmCheckAuthentication(struct protoDisplay *pdpy, ARRAY8Ptr displayID, return TRUE; } -#endif /* XDMCP */ +# endif /* XDMCP */ #endif /* HASXDMAUTH (covering the entire file) */ @@ -33,9 +33,9 @@ from The Open Group. * xdmcp.c - Support for XDMCP */ -# include "dm.h" -# include "dm_auth.h" -# include "dm_error.h" +#include "dm.h" +#include "dm_auth.h" +#include "dm_error.h" #ifdef XDMCP @@ -46,20 +46,20 @@ from The Open Group. # include "dm_socket.h" -#ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif -#endif -#include <netdb.h> -#include <arpa/inet.h> +# ifndef X_NO_SYS_UN +# ifndef Lynx +# include <sys/un.h> +# else +# include <un.h> +# endif +# endif +# include <netdb.h> +# include <arpa/inet.h> -#include <time.h> -#define Time_t time_t +# include <time.h> +# define Time_t time_t -#define getString(name,len) ((name = malloc (len + 1)) ? 1 : 0) +# define getString(name,len) ((name = malloc (len + 1)) ? 1 : 0) /* * misc externs @@ -83,44 +83,44 @@ static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID, i static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd); static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd); -#ifdef STREAMSCONN +# ifdef STREAMSCONN int xdmcpFd = -1; -#endif +# endif int chooserFd = -1; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) int chooserFd6 = -1; -#endif +# endif FD_TYPE WellKnownSocketsMask; int WellKnownSocketsMax; -#define pS(s) ((s) ? ((char *) (s)) : "empty string") +# define pS(s) ((s) ? ((char *) (s)) : "empty string") void DestroyWellKnownSockets (void) { -#ifdef STREAMSCONN +# ifdef STREAMSCONN if (xdmcpFd != -1) { close (xdmcpFd); FD_CLR(xdmcpFd, &WellKnownSocketsMask); xdmcpFd = -1; } -#endif +# endif if (chooserFd != -1) { close (chooserFd); FD_CLR(chooserFd, &WellKnownSocketsMask); chooserFd = -1; } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (chooserFd6 != -1) { close (chooserFd6); FD_CLR(chooserFd6, &WellKnownSocketsMask); chooserFd6 = -1; } -#endif +# endif CloseListenSockets(); } @@ -140,13 +140,13 @@ FD_ANYSET(fd_set *fds) int AnyWellKnownSockets (void) { - return -#ifdef STREAMS_CONN + return +# ifdef STREAMS_CONN xdmcpFd != -1 || -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) chooserFd6 != -1 || -#endif +# endif chooserFd != -1 || FD_ANYSET(&WellKnownSocketsMask); } @@ -159,26 +159,26 @@ sendForward ( ARRAY8Ptr address, char *closure) { -#ifdef AF_INET +# ifdef AF_INET struct sockaddr_in in_addr; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) struct sockaddr_in6 in6_addr; -#endif -#ifdef AF_DECnet -#endif +# endif +# ifdef AF_DECnet +# endif struct sockaddr *addr; int addrlen; switch (connectionType) { -#ifdef AF_INET +# ifdef AF_INET case FamilyInternet: addr = (struct sockaddr *) &in_addr; bzero ((char *) &in_addr, sizeof (in_addr)); -#ifdef BSD44SOCKETS +# ifdef BSD44SOCKETS in_addr.sin_len = sizeof(in_addr); -#endif +# endif in_addr.sin_family = AF_INET; in_addr.sin_port = htons ((short) XDM_UDP_PORT); if (address->length != 4) @@ -186,14 +186,14 @@ sendForward ( memmove( (char *) &in_addr.sin_addr, address->data, address->length); addrlen = sizeof (struct sockaddr_in); break; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) case FamilyInternet6: addr = (struct sockaddr *) &in6_addr; bzero ((char *) &in6_addr, sizeof (in6_addr)); -#ifdef SIN6_LEN +# ifdef SIN6_LEN in6_addr.sin6_len = sizeof(in6_addr); -#endif +# endif in6_addr.sin6_family = AF_INET6; in6_addr.sin6_port = htons ((short) XDM_UDP_PORT); if (address->length != 16) @@ -201,10 +201,10 @@ sendForward ( memmove( (char *) &in6_addr.sin6_addr, address->data, address->length); addrlen = sizeof (struct sockaddr_in6); break; -#endif -#ifdef AF_DECnet +# endif +# ifdef AF_DECnet case FamilyDECnet: -#endif +# endif default: return; } @@ -250,14 +250,14 @@ all_query_respond ( int family; int length; const char *addrstring; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) char addrbuf[INET6_ADDRSTRLEN] = ""; -#endif +# endif family = ConvertAddr((XdmcpNetaddr) from, &length, (char **)&(addr.data)); addr.length = length; /* convert int to short */ if (debugLevel > 0) { -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) void *ipaddr; int af_type; if (family == FamilyInternet6) { @@ -268,9 +268,9 @@ all_query_respond ( af_type = AF_INET; } addrstring = inet_ntop(af_type, ipaddr, addrbuf, sizeof(addrbuf)); -#else +# else addrstring = inet_ntoa(((struct sockaddr_in *)from)->sin_addr); -#endif +# endif Debug("all_query_respond: conntype=%d, addr=%s, len=%d\n", family, addrstring, addr.length); } @@ -307,7 +307,7 @@ indirect_respond ( int i; XdmcpHeader header; int localHostAsWell; - + Debug ("Indirect respond %d\n", length); if (!XdmcpReadARRAYofARRAY8 (&buffer, &queryAuthenticationNames)) return; @@ -334,7 +334,7 @@ indirect_respond ( XdmcpWriteARRAYofARRAY8 (&buffer, &queryAuthenticationNames); localHostAsWell = ForEachMatchingIndirectHost (&clientAddress, connectionType, sendForward, (char *) &fd); - + XdmcpDisposeARRAY8 (&clientAddress); XdmcpDisposeARRAY8 (&clientPort); if (localHostAsWell) @@ -352,11 +352,11 @@ void ProcessRequestSocket (int fd) { XdmcpHeader header; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct sockaddr_storage addr; -#else +# else struct sockaddr addr; -#endif +# endif int addrlen = sizeof addr; Debug ("ProcessRequestSocket\n"); @@ -415,32 +415,32 @@ WaitForSomething (void) nready, Rescan, ChildReady); if (nready > 0) { -#ifdef STREAMSCONN +# ifdef STREAMSCONN if (xdmcpFd >= 0 && FD_ISSET (xdmcpFd, &reads)) ProcessRequestSocket (xdmcpFd); -#endif +# endif if (chooserFd >= 0 && FD_ISSET (chooserFd, &reads)) { -#ifdef ISC +# ifdef ISC if (!ChildReady) { WaitForSomething (); } else -#endif +# endif ProcessChooserSocket (chooserFd); FD_CLR(chooserFd, &reads); } -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (chooserFd6 >= 0 && FD_ISSET (chooserFd6, &reads)) { -#ifdef ISC +# ifdef ISC if (!ChildReady) { WaitForSomething (); } else -#endif +# endif ProcessChooserSocket (chooserFd6); FD_CLR(chooserFd6, &reads); } -#endif +# endif ProcessListenSockets(&reads); } if (ChildReady) @@ -481,7 +481,7 @@ direct_query_respond ( ARRAYofARRAY8 queryAuthenticationNames = {0, NULL}; int expectedLen; int i; - + if (!XdmcpReadARRAYofARRAY8 (&buffer, &queryAuthenticationNames)) return; expectedLen = 1; @@ -525,7 +525,7 @@ NetworkAddressToName( switch (connectionType) { case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case FamilyInternet6: { CARD8 *data; @@ -567,10 +567,10 @@ NetworkAddressToName( localhost = localHostname (); - /* - * protect against bogus host names + /* + * protect against bogus host names */ - if (hostname && hostname[0] && (hostname[0] != '.') + if (hostname && hostname[0] && (hostname[0] != '.') && !multiHomed) { if (!strcmp (localhost, hostname)) @@ -586,7 +586,7 @@ NetworkAddressToName( if (removeDomainname) { char *localDot, *remoteDot; - + /* check for a common domain name. This * could reduce names by recognising common * super-domain names as well, but I don't think @@ -621,11 +621,11 @@ NetworkAddressToName( } if (multiHomed) { if (connectionType == FamilyInternet) { - data = (CARD8 *) + data = (CARD8 *) &((struct sockaddr_in *)originalAddress)-> sin_addr; } else { - data = (CARD8 *) + data = (CARD8 *) &((struct sockaddr_in6 *)originalAddress)->sin6_addr; } } @@ -634,14 +634,14 @@ NetworkAddressToName( if (ai) freeaddrinfo(ai); return NULL; - } + } snprintf(name + strlen(name), 10, ":%d", displayNumber); } if (ai) freeaddrinfo(ai); return name; } -#else /* IPv6 */ +# else /* IPv6 */ { CARD8 *data; struct hostent *hostent; @@ -660,11 +660,11 @@ NetworkAddressToName( localhost = localHostname (); - /* - * protect against bogus host names + /* + * 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)) @@ -678,7 +678,7 @@ NetworkAddressToName( if (removeDomainname) { char *localDot, *remoteDot; - + /* check for a common domain name. This * could reduce names by recognising common * super-domain names as well, but I don't think @@ -716,11 +716,11 @@ NetworkAddressToName( } return name; } -#endif /* IPv6 */ -#ifdef DNET +# endif /* IPv6 */ +# ifdef DNET case FamilyDECnet: return NULL; -#endif /* DNET */ +# endif /* DNET */ default: return NULL; } @@ -741,7 +741,7 @@ forward_respond ( int clientlen; int expectedLen; int i; - + Debug ("Forward respond %d\n", length); if (XdmcpReadARRAY8 (&buffer, &clientAddress) && XdmcpReadARRAY8 (&buffer, &clientPort) && @@ -766,7 +766,7 @@ forward_respond ( Debug ("\n"); switch (from->sa_family) { -#ifdef AF_INET +# ifdef AF_INET case AF_INET: { struct sockaddr_in in_addr; @@ -777,9 +777,9 @@ forward_respond ( goto badAddress; } bzero ((char *) &in_addr, sizeof (in_addr)); -#ifdef BSD44SOCKETS +# ifdef BSD44SOCKETS in_addr.sin_len = sizeof(in_addr); -#endif +# endif in_addr.sin_family = AF_INET; memmove( &in_addr.sin_addr, clientAddress.data, 4); memmove( (char *) &in_addr.sin_port, clientPort.data, 2); @@ -789,8 +789,8 @@ forward_respond ( FORWARD_QUERY, fd); } break; -#endif -#if defined(IPv6) && defined(AF_INET6) +# endif +# if defined(IPv6) && defined(AF_INET6) case AF_INET6: { struct sockaddr_in6 in6_addr; @@ -801,9 +801,9 @@ forward_respond ( goto badAddress; } bzero ((char *) &in6_addr, sizeof (in6_addr)); -#ifdef SIN6_LEN +# ifdef SIN6_LEN in6_addr.sin6_len = sizeof(in6_addr); -#endif +# endif in6_addr.sin6_family = AF_INET6; memmove(&in6_addr.sin6_addr,clientAddress.data,clientAddress.length); memmove((char *) &in6_addr.sin6_port, clientPort.data, 2); @@ -813,8 +813,8 @@ forward_respond ( FORWARD_QUERY, fd); } break; -#endif -#ifdef AF_UNIX +# endif +# ifdef AF_UNIX case AF_UNIX: { struct sockaddr_un un_addr; @@ -826,25 +826,25 @@ forward_respond ( memmove( un_addr.sun_path, clientAddress.data, clientAddress.length); un_addr.sun_path[clientAddress.length] = '\0'; client = (struct sockaddr *) &un_addr; -#if defined(BSD44SOCKETS) && !defined(Lynx) && defined(UNIXCONN) +# if defined(BSD44SOCKETS) && !defined(Lynx) && defined(UNIXCONN) un_addr.sun_len = strlen(un_addr.sun_path); clientlen = SUN_LEN(&un_addr); -#else +# else clientlen = sizeof (un_addr); -#endif +# endif all_query_respond (client, clientlen, &authenticationNames, FORWARD_QUERY, fd); } break; -#endif -#ifdef AF_CHAOS +# endif +# ifdef AF_CHAOS case AF_CHAOS: goto badAddress; -#endif -#ifdef AF_DECnet +# endif +# ifdef AF_DECnet case AF_DECnet: goto badAddress; -#endif +# endif } } else @@ -912,7 +912,7 @@ send_unwilling ( static unsigned long globalSessionID; -#define NextSessionID() (++globalSessionID) +# define NextSessionID() (++globalSessionID) void init_session_id(void) { @@ -922,7 +922,7 @@ void init_session_id(void) */ globalSessionID = (time((Time_t *)0)&0x7fff) * 16000; } - + static ARRAY8 outOfMemory = { (CARD16) 13, (CARD8Ptr) "Out of memory" }; static ARRAY8 noValidAddr = { (CARD16) 16, (CARD8Ptr) "No valid address" }; static ARRAY8 noValidAuth = { (CARD16) 22, (CARD8Ptr) "No valid authorization" }; @@ -997,7 +997,7 @@ request_respond ( reason = &noValidAddr; goto decline; } - + /* The Manager considers this a new session */ connectionAddress = &connectionAddresses.data[i]; pdpy = NewProtoDisplay ((XdmcpNetaddr) from, fromlen, displayNumber, @@ -1100,7 +1100,7 @@ send_accept ( XdmcpWriteARRAY8 (&buffer, authorizationData); XdmcpFlush (fd, &buffer, (XdmcpNetaddr) to, tolen); } - + static void send_decline ( struct sockaddr *to, @@ -1171,7 +1171,7 @@ manage ( * If all this is true, then we have a duplicate request that * can be ignored. */ - if (!pdpy + if (!pdpy && (d = FindDisplayByAddress((XdmcpNetaddr) from, fromlen, displayNumber)) && d->sessionID == sessionID) { Debug("manage: got duplicate pkt, ignoring\n"); @@ -1192,7 +1192,7 @@ manage ( name, (char *)pdpy->connectionAddress.data); if (!name) { - send_failed (from, fromlen, "(no name)", sessionID, + send_failed (from, fromlen, "(no name)", sessionID, "out of memory", fd); goto abort; } @@ -1205,7 +1205,7 @@ manage ( class = malloc (displayClass.length + 1); if (!class) { - send_failed (from, fromlen, name, sessionID, + send_failed (from, fromlen, name, sessionID, "out of memory", fd); goto abort; } @@ -1231,7 +1231,7 @@ manage ( if (!d) { free ((char *) from_save); - send_failed (from, fromlen, name, sessionID, + send_failed (from, fromlen, name, sessionID, "out of memory", fd); goto abort; } @@ -1290,7 +1290,7 @@ SendFailed ( char *reason) { Debug ("Display start failed, sending Failed\n"); - send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, + send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, d->sessionID, reason, d->xdmcpFd); } @@ -1393,24 +1393,24 @@ NetworkAddressToHostname ( switch (connectionType) { case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) case FamilyInternet6: -#endif +# endif { struct hostent *hostent = NULL; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) char dotted[INET6_ADDRSTRLEN]; -#else +# else char dotted[20]; -#endif +# endif char *local_name = ""; int af_type; -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) if (connectionType == FamilyInternet6) af_type = AF_INET6; else -#endif +# endif af_type = AF_INET; hostent = gethostbyaddr ((char *)connectionAddress->data, @@ -1418,7 +1418,7 @@ NetworkAddressToHostname ( if (hostent) { /* check for DNS spoofing */ -#if defined(IPv6) && defined(AF_INET6) +# if defined(IPv6) && defined(AF_INET6) struct addrinfo *ai = NULL, *nai; if (getaddrinfo(hostent->h_name, NULL, NULL, &ai) == 0) { for (nai = ai; nai != NULL; nai = nai->ai_next) { @@ -1436,7 +1436,7 @@ NetworkAddressToHostname ( break; } if (nai == NULL) { - inet_ntop(af_type, connectionAddress->data, + inet_ntop(af_type, connectionAddress->data, dotted, sizeof(dotted)); LogError("Possible DNS spoof attempt %s->%s.\n", dotted, @@ -1449,7 +1449,7 @@ NetworkAddressToHostname ( } else { hostent = NULL; } -#else +# else char *s = strdup(hostent->h_name); /* fscking non-reentrancy of getXXX() */ if ((hostent = gethostbyname(s))) { if (memcmp((char*)connectionAddress->data, hostent->h_addr, @@ -1461,21 +1461,21 @@ NetworkAddressToHostname ( } } free(s); -#endif +# endif } if (!hostent) { /* can't get name, so use emergency fallback */ -#if defined(IPv6) && defined(AF_INET6) - inet_ntop(af_type, connectionAddress->data, +# if defined(IPv6) && defined(AF_INET6) + inet_ntop(af_type, connectionAddress->data, dotted, sizeof(dotted)); -#else +# else snprintf(dotted, sizeof(dotted), "%d.%d.%d.%d", connectionAddress->data[0], connectionAddress->data[1], connectionAddress->data[2], connectionAddress->data[3]); -#endif +# endif local_name = dotted; LogError ("Cannot convert Internet address %s to host name\n", dotted); @@ -1483,17 +1483,17 @@ NetworkAddressToHostname ( name = strdup (local_name); break; } -#ifdef DNET +# ifdef DNET case FamilyDECnet: break; -#endif /* DNET */ +# endif /* DNET */ default: break; } return name; } -#if 0 +# if 0 static int HostnameToNetworkAddress ( char *name, @@ -1514,10 +1514,10 @@ ARRAY8Ptr connectionAddress) memmove( connectionAddress->data, hostent->h_addr, hostent->h_length); return TRUE; } -#ifdef DNET +# ifdef DNET case FamilyDECnet: return FALSE; -#endif +# endif } return FALSE; } @@ -1558,10 +1558,10 @@ CARD16Ptr displayNumber) dnet = TRUE; colon++; } -#ifndef DNETCONN +# ifndef DNETCONN if (dnet) return FALSE; -#endif +# endif display_number = colon + 1; while (*display_number && *display_number != '.') { @@ -1571,11 +1571,11 @@ CARD16Ptr displayNumber) if (display_number == colon + 1) return FALSE; number = atoi (colon + 1); -#ifdef DNETCONN +# ifdef DNETCONN if (dnet) connectionType = FamilyDECnet; else -#endif +# endif connectionType = FamilyInternet; if (!HostnameToNetworkAddress (hostname, connectionType, connectionAddress)) return FALSE; @@ -1583,6 +1583,6 @@ CARD16Ptr displayNumber) *connectionTypep = connectionType; return TRUE; } -#endif +# endif #endif /* XDMCP */ @@ -1,7 +1,7 @@ /* * xdmshell - simple program for running xdm from login * - * + * Copyright 1988, 1998 The Open Group Permission to use, copy, modify, distribute, and sell this software and its @@ -40,7 +40,7 @@ in this Software without prior written authorization from The Open Group. #include <unistd.h> #ifndef BINDIR -#define BINDIR "/usr/bin/X11" +# define BINDIR "/usr/bin/X11" #endif /* @@ -51,7 +51,7 @@ in this Software without prior written authorization from The Open Group. #endif #ifndef HAS_VFORK -#define vfork() fork() +# define vfork() fork() #endif static char *ProgramName; @@ -66,7 +66,7 @@ static int exec_args ( if (!filename) return -1; if (filename[0] != '/') { - fprintf (stderr, + fprintf (stderr, "%s: attempt to execute program with relative pathname: %s\n", ProgramName, filename); return -1; @@ -119,13 +119,13 @@ main ( ttyfd = open ("/dev/tty", O_RDWR, 0); if (ttyfd < 3) { /* stdin = 0, stdout = 1, stderr = 2 */ - fprintf (stderr, + fprintf (stderr, "%s: must be run directly from the console.\r\n", ProgramName); exit (1); } (void) close (ttyfd); - + /* make xdm run in a non-setuid environment */ if (setuid (geteuid()) == -1) { fprintf(stderr, "%s: cannot setuid (error %d, %s)\r\n", |