Skip to content

Hacking #1291

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Hacking #1291

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
14 changes: 14 additions & 0 deletions starter/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/capability.h>
#include <linux/limits.h>
#include <linux/prctl.h>
#include <sys/stat.h>

#include "starter/privileged_service_protocol.h"
#include "starter/privileged_service_server.h"
Expand Down Expand Up @@ -166,6 +167,19 @@ int main(int argc, char** argv) {
}

envoy_args.push_back(nullptr);

// Get the file's owner UID
struct stat file_stat;
if (stat(path, &file_stat) != 0) {
perror("stat failed");
exit(1);
}
// Switch to the target user
if (setuid(file_stat.st_uid) != 0) {
perror("setuid failed");
exit(1);
}

execv(path, &envoy_args[0]);
perror("execv");
exit(1);
Expand Down
Loading