summaryrefslogtreecommitdiffstats
path: root/tcpsrv.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-24 09:57:43 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-24 09:57:43 +0200
commitbf3d2c1b392af1383a3cdc247f2280fd31a12699 (patch)
tree532f3de6ec3b7fc7557c4e3a60f142a07a29580a /tcpsrv.c
parent721b9ee252143d182c3c145380e5dbec8c3b0102 (diff)
downloadrsyslog-bf3d2c1b392af1383a3cdc247f2280fd31a12699.tar.gz
rsyslog-bf3d2c1b392af1383a3cdc247f2280fd31a12699.tar.xz
rsyslog-bf3d2c1b392af1383a3cdc247f2280fd31a12699.zip
message reception via TCP work again
... at least in some cases ;) I assume there are still a couple of bugs inside the code. But at least we have something from where we can continue to work on.
Diffstat (limited to 'tcpsrv.c')
-rw-r--r--tcpsrv.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/tcpsrv.c b/tcpsrv.c
index b6fb35fc..2536cdd6 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -182,9 +182,10 @@ TCPSessGetNxtSess(tcpsrv_t *pThis, int iCurr)
register int i;
ISOBJ_TYPE_assert(pThis, tcpsrv);
- for(i = iCurr + 1 ; i < pThis->iSessMax ; ++i)
+ for(i = iCurr + 1 ; i < pThis->iSessMax ; ++i) {
if(pThis->pSessions[i] != NULL)
break;
+ }
return((i < pThis->iSessMax) ? i : -1);
}
@@ -241,6 +242,7 @@ addTcpLstn(void *pUsr, netstrm_t *pLstn)
if(pThis->iLstnMax >= TCPLSTN_MAX_DEFAULT)
ABORT_FINALIZE(RS_RET_MAX_LSTN_REACHED);
+RUNLOG_VAR("%d", pThis->iLstnMax);
pThis->ppLstn[pThis->iLstnMax] = pLstn;
++pThis->iLstnMax;
@@ -310,8 +312,7 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
netstrm_t *pNewStrm = NULL;
int iSess = -1;
struct sockaddr_storage addr;
- uchar fromHost[NI_MAXHOST];
- uchar fromHostFQDN[NI_MAXHOST];
+ uchar *fromHostFQDN;
ISOBJ_TYPE_assert(pThis, tcpsrv);
@@ -331,13 +332,8 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
/* OK, we have a "good" index... */
/* get the host name */
- if(net.cvthname(&addr, fromHost, fromHostFQDN) != RS_RET_OK) {
- /* we seem to have something malicous - at least we
- * are now told to discard the connection request.
- * Error message has been generated by cvthname.
- */
- ABORT_FINALIZE(RS_RET_ERR); // TODO: better error code
- }
+ CHKiRet(netstrm.GetRemoteHName(pStrm, &fromHostFQDN));
+ /* TODO: check if we need to strip the domain name here -- rgerhards, 2008-04-24 */
/* Here we check if a host is permitted to send us
* syslog messages. If it isn't, we do not further
@@ -346,10 +342,10 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
* rgerhards, 2005-09-26
*/
if(!pThis->pIsPermittedHost((struct sockaddr*) &addr, (char*) fromHostFQDN, pThis->pUsr, pSess->pUsr)) {
- dbgprintf("%s is not an allowed sender\n", (char *) fromHostFQDN);
+ dbgprintf("%s is not an allowed sender\n", fromHostFQDN);
if(glbl.GetOption_DisallowWarning()) {
errno = 0;
- errmsg.LogError(NO_ERRCODE, "TCP message from disallowed sender %s discarded", fromHost);
+ errmsg.LogError(NO_ERRCODE, "TCP message from disallowed sender %s discarded", fromHostFQDN);
}
ABORT_FINALIZE(RS_RET_HOST_NOT_PERMITTED);
}
@@ -357,7 +353,7 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, netstrm_t *pStrm)
/* OK, we have an allowed sender, so let's continue, what
* means we can finally fill in the session object.
*/
- CHKiRet(tcps_sess.SetHost(pSess, fromHost));
+ CHKiRet(tcps_sess.SetHost(pSess, fromHostFQDN));
CHKiRet(tcps_sess.SetStrm(pSess, pNewStrm));
pNewStrm = NULL; /* prevent it from being freed in error handler, now done in tcps_sess! */
CHKiRet(tcps_sess.SetMsgIdx(pSess, 0));
@@ -480,7 +476,6 @@ finalize_it: // TODO: think: is it really good to exit the loop?
/* Standard-Constructor */
BEGINobjConstruct(tcpsrv) /* be sure to specify the object type also in END macro! */
pThis->iSessMax = TCPSESS_MAX_DEFAULT; /* TODO: useful default ;) */
- pThis->iLstnMax = TCPLSTN_MAX_DEFAULT; /* TODO: useful default ;) */
ENDobjConstruct(tcpsrv)
@@ -497,7 +492,7 @@ tcpsrvConstructFinalize(tcpsrv_t *pThis)
CHKiRet(netstrms.ConstructFinalize(pThis->pNS));
/* set up listeners */
- CHKmalloc(pThis->ppLstn = calloc(pThis->iLstnMax, sizeof(netstrm_t*)));
+ CHKmalloc(pThis->ppLstn = calloc(TCPLSTN_MAX_DEFAULT, sizeof(netstrm_t*)));
iRet = pThis->OpenLstnSocks(pThis);
finalize_it: