diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-03 12:40:04 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-03 12:40:04 +0000 |
commit | cb71628f67e12081db2449eff83667e2a832f495 (patch) | |
tree | 77ff69744751c5fe9b3f99ad04010fb3d5f98cd0 /tcpsrv.c | |
parent | 42730360196f1aaafaebb955c1a0a66a185e61ec (diff) | |
download | rsyslog-cb71628f67e12081db2449eff83667e2a832f495.tar.gz rsyslog-cb71628f67e12081db2449eff83667e2a832f495.tar.bz2 rsyslog-cb71628f67e12081db2449eff83667e2a832f495.zip |
fixed newly introduced bugs in imgssapi and imtcp and their helpers now
plain tcp works again
Diffstat (limited to 'tcpsrv.c')
-rw-r--r-- | tcpsrv.c | 46 |
1 files changed, 28 insertions, 18 deletions
@@ -420,13 +420,13 @@ static int *create_tcp_socket(tcpsrv_t *pThis) * If it does not succeed, no session is created and ppSess is * undefined. -- rgerhards, 2008-03-02 */ -static int +static rsRetVal SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) { DEFiRet; int newConn; - int iSess; + int iSess = -1; struct sockaddr_storage addr; socklen_t addrlen = sizeof(struct sockaddr_storage); uchar fromHost[NI_MAXHOST]; @@ -434,10 +434,12 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) ISOBJ_TYPE_assert(pThis, tcpsrv); +RUNLOG_VAR("%p", pThis->pUsr); newConn = accept(fd, (struct sockaddr*) &addr, &addrlen); if (newConn < 0) { logerror("tcp accept, ignoring error and connection request"); - return -1; + ABORT_FINALIZE(RS_RET_ERR); // TODO: better error code + //was: return -1; } /* Add to session list */ @@ -446,13 +448,16 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) errno = 0; logerror("too many tcp sessions - dropping incoming request"); close(newConn); - return -1; + ABORT_FINALIZE(RS_RET_ERR); // TODO: better error code + //was: return -1; } else { /* we found a free spot and can construct our session object */ - CHKiRet(tcps_sess.Construct(&pThis->pSessions[iSess])); + CHKiRet(tcps_sess.Construct(ppSess)); + CHKiRet(tcps_sess.SetTcpsrv(*ppSess, pThis)); } - *ppSess = pThis->pSessions[iSess]; + + pThis->pSessions[iSess] = *ppSess; /* OK, we have a "good" index... */ /* get the host name */ @@ -462,7 +467,8 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) * Error message has been generated by cvthname. */ close (newConn); - return -1; + ABORT_FINALIZE(RS_RET_ERR); // TODO: better error code + //was: return -1; } /* Here we check if a host is permitted to send us @@ -471,9 +477,7 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) * configured to do this). * rgerhards, 2005-09-26 */ - if(!pThis->pIsPermittedHost((struct sockaddr*) &addr, (char*) fromHostFQDN, - pThis->pUsr, pThis->pSessions[iSess]->pUsr)) - { + if(!pThis->pIsPermittedHost((struct sockaddr*) &addr, (char*) fromHostFQDN, pThis->pUsr, (*ppSess)->pUsr)) { dbgprintf("%s is not an allowed sender\n", (char *) fromHostFQDN); if(option_DisallowWarning) { errno = 0; @@ -481,13 +485,14 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) (char*)fromHost); } close(newConn); - return -1; + ABORT_FINALIZE(RS_RET_HOST_NOT_PERMITTED); } - /* OK, we have an allowed sender, so let's continue */ - /* we first need to construct a new session object */ - CHKiRet(tcps_sess.SetTcpsrv(pThis->pSessions[iSess], pThis)); + /* OK, we have an allowed sender, so let's continue, what + * means we can finally fill in the session object. + */ CHKiRet(tcps_sess.SetHost(pThis->pSessions[iSess], fromHost)); +RUNLOG_VAR("%d", newConn); CHKiRet(tcps_sess.SetSock(pThis->pSessions[iSess], newConn)); CHKiRet(tcps_sess.SetMsgIdx(pThis->pSessions[iSess], 0)); CHKiRet(tcps_sess.ConstructFinalize(pThis->pSessions[iSess])); @@ -495,13 +500,15 @@ SessAccept(tcpsrv_t *pThis, tcps_sess_t **ppSess, int fd) finalize_it: RUNLOG_VAR("%d", iRet); if(iRet != RS_RET_OK) { - if(pThis->pSessions[iSess] != NULL) - tcps_sess.Destruct(&pThis->pSessions[iSess]); + if(iSess != -1) { +RUNLOG_VAR("%d", iSess); + if(pThis->pSessions[iSess] != NULL) + tcps_sess.Destruct(&pThis->pSessions[iSess]); + } iSess = -1; // TODO: change this to be fully iRet compliant ;) } - ENDfunc - return iSess; + RETiRet; } @@ -548,8 +555,11 @@ Run(tcpsrv_t *pThis) while(iTCPSess != -1) { int fdSess; fdSess = pThis->pSessions[iTCPSess]->sock; // TODO: NOT CLEAN!, use method +RUNLOG_VAR("%d", iTCPSess); +RUNLOG_VAR("%d", fdSess); dbgprintf("Adding TCP Session %d\n", fdSess); FD_SET(fdSess, &readfds); +RUNLOG; if (fdSess>maxfds) maxfds=fdSess; /* now get next... */ iTCPSess = TCPSessGetNxtSess(pThis, iTCPSess); |