1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 04:31:52 +00:00

Enhhh I think compile time macros are gross

This commit is contained in:
Parnell Springmeyer 2017-01-26 00:41:00 -08:00
parent 785684f6c2
commit a4f905afc2
No known key found for this signature in database
GPG key ID: DCCF89258EAD874A

View file

@ -8,6 +8,11 @@
#include <dirent.h>
#include <assert.h>
#include <errno.h>
#include <linux/capability.h>
#include <sys/capability.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <cap-ng.h>
// Make sure assertions are not compiled out, we use them to codify
// invariants about this program and we want it to fail fast and
@ -32,13 +37,6 @@ fprintf(stderr, "Program must be compiled with either the WRAPPER_SETCAP or WRAP
exit(1);
#endif
#ifdef WRAPPER_SETCAP
#include <linux/capability.h>
#include <sys/capability.h>
#include <linux/prctl.h>
#include <sys/prctl.h>
#include <cap-ng.h>
// Update the capabilities of the running process to include the given
// capability in the Ambient set.
static void set_ambient_cap(cap_value_t cap)
@ -163,7 +161,6 @@ static int make_caps_ambient(const char *selfPath)
return 0;
}
#endif
int main(int argc, char * * argv)
{
@ -211,9 +208,8 @@ int main(int argc, char * * argv)
// Read the capabilities set on the file and raise them in to the
// Ambient set so the program we're wrapping receives the
// capabilities too!
#ifdef WRAPPER_SETCAP
assert(!make_caps_ambient(selfPath));
#endif
if (strcmp(wrapperType, "setcap") == 0)
assert(!make_caps_ambient(selfPath));
execve(sourceProg, argv, environ);