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 /auth.c | |
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>
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 216 |
1 files changed, 108 insertions, 108 deletions
@@ -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) { |