Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
ab3a7c2f
Commit
ab3a7c2f
authored
Dec 07, 2015
by
Michael Klein
Browse files
drop privileges before changing process priority or sending signals
- replaces uid check from
d18e9a48
parent
42b08f22
Changes
2
Show whitespace changes
Inline
Side-by-side
Process.c
View file @
ab3a7c2f
...
@@ -513,16 +513,15 @@ void Process_toggleTag(Process* this) {
...
@@ -513,16 +513,15 @@ void Process_toggleTag(Process* this) {
}
}
bool
Process_setPriority
(
Process
*
this
,
int
priority
)
{
bool
Process_setPriority
(
Process
*
this
,
int
priority
)
{
if
(
Process_getuid
==
0
||
Process_getuid
==
(
int
)
this
->
st_uid
)
{
uid_t
euid
=
geteuid
();
seteuid
(
getuid
());
int
old_prio
=
getpriority
(
PRIO_PROCESS
,
this
->
pid
);
int
old_prio
=
getpriority
(
PRIO_PROCESS
,
this
->
pid
);
int
err
=
setpriority
(
PRIO_PROCESS
,
this
->
pid
,
priority
);
int
err
=
setpriority
(
PRIO_PROCESS
,
this
->
pid
,
priority
);
seteuid
(
euid
);
if
(
err
==
0
&&
old_prio
!=
getpriority
(
PRIO_PROCESS
,
this
->
pid
))
{
if
(
err
==
0
&&
old_prio
!=
getpriority
(
PRIO_PROCESS
,
this
->
pid
))
{
this
->
nice
=
priority
;
this
->
nice
=
priority
;
}
}
return
(
err
==
0
);
return
(
err
==
0
);
}
else
return
false
;
}
}
bool
Process_changePriorityBy
(
Process
*
this
,
size_t
delta
)
{
bool
Process_changePriorityBy
(
Process
*
this
,
size_t
delta
)
{
...
@@ -530,8 +529,10 @@ bool Process_changePriorityBy(Process* this, size_t delta) {
...
@@ -530,8 +529,10 @@ bool Process_changePriorityBy(Process* this, size_t delta) {
}
}
void
Process_sendSignal
(
Process
*
this
,
size_t
sgn
)
{
void
Process_sendSignal
(
Process
*
this
,
size_t
sgn
)
{
if
(
Process_getuid
==
0
||
Process_getuid
==
(
int
)
this
->
st_uid
)
uid_t
euid
=
geteuid
();
seteuid
(
getuid
());
kill
(
this
->
pid
,
(
int
)
sgn
);
kill
(
this
->
pid
,
(
int
)
sgn
);
seteuid
(
euid
);
}
}
long
Process_pidCompare
(
const
void
*
v1
,
const
void
*
v2
)
{
long
Process_pidCompare
(
const
void
*
v1
,
const
void
*
v2
)
{
...
...
Process.h
View file @
ab3a7c2f
...
@@ -158,6 +158,8 @@ typedef struct ProcessClass_ {
...
@@ -158,6 +158,8 @@ typedef struct ProcessClass_ {
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
extern
char
Process_pidFormat
[
20
];
void
Process_setupColumnWidths
();
void
Process_setupColumnWidths
();
void
Process_humanNumber
(
RichString
*
str
,
unsigned
long
number
,
bool
coloring
);
void
Process_humanNumber
(
RichString
*
str
,
unsigned
long
number
,
bool
coloring
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment