mirror of
https://github.com/bstansell/conserver.git
synced 2025-03-15 00:36:28 +00:00
Merge branch 'master' into reinitcheck-sec
This commit is contained in:
commit
1542e903af
@ -146,6 +146,12 @@ AccType(INADDR_STYPE *addr, char **peername)
|
||||
so = sizeof(*addr);
|
||||
|
||||
#if USE_IPV6
|
||||
/*
|
||||
* XXX where is the TRUST_REVERSE_DNS support for IPv6???
|
||||
*
|
||||
* XXX IPv4 should use getnameinfo() et al as well
|
||||
* (if available, they are in IEEE Std 1003.1g-2000)
|
||||
*/
|
||||
error =
|
||||
getnameinfo((struct sockaddr *)addr, so, ipaddr, sizeof(ipaddr),
|
||||
NULL, 0, NI_NUMERICHOST);
|
||||
@ -153,7 +159,11 @@ AccType(INADDR_STYPE *addr, char **peername)
|
||||
Error("AccType(): getnameinfo failed: %s", gai_strerror(error));
|
||||
goto common_ret;
|
||||
}
|
||||
CONDDEBUG((1, "AccType(): ip=%s", ipaddr));
|
||||
CONDDEBUG((1, "AccType(): ip=%s (%s)", ipaddr,
|
||||
addr->ss_family == AF_UNSPEC ? "AF_UNSPEC" :
|
||||
addr->ss_family == AF_LOCAL ? "AF_LOCAL" :
|
||||
addr->ss_family == AF_INET ? "AF_INET" :
|
||||
addr->ss_family == AF_INET6 ? "AF_INET6" : "IF_???"));
|
||||
|
||||
error =
|
||||
getnameinfo((struct sockaddr *)addr, so, host, sizeof(host), NULL,
|
||||
@ -189,7 +199,7 @@ AccType(INADDR_STYPE *addr, char **peername)
|
||||
common_ret:
|
||||
if (config->loghostnames == FLAGTRUE && !error)
|
||||
*peername = StrDup(host);
|
||||
#else
|
||||
#else /* !USE_IPV6 */
|
||||
# if TRUST_REVERSE_DNS
|
||||
/* if we trust reverse dns, we get the names associated with
|
||||
* the address we're checking and then check each of those
|
||||
|
@ -915,6 +915,9 @@ ConsInit(CONSENT *pCE)
|
||||
case HOST:
|
||||
{
|
||||
#if USE_IPV6
|
||||
/* XXX IPv4 should use getaddrinfo() and getnameinfo() as well,
|
||||
* (if available, they are in IEEE Std 1003.1g-2000)
|
||||
*/
|
||||
int error;
|
||||
char host[NI_MAXHOST];
|
||||
char serv[NI_MAXSERV];
|
||||
@ -929,7 +932,7 @@ ConsInit(CONSENT *pCE)
|
||||
Sleep(100000); /* Not all terminal servers can keep up */
|
||||
|
||||
#if USE_IPV6
|
||||
# if HAVE_MEMSET
|
||||
# if HAVE_MEMSET /* XXX memset() is C89!!! */
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
# else
|
||||
bzero(&hints, sizeof(hints));
|
||||
@ -966,8 +969,12 @@ ConsInit(CONSENT *pCE)
|
||||
# if HAVE_SETSOCKOPT
|
||||
if (setsockopt
|
||||
(cofile, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(char *)&one, sizeof(one)) < 0)
|
||||
(char *)&one, sizeof(one)) < 0) {
|
||||
Error
|
||||
("[%s] %s:%s setsockopt(%u,SO_KEEPALIVE): %s",
|
||||
pCE->server, host, serv, cofile, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
# endif
|
||||
if (!SetFlags(cofile, O_NONBLOCK, 0))
|
||||
goto fail;
|
||||
@ -975,20 +982,25 @@ ConsInit(CONSENT *pCE)
|
||||
ret = connect(cofile, rp->ai_addr, rp->ai_addrlen);
|
||||
if (ret == 0 || errno == EINPROGRESS)
|
||||
goto success;
|
||||
|
||||
Error("[%s] %s:%s connect(%u): %s",
|
||||
pCE->server, host, serv, cofile, strerror(errno));
|
||||
fail:
|
||||
close(cofile);
|
||||
} else {
|
||||
Error
|
||||
("[%s] %s:%s socket(AF_INET,SOCK_STREAM): %s",
|
||||
pCE->server, host, serv, strerror(errno));
|
||||
}
|
||||
rp = rp->ai_next;
|
||||
}
|
||||
|
||||
Error("[%s]: Unable to connect to %s:%s", pCE->server,
|
||||
host, serv);
|
||||
Error("[%s] Unable to connect to %s:%s, forcing down", pCE->server,
|
||||
pCE->host, serv);
|
||||
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
|
||||
return;
|
||||
success:
|
||||
freeaddrinfo(ai);
|
||||
#else
|
||||
#else /* !USE_IPV6 */
|
||||
# if HAVE_MEMSET
|
||||
memset((void *)&port, 0, sizeof(port));
|
||||
# else
|
||||
|
@ -262,7 +262,7 @@ DestroyString(STRING *msg)
|
||||
{
|
||||
if (msg->prev == (STRING *)0 && msg->next == (STRING *)0 &&
|
||||
allStrings != msg) {
|
||||
CONDDEBUG((1, "DestroyString(): 0x%lx non-pooled string destroyed",
|
||||
CONDDEBUG((3, "DestroyString(): 0x%lx non-pooled string destroyed",
|
||||
(void *)msg, stringCount));
|
||||
} else {
|
||||
if (msg->prev != (STRING *)0)
|
||||
@ -273,7 +273,7 @@ DestroyString(STRING *msg)
|
||||
allStrings = msg->next;
|
||||
}
|
||||
stringCount--;
|
||||
CONDDEBUG((1,
|
||||
CONDDEBUG((3,
|
||||
"DestroyString(): 0x%lx string destroyed (count==%d)",
|
||||
(void *)msg, stringCount));
|
||||
}
|
||||
@ -296,7 +296,7 @@ AllocString(void)
|
||||
allStrings = s;
|
||||
InitString(s);
|
||||
stringCount++;
|
||||
CONDDEBUG((1, "AllocString(): 0x%lx created string #%d", (void *)s,
|
||||
CONDDEBUG((3, "AllocString(): 0x%lx created string #%d", (void *)s,
|
||||
stringCount));
|
||||
return s;
|
||||
}
|
||||
@ -2415,7 +2415,7 @@ GetWord(FILE *fp, int *line, short spaceok, STRING *word)
|
||||
while ((c = fgetc(fp)) != EOF) {
|
||||
if (c == '\n') {
|
||||
(*line)++;
|
||||
if (checkInc == -2)
|
||||
if (checkInc == -2 || checkInc == 0)
|
||||
checkInc = -1;
|
||||
}
|
||||
if (comment) {
|
||||
@ -2592,11 +2592,17 @@ ParseFile(char *filename, FILE *fp, int level)
|
||||
strerror(errno));
|
||||
} else {
|
||||
char *fname;
|
||||
char *sfile;
|
||||
int sline;
|
||||
/* word gets destroyed, so save the name */
|
||||
fname = StrDup(word->string);
|
||||
sfile = file;
|
||||
sline = line;
|
||||
ParseFile(fname, lfp, level + 1);
|
||||
fclose(lfp);
|
||||
free(fname);
|
||||
file = sfile;
|
||||
line = sline;
|
||||
}
|
||||
} else {
|
||||
switch (state) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user