mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
Root user gets proper privilege
This commit is contained in:
parent
db4c960a3b
commit
445bae198b
1 changed files with 21 additions and 6 deletions
|
@ -3032,16 +3032,31 @@ void thread_ctrl::set_native_priority(int priority)
|
|||
}
|
||||
#elif defined(__linux__)
|
||||
// available niceness for nonroot: 0~19
|
||||
int linuxprio = 9;
|
||||
// available niceness for root: -20~19
|
||||
|
||||
int linuxprio = 0;
|
||||
id_t threadpid = gettid();
|
||||
|
||||
if (priority > 0)
|
||||
uid_t euid = geteuid();
|
||||
|
||||
if (euid == 0)
|
||||
{
|
||||
linuxprio = 0;
|
||||
else if (priority < 0)
|
||||
linuxprio = 19;
|
||||
if (priority > 0)
|
||||
linuxprio = -6;
|
||||
else if (priority < 0)
|
||||
linuxprio = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
linuxprio = 6;
|
||||
if (priority > 0)
|
||||
linuxprio = 0;
|
||||
else if (priority < 0)
|
||||
linuxprio = 12;
|
||||
}
|
||||
|
||||
// nonroot cannot increase niceness value
|
||||
if (getpriority(PRIO_PROCESS, threadpid) < linuxprio)
|
||||
if ((getpriority(PRIO_PROCESS, threadpid) < linuxprio) || (euid == 0))
|
||||
{
|
||||
if (int err = setpriority(PRIO_PROCESS, threadpid, linuxprio))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue