mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-12 15:00:24 +01:00
Bug 19432 - Fix handling of HAVE_CMSGCRED case (FreeBSD)
Fixes dbus on FreeBSD and DragonFly systems.
The patch is obtained from FreeBSD ports tree.
Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit 7bf132c7d1)
This commit is contained in:
parent
fceaa7a153
commit
5abb8aeb5e
1 changed files with 19 additions and 15 deletions
|
|
@ -1041,9 +1041,9 @@ write_credentials_byte (int server_fd,
|
|||
int bytes_written;
|
||||
char buf[1] = { '\0' };
|
||||
#if defined(HAVE_CMSGCRED)
|
||||
struct {
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
struct cmsgcred cred;
|
||||
char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
|
||||
} cmsg;
|
||||
struct iovec iov;
|
||||
struct msghdr msg;
|
||||
|
|
@ -1054,10 +1054,10 @@ write_credentials_byte (int server_fd,
|
|||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
msg.msg_control = &cmsg;
|
||||
msg.msg_controllen = sizeof (cmsg);
|
||||
msg.msg_control = (caddr_t) &cmsg;
|
||||
msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
|
||||
memset (&cmsg, 0, sizeof (cmsg));
|
||||
cmsg.hdr.cmsg_len = sizeof (cmsg);
|
||||
cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred));
|
||||
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
||||
cmsg.hdr.cmsg_type = SCM_CREDS;
|
||||
#endif
|
||||
|
|
@ -1129,13 +1129,10 @@ _dbus_read_credentials_socket (int client_fd,
|
|||
dbus_pid_t pid_read;
|
||||
int bytes_read;
|
||||
|
||||
uid_read = DBUS_UID_UNSET;
|
||||
pid_read = DBUS_PID_UNSET;
|
||||
|
||||
#ifdef HAVE_CMSGCRED
|
||||
struct {
|
||||
union {
|
||||
struct cmsghdr hdr;
|
||||
struct cmsgcred cred;
|
||||
char cred[CMSG_SPACE (sizeof (struct cmsgcred))];
|
||||
} cmsg;
|
||||
|
||||
#elif defined(LOCAL_CREDS)
|
||||
|
|
@ -1145,6 +1142,9 @@ _dbus_read_credentials_socket (int client_fd,
|
|||
} cmsg;
|
||||
#endif
|
||||
|
||||
uid_read = DBUS_UID_UNSET;
|
||||
pid_read = DBUS_PID_UNSET;
|
||||
|
||||
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
||||
|
||||
/* The POSIX spec certainly doesn't promise this, but
|
||||
|
|
@ -1172,8 +1172,8 @@ _dbus_read_credentials_socket (int client_fd,
|
|||
|
||||
#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS)
|
||||
memset (&cmsg, 0, sizeof (cmsg));
|
||||
msg.msg_control = &cmsg;
|
||||
msg.msg_controllen = sizeof (cmsg);
|
||||
msg.msg_control = (caddr_t) &cmsg;
|
||||
msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred));
|
||||
#endif
|
||||
|
||||
again:
|
||||
|
|
@ -1211,7 +1211,8 @@ _dbus_read_credentials_socket (int client_fd,
|
|||
}
|
||||
|
||||
#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS)
|
||||
if (cmsg.hdr.cmsg_len < sizeof (cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS)
|
||||
if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred))
|
||||
|| cmsg.hdr.cmsg_type != SCM_CREDS)
|
||||
{
|
||||
dbus_set_error (error, DBUS_ERROR_FAILED,
|
||||
"Message from recvmsg() was not SCM_CREDS");
|
||||
|
|
@ -1238,8 +1239,11 @@ _dbus_read_credentials_socket (int client_fd,
|
|||
cr_len, (int) sizeof (cr), _dbus_strerror (errno));
|
||||
}
|
||||
#elif defined(HAVE_CMSGCRED)
|
||||
pid_read = cmsg.cred.cmcred_pid;
|
||||
uid_read = cmsg.cred.cmcred_euid;
|
||||
struct cmsgcred *cred;
|
||||
|
||||
cred = (struct cmsgcred *) CMSG_DATA (&cmsg);
|
||||
pid_read = cred->cmcred_pid;
|
||||
uid_read = cred->cmcred_euid;
|
||||
#elif defined(LOCAL_CREDS)
|
||||
pid_read = DBUS_PID_UNSET;
|
||||
uid_read = cmsg.cred.sc_uid;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue