From a53c2bca49ba0bb49719ebe570854d06ea7e1ca2 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 11 Sep 2012 16:01:44 +0200 Subject: fix compile problem on FreeBSD --- plugins/imuxsock/imuxsock.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index ea54e79b..d8922888 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -77,7 +77,7 @@ MODULE_TYPE_NOKEEP /* emulate struct ucred for platforms that do not have it */ #ifndef HAVE_SCM_CREDENTIALS -struct ucred { int pid; }; +struct ucred { int pid; uid_t uid; gid_t gid; }; #endif /* handle some defines missing on more than one platform */ @@ -802,9 +802,7 @@ static rsRetVal readSocket(lstn_t *pLstn) int iMaxLine; struct msghdr msgh; struct iovec msgiov; -# if HAVE_SCM_CREDENTIALS struct cmsghdr *cm; -# endif struct ucred *cred; struct timeval *ts; uchar bufRcv[4096+1]; -- cgit From d1de4cbd92a55c6b930fd84ee9fa5bbfee16aed6 Mon Sep 17 00:00:00 2001 From: Cristian Ionescu-Idbohrn Date: Wed, 12 Sep 2012 12:44:51 +0200 Subject: imuxsock: remove incorrect socket option call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SCM_CREDENTIALS is not a socket option; its value is usually 0x2 which on most archs corresponds to socket option SO_REUSEADDR, but on mips-arch there is no socket option with value 0x2 and SO_REUSEADDR = 0x4, so the call will fail with ENOPROTOOPT 'Protocol not available'; skip it. There does not seem any other special setsockopt call is needed anyway, besides the above. In addition Jonny Törnbom commented: SCM_CREDENTIALS is a control message type, not a socket option, so using setsockopt(...SCM_CREDENTIALS...) is potentially dangerous and wrong and should be deleted from the code. (SCM_CREDENTIALS is used in conjuction with SO_PASSCRED which is the socket option to use.) --- plugins/imuxsock/imuxsock.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index d8922888..b0247d6e 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -427,10 +427,6 @@ openLogSocket(lstn_t *pLstn) errmsg.LogError(errno, NO_ERRCODE, "set SO_PASSCRED failed on '%s'", pLstn->sockName); pLstn->bUseCreds = 0; } - if(setsockopt(pLstn->fd, SOL_SOCKET, SCM_CREDENTIALS, &one, sizeof(one)) != 0) { - errmsg.LogError(errno, NO_ERRCODE, "set SCM_CREDENTIALS failed on '%s'", pLstn->sockName); - pLstn->bUseCreds = 0; - } // TODO: move to its own #if if(setsockopt(pLstn->fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one)) != 0) { errmsg.LogError(errno, NO_ERRCODE, "set SO_TIMESTAMP failed on '%s'", pLstn->sockName); -- cgit From 2d538f14e2bae1407a3fb22c4a5244247dda1e4b Mon Sep 17 00:00:00 2001 From: Cristian Ionescu-Idbohrn Date: Wed, 12 Sep 2012 12:59:38 +0200 Subject: remove unused variables (if SCM_CREDENTIALS is not available) --- ChangeLog | 4 ++++ plugins/imuxsock/imuxsock.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3073d2f8..a053d8ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ --------------------------------------------------------------------------- +Version 5.10.1 [V5-STABLE], 2012-0?-?? +- bugfix: remove invalid socket option call from imuxsock + Thanks to Cristian Ionescu-Idbohrn and Jonny Törnbom +--------------------------------------------------------------------------- Version 5.10.0 [V5-STABLE], 2012-08-23 NOTE: this is the new rsyslog v5-stable, incorporating all changes from the diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index b0247d6e..76474724 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -386,7 +386,9 @@ static inline rsRetVal openLogSocket(lstn_t *pLstn) { DEFiRet; +# if HAVE_SCM_CREDENTIALS int one; +# endif /* HAVE_SCM_CREDENTIALS */ if(pLstn->sockName[0] == '\0') return -1; @@ -802,8 +804,10 @@ static rsRetVal readSocket(lstn_t *pLstn) struct ucred *cred; struct timeval *ts; uchar bufRcv[4096+1]; - char aux[128]; uchar *pRcv = NULL; /* receive buffer */ +# if HAVE_SCM_CREDENTIALS + char aux[128]; +# endif assert(pLstn->fd >= 0); -- cgit