зеркало из https://github.com/mozilla/gecko-dev.git
Bug 832723 - Unbreak build on BSDs after bug 786631. r=cjones
This commit is contained in:
Родитель
8ceb72cf5e
Коммит
8fb239fc05
|
@ -204,6 +204,10 @@ bool LaunchApp(const CommandLine& cl,
|
|||
return LaunchApp(cl.argv(), no_files, wait, process_handle);
|
||||
}
|
||||
|
||||
void SetCurrentProcessPrivileges(ChildPrivileges privs) {
|
||||
|
||||
}
|
||||
|
||||
#else // no posix_spawn, use fork/exec
|
||||
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
|
@ -255,18 +259,7 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
|||
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
|
||||
argv_cstr[argv.size()] = NULL;
|
||||
|
||||
if (privs == PRIVILEGES_UNPRIVILEGED) {
|
||||
if (setgid(CHILD_UNPRIVILEGED_GID) != 0) {
|
||||
DLOG(ERROR) << "FAILED TO setgid() CHILD PROCESS, path: " << argv_cstr[0];
|
||||
_exit(127);
|
||||
}
|
||||
if (setuid(CHILD_UNPRIVILEGED_UID) != 0) {
|
||||
DLOG(ERROR) << "FAILED TO setuid() CHILD PROCESS, path: " << argv_cstr[0];
|
||||
_exit(127);
|
||||
}
|
||||
if (chdir("/") != 0)
|
||||
gProcessLog.print("==> could not chdir()\n");
|
||||
}
|
||||
SetCurrentProcessPrivileges(privs);
|
||||
|
||||
for (environment_map::const_iterator it = env_vars_to_set.begin();
|
||||
it != env_vars_to_set.end(); ++it) {
|
||||
|
@ -297,6 +290,25 @@ bool LaunchApp(const CommandLine& cl,
|
|||
return LaunchApp(cl.argv(), no_files, wait, process_handle);
|
||||
}
|
||||
|
||||
void SetCurrentProcessPrivileges(ChildPrivileges privs) {
|
||||
if (privs == PRIVILEGES_INHERIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
gid_t gid = CHILD_UNPRIVILEGED_GID;
|
||||
uid_t uid = CHILD_UNPRIVILEGED_UID;
|
||||
if (setgid(gid) != 0) {
|
||||
DLOG(ERROR) << "FAILED TO setgid() CHILD PROCESS";
|
||||
_exit(127);
|
||||
}
|
||||
if (setuid(uid) != 0) {
|
||||
DLOG(ERROR) << "FAILED TO setuid() CHILD PROCESS";
|
||||
_exit(127);
|
||||
}
|
||||
if (chdir("/") != 0)
|
||||
gProcessLog.print("==> could not chdir()\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
|
||||
|
|
Загрузка…
Ссылка в новой задаче