diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2011-10-01 18:25:22 +0200 |
---|---|---|
committer | Matthieu Herrb <matthieu.herrb@laas.fr> | 2011-10-01 18:25:22 +0200 |
commit | 8edbf66b8e869a66070859362dadee77b3511eeb (patch) | |
tree | a862a11e0095d1aa56619dea1a579e84356a9111 /Xtransutil.c | |
parent | 9cadbc0e912148a93c45634f551a79c427ccadba (diff) | |
parent | 0f942e5f015cb3270e6f2e17c308bee894cb5fe3 (diff) |
Merge remote-tracking branch 'origin/master' into obsd
Conflicts:
Xtranssock.c
Xtransutil.c
Diffstat (limited to 'Xtransutil.c')
-rw-r--r-- | Xtransutil.c | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/Xtransutil.c b/Xtransutil.c index 6b2b4d8..b0f1a9f 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -91,7 +91,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG(2,"ConvertAddress(%d,%d,%x)\n",*familyp,*addrlenp,*addrp); + prmsg(2,"ConvertAddress(%d,%d,%p)\n",*familyp,*addrlenp,*addrp); switch( *familyp ) { @@ -142,7 +142,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) { *familyp=FamilyLocal; } - else + else { *familyp=FamilyInternet; *addrlenp = sizeof (struct in_addr); @@ -161,7 +161,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) #endif /* defined(TCPCONN) || defined(STREAMSCONN) */ -#if defined(UNIXCONN) || defined(LOCALCONN) +#if defined(UNIXCONN) || defined(LOCALCONN) case AF_UNIX: { *familyp=FamilyLocal; @@ -178,8 +178,8 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) #endif default: - PRMSG(1,"ConvertAddress: Unknown family type %d\n", - *familyp, 0,0 ); + prmsg(1,"ConvertAddress: Unknown family type %d\n", + *familyp); return -1; } @@ -190,7 +190,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) * In the case of a local connection, we need to get the * host name for authentication. */ - + char hostnamebuf[256]; int len = TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf); @@ -242,7 +242,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) char *addr = ciptr->addr; char hostnamebuf[256]; char *networkId = NULL; - char *transName = ciptr->transptr->TransName; + const char *transName = ciptr->transptr->TransName; size_t len; if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0) @@ -252,7 +252,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) switch (family) { -#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) +#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) case AF_UNIX: { struct sockaddr_un *saddr = (struct sockaddr_un *) addr; @@ -320,7 +320,7 @@ int void #endif #endif -nameserver_lost(int sig) +nameserver_lost(int sig _X_UNUSED) { nameserver_timedout = 1; longjmp (env, -1); @@ -346,7 +346,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) switch (family) { case AF_UNSPEC: -#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) +#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) case AF_UNIX: { if (gethostname (addrbuf, sizeof (addrbuf)) == 0) @@ -391,7 +391,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds * that something is wrong and do not make the user wait. * gethostbyaddr will continue after a signal, so we have to - * jump out of it. + * jump out of it. */ nameserver_timedout = 0; @@ -435,13 +435,13 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) #endif /* ICE_t */ -#if defined(WIN32) && defined(TCPCONN) +#if defined(WIN32) && defined(TCPCONN) int TRANS(WSAStartup) (void) { static WSADATA wsadata; - PRMSG (2,"WSAStartup()\n", 0, 0, 0); + prmsg (2,"WSAStartup()\n"); if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata)) return 1; @@ -482,15 +482,15 @@ is_numeric (const char *str) * it's not save if the directory has non-root ownership or the sticky * bit cannot be set and fail. */ -static int +static int trans_mkdir(const char *path, int mode) { struct stat buf; if (lstat(path, &buf) != 0) { if (errno != ENOENT) { - PRMSG(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n", - path, errno, 0); + prmsg(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n", + path, errno); return -1; } /* Dir doesn't exist. Try to create it */ @@ -503,15 +503,15 @@ trans_mkdir(const char *path, int mode) */ if (geteuid() != 0) { if (mode & 01000) { - PRMSG(1, "mkdir: ERROR: euid != 0," + prmsg(1, "mkdir: ERROR: euid != 0," "directory %s will not be created.\n", - path, 0, 0); + path); #ifdef FAIL_HARD return -1; #endif } else { - PRMSG(1, "mkdir: Cannot create %s with root ownership\n", - path, 0, 0); + prmsg(1, "mkdir: Cannot create %s with root ownership\n", + path); } } #endif @@ -519,8 +519,8 @@ trans_mkdir(const char *path, int mode) #ifndef WIN32 if (mkdir(path, mode) == 0) { if (chmod(path, mode)) { - PRMSG(1, "mkdir: ERROR: Mode of %s should be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: ERROR: Mode of %s should be set to %04o\n", + path, mode); #ifdef FAIL_HARD return -1; #endif @@ -529,13 +529,13 @@ trans_mkdir(const char *path, int mode) if (mkdir(path) == 0) { #endif } else { - PRMSG(1, "mkdir: ERROR: Cannot create %s\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: Cannot create %s\n", + path); return -1; } return 0; - + } else { if (S_ISDIR(buf.st_mode)) { int updateOwner = 0; @@ -554,7 +554,7 @@ trans_mkdir(const char *path, int mode) */ if ((~mode) & 0077 & buf.st_mode) updateMode = 1; - + /* * If the directory is not writeable not everybody may * be able to create sockets. Therefore warn if mode @@ -564,7 +564,7 @@ trans_mkdir(const char *path, int mode) updateMode = 1; status |= WARN_NO_ACCESS; } - + /* * If 'sticky' bit is requested fail if owner isn't root * as we assume the caller makes certain security implications @@ -576,7 +576,7 @@ trans_mkdir(const char *path, int mode) updateMode = 1; } } - + #ifdef HAS_FCHOWN /* * If fchown(2) and fchmod(2) are available, try to correct the @@ -588,8 +588,8 @@ trans_mkdir(const char *path, int mode) struct stat fbuf; if ((fd = open(path, O_RDONLY)) != -1) { if (fstat(fd, &fbuf) == -1) { - PRMSG(1, "mkdir: ERROR: fstat failed for %s (%d)\n", - path, errno, 0); + prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n", + path, errno); return -1; } /* @@ -599,8 +599,8 @@ trans_mkdir(const char *path, int mode) if (!S_ISDIR(fbuf.st_mode) || buf.st_dev != fbuf.st_dev || buf.st_ino != fbuf.st_ino) { - PRMSG(1, "mkdir: ERROR: inode for %s changed\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: inode for %s changed\n", + path); return -1; } if (updateOwner && fchown(fd, 0, 0) == 0) @@ -611,34 +611,33 @@ trans_mkdir(const char *path, int mode) } } #endif - + if (updateOwner && !updatedOwner) { #ifdef FAIL_HARD if (status & FAIL_IF_NOT_ROOT) { - PRMSG(1, "mkdir: ERROR: Owner of %s must be set to root\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: Owner of %s must be set to root\n", + path); return -1; } #endif #if !defined(__APPLE_CC__) && !defined(__CYGWIN__) - PRMSG(1, "mkdir: Owner of %s should be set to root\n", - path, 0, 0); + prmsg(1, "mkdir: Owner of %s should be set to root\n", + path); #endif } - + if (updateMode && !updatedMode) { #ifdef FAIL_HARD if (status & FAIL_IF_NOMODE) { - PRMSG(1, "mkdir: ERROR: Mode of %s must be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: ERROR: Mode of %s must be set to %04o\n", + path, mode); return -1; } #endif - PRMSG(1, "mkdir: Mode of %s should be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: Mode of %s should be set to %04o\n", + path, mode); if (status & WARN_NO_ACCESS) { - PRMSG(1, "mkdir: this may cause subsequent errors\n", - 0, 0, 0); + prmsg(1, "mkdir: this may cause subsequent errors\n"); } } return 0; |