diff options
| author | 2019-07-03 03:09:10 +0000 | |
|---|---|---|
| committer | 2019-07-03 03:09:10 +0000 | |
| commit | e928d0b1bfc4b7707c41ead270e928f3c2f0fb0a (patch) | |
| tree | 93a9b59c7cd91eb47c2d453a0891c6b79e4cd8dd /libs | |
| parent | 9c9e61e8756d6c99978d7c027aa55ac0afbb393a (diff) | |
| parent | 660c234e9ad68cd23feb2e22cb43bd7a645b24e6 (diff) | |
Snap for 5704971 from 660c234e9ad68cd23feb2e22cb43bd7a645b24e6 to qt-release
Change-Id: I5702c91fc67523a99b1403908c1735ea034e8b0a
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/androidfw/PosixUtils.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/androidfw/PosixUtils.cpp b/libs/androidfw/PosixUtils.cpp index df0dd7ce463d..f1ab1493012a 100644 --- a/libs/androidfw/PosixUtils.cpp +++ b/libs/androidfw/PosixUtils.cpp @@ -64,6 +64,9 @@ std::unique_ptr<ProcResult> ExecuteBinary(const std::vector<std::string>& argv) return nullptr; } + auto gid = getgid(); + auto uid = getuid(); + char const** argv0 = (char const**)malloc(sizeof(char*) * (argv.size() + 1)); for (size_t i = 0; i < argv.size(); i++) { argv0[i] = argv[i].c_str(); @@ -75,6 +78,16 @@ std::unique_ptr<ProcResult> ExecuteBinary(const std::vector<std::string>& argv) PLOG(ERROR) << "fork"; return nullptr; case 0: // child + if (setgid(gid) != 0) { + PLOG(ERROR) << "setgid"; + exit(1); + } + + if (setuid(uid) != 0) { + PLOG(ERROR) << "setuid"; + exit(1); + } + close(stdout[0]); if (dup2(stdout[1], STDOUT_FILENO) == -1) { abort(); |