diff options
author | Ruediger Meier | 2016-02-19 01:44:14 +0100 |
---|---|---|
committer | Ruediger Meier | 2016-02-26 03:29:41 +0100 |
commit | 4199e9891eb4b024792b18b21f576331d370fdc1 (patch) | |
tree | 55a7dd9c1a9b083d49231af529c127b94c4a1703 /misc-utils/logger.c | |
parent | Merge branch 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux (diff) | |
download | kernel-qcow2-util-linux-4199e9891eb4b024792b18b21f576331d370fdc1.tar.gz kernel-qcow2-util-linux-4199e9891eb4b024792b18b21f576331d370fdc1.tar.xz kernel-qcow2-util-linux-4199e9891eb4b024792b18b21f576331d370fdc1.zip |
logger: use SCM_CREDENTIALS on LINUX only
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@ga-group.nl>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 4201e4335..d9aee0eb9 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")); |