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>
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)
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)
cred->pid = ctl->pid;
}
+#endif
if (sendmsg(ctl->fd, &message, 0) < 0)
warn(_("send message failed"));