diff options
author | Alex Suykov <alex.suykov@gmail.com> | 2014-12-23 07:52:58 +0200 |
---|---|---|
committer | Riku Voipio <riku.voipio@linaro.org> | 2015-01-27 22:33:57 +0200 |
commit | 30b8b68eb574fd68060eebcc4da790fdfe18d668 (patch) | |
tree | 2a70294a565982392a3e302eb6c23419e2a16e91 /linux-user | |
parent | 1669add752d9f29283f8ebf6a863d7b1e2d0f146 (diff) | |
download | qemu-30b8b68eb574fd68060eebcc4da790fdfe18d668.zip qemu-30b8b68eb574fd68060eebcc4da790fdfe18d668.tar.gz qemu-30b8b68eb574fd68060eebcc4da790fdfe18d668.tar.bz2 |
linux-user: support target-to-host SCM_CREDENTIALS
When passing ancillary data through a unix socket, handle
credentials properly instead of doing a simple copy and
issuing a warning.
Signed-off-by: Alex Suykov <alex.suykov@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/syscall.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 683f8cc..d4398b9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1214,16 +1214,26 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh, cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type); cmsg->cmsg_len = CMSG_LEN(len); - if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { - gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); - memcpy(data, target_data, len); - } else { + if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { int *fd = (int *)data; int *target_fd = (int *)target_data; int i, numfds = len / sizeof(int); for (i = 0; i < numfds; i++) fd[i] = tswap32(target_fd[i]); + } else if (cmsg->cmsg_level == SOL_SOCKET + && cmsg->cmsg_type == SCM_CREDENTIALS) { + struct ucred *cred = (struct ucred *)data; + struct target_ucred *target_cred = + (struct target_ucred *)target_data; + + __put_user(target_cred->pid, &cred->pid); + __put_user(target_cred->uid, &cred->uid); + __put_user(target_cred->gid, &cred->gid); + } else { + gemu_log("Unsupported ancillary data: %d/%d\n", + cmsg->cmsg_level, cmsg->cmsg_type); + memcpy(data, target_data, len); } cmsg = CMSG_NXTHDR(msgh, cmsg); |