diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-23 10:29:15 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-23 10:29:15 +0200 |
commit | 7b1a570d54ac4c82325aeeee70d7a8871ecd688a (patch) | |
tree | 68b2ab1fc7f85f7eca8d9d0d8270074c6cfb6bce /plugins | |
parent | 716ab25446cd45ec8117264e51b5018f9a813d4e (diff) | |
download | rsyslog-7b1a570d54ac4c82325aeeee70d7a8871ecd688a.tar.gz rsyslog-7b1a570d54ac4c82325aeeee70d7a8871ecd688a.tar.xz rsyslog-7b1a570d54ac4c82325aeeee70d7a8871ecd688a.zip |
changed Rcv-Interface in tcpsrv subsystem
It is now iRet based. This enables us to communicate
more in-depth information to the upper peers. This is needed
to handle the EGAIN case on rcv (not yet implemented)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imgssapi/imgssapi.c | 43 | ||||
-rw-r--r-- | plugins/imtcp/imtcp.c | 16 |
2 files changed, 32 insertions, 27 deletions
diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c index 48cc99a2..24317b51 100644 --- a/plugins/imgssapi/imgssapi.c +++ b/plugins/imgssapi/imgssapi.c @@ -68,7 +68,7 @@ MODULE_TYPE_INPUT static rsRetVal addGSSListener(void __attribute__((unused)) *pVal, uchar *pNewVal); static int TCPSessGSSInit(void); static void TCPSessGSSClose(tcps_sess_t* pSess); -static int TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len); +static rsRetVal TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len, ssize_t *); static rsRetVal onSessAccept(tcpsrv_t *pThis, tcps_sess_t *ppSess); static rsRetVal OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *ppSess); @@ -274,25 +274,28 @@ finalize_it: } -static int -doRcvData(tcps_sess_t *pSess, char *buf, size_t lenBuf) +static rsRetVal +doRcvData(tcps_sess_t *pSess, char *buf, size_t lenBuf, ssize_t *piLenRcvd) { - ssize_t state; + DEFiRet; int allowedMethods; gss_sess_t *pGSess; assert(pSess != NULL); assert(pSess->pUsr != NULL); pGSess = (gss_sess_t*) pSess->pUsr; + assert(piLenRcvd != NULL); allowedMethods = pGSess->allowedMethods; - if(allowedMethods & ALLOWEDMETHOD_GSS) - state = TCPSessGSSRecv(pSess, buf, lenBuf); - else { - if(netstrm.Rcv(pSess->pStrm, (uchar*) buf, &state) != RS_RET_OK) - state = -1; // TODO: move this function to an iRet interface! 2008-05-05 + if(allowedMethods & ALLOWEDMETHOD_GSS) { + CHKiRet(TCPSessGSSRecv(pSess, buf, lenBuf, piLenRcvd)); + } else { + *piLenRcvd = lenBuf; + CHKiRet(netstrm.Rcv(pSess->pStrm, (uchar*) buf, piLenRcvd) != RS_RET_OK); } - return state; + +finalize_it: + RETiRet; } @@ -526,25 +529,26 @@ finalize_it: } -/* returns: number of bytes read or -1 on error - * Replaces recv() for gssapi connections. +/* Replaces recv() for gssapi connections. */ -int TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len) +int TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len, ssize_t *piLenRcvd) { + DEFiRet; gss_buffer_desc xmit_buf, msg_buf; gss_ctx_id_t *context; OM_uint32 maj_stat, min_stat; int fdSess; int conf_state; - int state, len; + int state; gss_sess_t *pGSess; assert(pSess->pUsr != NULL); + assert(piLenRcvd != NULL); pGSess = (gss_sess_t*) pSess->pUsr; netstrm.GetSock(pSess->pStrm, &fdSess); // TODO: method access, CHKiRet! if ((state = gssutil.recv_token(fdSess, &xmit_buf)) <= 0) - return state; + ABORT_FINALIZE(RS_RET_GSS_ERR); context = &pGSess->gss_context; maj_stat = gss_unwrap(&min_stat, *context, &xmit_buf, &msg_buf, @@ -555,18 +559,19 @@ int TCPSessGSSRecv(tcps_sess_t *pSess, void *buf, size_t buf_len) free(xmit_buf.value); xmit_buf.value = 0; } - return (-1); + ABORT_FINALIZE(RS_RET_GSS_ERR); } if (xmit_buf.value) { free(xmit_buf.value); xmit_buf.value = 0; } - len = msg_buf.length < buf_len ? msg_buf.length : buf_len; - memcpy(buf, msg_buf.value, len); + *piLenRcvd = msg_buf.length < buf_len ? msg_buf.length : buf_len; + memcpy(buf, msg_buf.value, *piLenRcvd); gss_release_buffer(&min_stat, &msg_buf); - return len; +finalize_it: + RETiRet; } diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index d50d80e9..4d31744d 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -101,16 +101,17 @@ doOpenLstnSocks(tcpsrv_t *pSrv) } -static int -doRcvData(tcps_sess_t *pSess, char *buf, size_t lenBuf) +static rsRetVal +doRcvData(tcps_sess_t *pSess, char *buf, size_t lenBuf, ssize_t *piLenRcvd) { - ssize_t state; + DEFiRet; assert(pSess != NULL); + assert(piLenRcvd != NULL); - state = lenBuf; - if(netstrm.Rcv(pSess->pStrm, (uchar*) buf, &state) != RS_RET_OK) - state = -1; // TODO: move this function to an iRet interface! 2008-04-23 - return state; + *piLenRcvd = lenBuf; + CHKiRet(netstrm.Rcv(pSess->pStrm, (uchar*) buf, piLenRcvd) != RS_RET_OK); +finalize_it: + RETiRet; } static rsRetVal @@ -167,7 +168,6 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa CHKiRet(tcpsrv.SetDrvrMode(pOurTcpsrv, iStrmDrvrMode)); /* now set optional params, but only if they were actually configured */ if(pszStrmDrvrAuthMode != NULL) { -RUNLOG_VAR("%s", pszStrmDrvrAuthMode); CHKiRet(tcpsrv.SetDrvrAuthMode(pOurTcpsrv, pszStrmDrvrAuthMode)); } if(pPermPeersRoot != NULL) { |