mirror of
https://github.com/samhocevar/rinetd.git
synced 2025-03-22 15:50:08 +08:00
Add \n to all syslog calls because on Windows it will use fprintf.
This commit is contained in:
parent
e35403e112
commit
b5206eab4e
24
rinetd.c
24
rinetd.c
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
|
|||||||
readConfiguration(options.conf_file);
|
readConfiguration(options.conf_file);
|
||||||
registerPID();
|
registerPID();
|
||||||
|
|
||||||
syslog(LOG_INFO, "Starting redirections...");
|
syslog(LOG_INFO, "Starting redirections...\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
selectPass();
|
selectPass();
|
||||||
}
|
}
|
||||||
@ -401,8 +401,8 @@ static ConnectionInfo *findAvailableConnection(void)
|
|||||||
return &coInfo[oldTotal];
|
return &coInfo[oldTotal];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void selectPass(void) {
|
static void selectPass(void)
|
||||||
|
{
|
||||||
int const fdSetCount = maxfd / FD_SETSIZE + 1;
|
int const fdSetCount = maxfd / FD_SETSIZE + 1;
|
||||||
# define FD_ZERO_EXT(ar) for (int i = 0; i < fdSetCount; ++i) { FD_ZERO(&(ar)[i]); }
|
# define FD_ZERO_EXT(ar) for (int i = 0; i < fdSetCount; ++i) { FD_ZERO(&(ar)[i]); }
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -547,8 +547,7 @@ static void handleClose(ConnectionInfo *cnx, Socket *socket, Socket *other_socke
|
|||||||
}
|
}
|
||||||
socket->fd = INVALID_SOCKET;
|
socket->fd = INVALID_SOCKET;
|
||||||
if (other_socket->fd != INVALID_SOCKET) {
|
if (other_socket->fd != INVALID_SOCKET) {
|
||||||
#ifndef __linux__
|
#if !defined __linux__ && !defined _WIN32
|
||||||
#ifndef _WIN32
|
|
||||||
/* Now set up the other end for a polite closing */
|
/* Now set up the other end for a polite closing */
|
||||||
|
|
||||||
/* Request a low-water mark equal to the entire
|
/* Request a low-water mark equal to the entire
|
||||||
@ -557,8 +556,7 @@ static void handleClose(ConnectionInfo *cnx, Socket *socket, Socket *other_socke
|
|||||||
int arg = 1024;
|
int arg = 1024;
|
||||||
setsockopt(other_socket->fd, SOL_SOCKET, SO_SNDLOWAT,
|
setsockopt(other_socket->fd, SOL_SOCKET, SO_SNDLOWAT,
|
||||||
&arg, sizeof(arg));
|
&arg, sizeof(arg));
|
||||||
#endif /* _WIN32 */
|
#endif
|
||||||
#endif /* __linux__ */
|
|
||||||
cnx->coLog = socket == &cnx->local ?
|
cnx->coLog = socket == &cnx->local ?
|
||||||
logLocalClosedFirst : logRemoteClosedFirst;
|
logLocalClosedFirst : logRemoteClosedFirst;
|
||||||
}
|
}
|
||||||
@ -580,7 +578,7 @@ static void handleAccept(ServerInfo const *srv)
|
|||||||
if (srv->fromProto == protoTcp) {
|
if (srv->fromProto == protoTcp) {
|
||||||
nfd = accept(srv->fd, &addr, &addrlen);
|
nfd = accept(srv->fd, &addr, &addrlen);
|
||||||
if (nfd == INVALID_SOCKET) {
|
if (nfd == INVALID_SOCKET) {
|
||||||
syslog(LOG_ERR, "accept(%d): %m", srv->fd);
|
syslog(LOG_ERR, "accept(%d): %m\n", srv->fd);
|
||||||
logEvent(NULL, srv, logAcceptFailed);
|
logEvent(NULL, srv, logAcceptFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -596,7 +594,7 @@ static void handleAccept(ServerInfo const *srv)
|
|||||||
ssize_t ret = recvfrom(srv->fd, NULL, 0, MSG_PEEK,
|
ssize_t ret = recvfrom(srv->fd, NULL, 0, MSG_PEEK,
|
||||||
&addr, &addrlen);
|
&addr, &addrlen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
syslog(LOG_ERR, "recvfrom(%d): %m", srv->fd);
|
syslog(LOG_ERR, "recvfrom(%d): %m\n", srv->fd);
|
||||||
logEvent(NULL, srv, logAcceptFailed);
|
logEvent(NULL, srv, logAcceptFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -633,7 +631,7 @@ static void handleAccept(ServerInfo const *srv)
|
|||||||
? socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
|
? socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)
|
||||||
: socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
: socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (cnx->local.fd == INVALID_SOCKET) {
|
if (cnx->local.fd == INVALID_SOCKET) {
|
||||||
syslog(LOG_ERR, "socket(): %m");
|
syslog(LOG_ERR, "socket(): %m\n");
|
||||||
closesocket(cnx->remote.fd);
|
closesocket(cnx->remote.fd);
|
||||||
cnx->remote.fd = INVALID_SOCKET;
|
cnx->remote.fd = INVALID_SOCKET;
|
||||||
logEvent(cnx, srv, logLocalSocketFailed);
|
logEvent(cnx, srv, logLocalSocketFailed);
|
||||||
@ -806,7 +804,7 @@ static int getAddress(char const *host, struct in_addr *iaddr)
|
|||||||
msg = "A temporary error occurred on an authoritative name server. Try again later.";
|
msg = "A temporary error occurred on an authoritative name server. Try again later.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
syslog(LOG_ERR, "While resolving `%s' got: %s", host, msg);
|
syslog(LOG_ERR, "While resolving `%s' got: %s\n", host, msg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,7 +820,7 @@ RETSIGTYPE plumber(int s)
|
|||||||
RETSIGTYPE hup(int s)
|
RETSIGTYPE hup(int s)
|
||||||
{
|
{
|
||||||
(void)s;
|
(void)s;
|
||||||
syslog(LOG_INFO, "Received SIGHUP, reloading configuration...");
|
syslog(LOG_INFO, "Received SIGHUP, reloading configuration...\n");
|
||||||
/* Learn the new rules */
|
/* Learn the new rules */
|
||||||
clearConfiguration();
|
clearConfiguration();
|
||||||
readConfiguration(options.conf_file);
|
readConfiguration(options.conf_file);
|
||||||
@ -910,7 +908,7 @@ static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int resul
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result==logNotAllowed || result==logDenied)
|
if (result==logNotAllowed || result==logDenied)
|
||||||
syslog(LOG_INFO, "%s %s"
|
syslog(LOG_INFO, "%s %s\n"
|
||||||
, addressText
|
, addressText
|
||||||
, logMessages[result]);
|
, logMessages[result]);
|
||||||
if (logFile) {
|
if (logFile) {
|
||||||
|
Loading…
Reference in New Issue
Block a user