[PATCH 01/14] logger: use SCM_CREDENTIALS on LINUX only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>

This is a build fix of FreeBSD and OSX. Basically we revert
the following commit for non-linux systems:
27a9eb53 "use --id as local socket credentials"

Note I could also compile it like this:

  #ifdef HAVE_SYS_UCRED_H
  # define _WANT_UCRED
  # include <sys/param.h>
  # include <sys/ucred.h>
  # define SCM_CREDENTIALS SCM_CREDS
  #endif

  [...]
  #ifdef _linux_
  cred->pid = ctl->pid;
  #endif
  [...]

... but don't know how to test whether it does what it
should.

Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx>
---
 misc-utils/logger.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 4201e43..d9aee0e 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -446,12 +446,14 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg)
 
 	if (!ctl->noact) {
 		struct msghdr message = { 0 };
+#ifdef SCM_CREDENTIALS
 		struct cmsghdr *cmhp;
 		struct ucred *cred;
 		union {
 			struct cmsghdr cmh;
 			char   control[CMSG_SPACE(sizeof(struct ucred))];
 		} cbuf;
+#endif
 
 		/* 4) add extra \n to make sure message is terminated */
 		if ((ctl->socket_type == TYPE_TCP) && !ctl->octet_count)
@@ -460,6 +462,7 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg)
 		message.msg_iov = iov;
 		message.msg_iovlen = iovlen;
 
+#ifdef SCM_CREDENTIALS
 		/* syslog/journald may follow local socket credentials rather
 		 * than in the message PID. If we use --id as root than we can
 		 * force kernel to accept another valid PID than the real logger(1)
@@ -479,6 +482,7 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg)
 
 			cred->pid = ctl->pid;
 		}
+#endif
 
 		if (sendmsg(ctl->fd, &message, 0) < 0)
 			warn(_("send message failed"));
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux