-if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0)
+if (setsockopt(fd, SOL_SOCKET,
+#ifdef SO_PASSCRED /* Linux */
+ SO_PASSCRED,
+#elif defined(LOCAL_CREDS) /* BSD-ish */
+ LOCAL_CREDS,
+#else
+# error no SO_PASSCRED
+#endif
+ &on, sizeof(on)) < 0)
/* Refuse to handle the item unless the peer has good credentials */
#ifdef SCM_CREDENTIALS
# define EXIM_SCM_CR_TYPE SCM_CREDENTIALS
/* Refuse to handle the item unless the peer has good credentials */
#ifdef SCM_CREDENTIALS
# define EXIM_SCM_CR_TYPE SCM_CREDENTIALS
cp = CMSG_NXTHDR(&msg, cp))
if (cp->cmsg_level == SOL_SOCKET && cp->cmsg_type == EXIM_SCM_CR_TYPE)
{
cp = CMSG_NXTHDR(&msg, cp))
if (cp->cmsg_level == SOL_SOCKET && cp->cmsg_type == EXIM_SCM_CR_TYPE)
{
struct ucred * cr = (struct ucred *) CMSG_DATA(cp);
if (cr->uid && cr->uid != exim_uid)
{
DEBUG(D_queue_run) debug_printf("%s: sender creds pid %d uid %d gid %d\n",
__FUNCTION__, (int)cr->pid, (int)cr->uid, (int)cr->gid);
return FALSE;
struct ucred * cr = (struct ucred *) CMSG_DATA(cp);
if (cr->uid && cr->uid != exim_uid)
{
DEBUG(D_queue_run) debug_printf("%s: sender creds pid %d uid %d gid %d\n",
__FUNCTION__, (int)cr->pid, (int)cr->uid, (int)cr->gid);
return FALSE;
-#elif defined(SCM_CREDS)
- struct cmsgcred * cr = (struct cmsgcred *) CMSG_DATA(cp);
- if (cr->cmcred_uid && cr->cmcred_uid != exim_uid)
+#elif defined(LOCAL_CREDS) /* BSD-ish */
+ struct sockcred * cr = (struct sockcred *) CMSG_DATA(cp);
+ if (cr->sc_uid && cr->sc_uid != exim_uid)
- DEBUG(D_queue_run) debug_printf("%s: sender creds pid %d uid %d gid %d\n",
- __FUNCTION__, (int)cr->cmcred_pid, (int)cr->cmcred_uid, (int)cr->cmcred_gid);
+ DEBUG(D_queue_run) debug_printf("%s: sender creds pid ??? uid %d gid %d\n",
+ __FUNCTION__, (int)cr->sc_uid, (int)cr->sc_gid);