[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/44] linux-user: add netlink audit
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 04/44] linux-user: add netlink audit |
Date: |
Wed, 8 Jun 2016 16:29:45 +0300 |
From: Laurent Vivier <address@hidden>
This is, for instance, needed to log in a container.
Without this, the user cannot be identified and the console login
fails with "Login incorrect".
Signed-off-by: Laurent Vivier <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 584aecc..933c2cd 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -103,6 +103,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#include <linux/blkpg.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include <linux/audit.h>
#include "linux_loop.h"
#include "uname.h"
@@ -2041,6 +2042,44 @@ static abi_long target_to_host_nlmsg_route(struct
nlmsghdr *nlh, size_t len)
return target_to_host_for_each_nlmsg(nlh, len, target_to_host_data_route);
}
+static abi_long host_to_target_data_audit(struct nlmsghdr *nlh)
+{
+ switch (nlh->nlmsg_type) {
+ default:
+ gemu_log("Unknown host audit message type %d\n",
+ nlh->nlmsg_type);
+ return -TARGET_EINVAL;
+ }
+ return 0;
+}
+
+static inline abi_long host_to_target_nlmsg_audit(struct nlmsghdr *nlh,
+ size_t len)
+{
+ return host_to_target_for_each_nlmsg(nlh, len, host_to_target_data_audit);
+}
+
+static abi_long target_to_host_data_audit(struct nlmsghdr *nlh)
+{
+ switch (nlh->nlmsg_type) {
+ case AUDIT_USER:
+ case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
+ case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
+ break;
+ default:
+ gemu_log("Unknown target audit message type %d\n",
+ nlh->nlmsg_type);
+ return -TARGET_EINVAL;
+ }
+
+ return 0;
+}
+
+static abi_long target_to_host_nlmsg_audit(struct nlmsghdr *nlh, size_t len)
+{
+ return target_to_host_for_each_nlmsg(nlh, len, target_to_host_data_audit);
+}
+
/* do_setsockopt() Must return target values and target errnos. */
static abi_long do_setsockopt(int sockfd, int level, int optname,
abi_ulong optval_addr, socklen_t optlen)
@@ -2706,6 +2745,21 @@ static TargetFdTrans target_netlink_route_trans = {
.host_to_target_data = netlink_route_host_to_target,
};
+static abi_long netlink_audit_target_to_host(void *buf, size_t len)
+{
+ return target_to_host_nlmsg_audit(buf, len);
+}
+
+static abi_long netlink_audit_host_to_target(void *buf, size_t len)
+{
+ return host_to_target_nlmsg_audit(buf, len);
+}
+
+static TargetFdTrans target_netlink_audit_trans = {
+ .target_to_host_data = netlink_audit_target_to_host,
+ .host_to_target_data = netlink_audit_host_to_target,
+};
+
/* do_socket() Must return target values and target errnos. */
static abi_long do_socket(int domain, int type, int protocol)
{
@@ -2719,7 +2773,8 @@ static abi_long do_socket(int domain, int type, int
protocol)
if (domain == PF_NETLINK &&
!(protocol == NETLINK_ROUTE ||
- protocol == NETLINK_KOBJECT_UEVENT)) {
+ protocol == NETLINK_KOBJECT_UEVENT ||
+ protocol == NETLINK_AUDIT)) {
return -EPFNOSUPPORT;
}
@@ -2744,6 +2799,9 @@ static abi_long do_socket(int domain, int type, int
protocol)
case NETLINK_KOBJECT_UEVENT:
/* nothing to do: messages are strings */
break;
+ case NETLINK_AUDIT:
+ fd_trans_register(ret, &target_netlink_audit_trans);
+ break;
default:
g_assert_not_reached();
}
--
2.1.4
- [Qemu-devel] [PULL 00/44] linux-user update, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 01/44] linux-user: Fix qemu-binfmt-conf.sh to store config across reboot, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 04/44] linux-user: add netlink audit,
riku . voipio <=
- [Qemu-devel] [PULL 03/44] linux-user: support netlink protocol NETLINK_KOBJECT_UEVENT, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 02/44] linux-user: add rtnetlink(7) support, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 06/44] linux-user: Factor out handle_signal code from process_pending_signals(), riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 07/44] linux-user: Move handle_pending_signal() to avoid need for declaration, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 05/44] linux-user: check if NETLINK_ROUTE is available, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 10/44] linux-user: Define macro for size of host kernel sigset_t, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 08/44] linux-user: Fix stray tab-indent, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 09/44] linux-user: Factor out uses of do_sigprocmask() from sigreturn code, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 11/44] linux-user: Use safe_syscall for sigsuspend syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 13/44] linux-user: Remove redundant default action check in queue_signal(), riku . voipio, 2016/06/08