Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ambient capabilities #228

Merged
merged 3 commits into from
Nov 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <time.h>
Expand Down Expand Up @@ -91,6 +92,12 @@ int main(int argc, char* argv[])
fatal(4, "Could not cd to /proc: %s", strerror(errno));
}

// When systemd starts a daemon with capabilities, it uses ambient
// capabilities to do so. If not dropped, the capabilities can spread
// to any child process. This is usually not necessary and its a good
// idea to drop them if not needed.
prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0);

meminfo_t m = parse_meminfo();

int c;
Expand Down