libcap, library used to manipulate posix file capabilities uses getcap() to query version of capabilities supported by running kernel. Information obtained from this syscall is then used to initialize data structures that can be used to set process or/and file capabilities.
Providing capget() alone makes it possible to set posix file capabilities under qemu (using setcap(8)). Signed-off-by: Karol Lewandowski <k.lewando...@samsung.com> --- linux-user/syscall.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6257a04..bcd7a05 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -56,6 +56,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include <utime.h> #include <sys/sysinfo.h> #include <sys/utsname.h> +#include <sys/capability.h> //#include <sys/user.h> #include <netinet/ip.h> #include <netinet/tcp.h> @@ -97,6 +98,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include <linux/fb.h> #include <linux/vt.h> #include <linux/dm-ioctl.h> +#include <linux/capability.h> #include "linux_loop.h" #include "cpu-uname.h" @@ -328,6 +330,11 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } +static int sys_capget(struct __user_cap_header_struct *hdr, struct __user_cap_data_struct *data) +{ + return (capget(hdr, data)); +} + #ifdef CONFIG_ATFILE /* * Host system seems to have atfile syscall stubs available. We @@ -7436,7 +7443,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, ret); break; case TARGET_NR_capget: - goto unimplemented; + { + void *p2 = NULL; + if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(struct __user_cap_header_struct), 0))) + goto efault; + if (arg2 && !(p2 = lock_user(VERIFY_WRITE, arg2, sizeof(struct __user_cap_data_struct), 0))) + goto efault; + ret = get_errno(sys_capget(p, p2)); + unlock_user(p, arg1, sizeof(struct __user_cap_header_struct)); + if (arg2) + unlock_user(p, arg2, sizeof(struct __user_cap_data_struct)); + break; + } case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: -- 1.7.5.4