mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12: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__)
|
#elif defined(__linux__)
|
||||||
// available niceness for nonroot: 0~19
|
// available niceness for nonroot: 0~19
|
||||||
int linuxprio = 9;
|
// available niceness for root: -20~19
|
||||||
|
|
||||||
|
int linuxprio = 0;
|
||||||
id_t threadpid = gettid();
|
id_t threadpid = gettid();
|
||||||
|
uid_t euid = geteuid();
|
||||||
if (priority > 0)
|
|
||||||
|
if (euid == 0)
|
||||||
|
{
|
||||||
linuxprio = 0;
|
linuxprio = 0;
|
||||||
else if (priority < 0)
|
if (priority > 0)
|
||||||
linuxprio = 19;
|
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
|
// 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))
|
if (int err = setpriority(PRIO_PROCESS, threadpid, linuxprio))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue