linux: Use capget syscall instead of its libc wrapper

The sys/capability.h header is only present if libcap is installed. We
were only using it for its declaration of a capget() wrapper. Using the
system call directly allows compiling without installing libcap.

Change-Id: I83dfc5c8d56bb3cdd4efb62e0c568d8a221334cd
Reviewed-on: https://chromium-review.googlesource.com/c/1292231
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Joshua Peraza 2018-10-19 13:14:36 -07:00 committed by Commit Bot
parent df5d1aa3ff
commit 8e329d12c7

View File

@ -15,10 +15,11 @@
#include "handler/linux/exception_handler_server.h" #include "handler/linux/exception_handler_server.h"
#include <errno.h> #include <errno.h>
#include <sys/capability.h> #include <linux/capability.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <sys/eventfd.h> #include <sys/eventfd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -95,7 +96,7 @@ bool HaveCapSysPtrace() {
cap_header.pid = getpid(); cap_header.pid = getpid();
if (capget(&cap_header, &cap_data) != 0) { if (syscall(SYS_capget, &cap_header, &cap_data) != 0) {
PLOG(ERROR) << "capget"; PLOG(ERROR) << "capget";
return false; return false;
} }