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
b14f89e9
Commit
b14f89e9
authored
Jan 06, 2016
by
Michael Klein
Browse files
drop privileges before reading environment
parent
b10e54cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
EnvScreen.c
View file @
b14f89e9
...
...
@@ -60,23 +60,20 @@ static inline void addLine(const char* line, Vector* lines, Panel* panel, const
static
void
EnvScreen_scan
(
EnvScreen
*
this
,
Vector
*
lines
,
IncSet
*
inc
)
{
Panel
*
panel
=
this
->
display
;
int
idx
=
MAX
(
Panel_getSelectedIndex
(
panel
),
0
);
uid_t
uid
=
getuid
();
Panel_prune
(
panel
);
if
(
uid
==
0
||
uid
==
this
->
process
->
st_uid
)
{
char
*
env
=
Platform_getProcessEnv
(
this
->
process
->
pid
);
if
(
env
)
{
for
(
char
*
p
=
env
;
*
p
;
p
=
strrchr
(
p
,
0
)
+
1
)
addLine
(
p
,
lines
,
panel
,
IncSet_filter
(
inc
));
free
(
env
);
}
else
{
addLine
(
"Could not read process environment."
,
lines
,
panel
,
IncSet_filter
(
inc
));
}
uid_t
euid
=
geteuid
();
seteuid
(
getuid
());
char
*
env
=
Platform_getProcessEnv
(
this
->
process
->
pid
);
seteuid
(
euid
);
if
(
env
)
{
for
(
char
*
p
=
env
;
*
p
;
p
=
strrchr
(
p
,
0
)
+
1
)
addLine
(
p
,
lines
,
panel
,
IncSet_filter
(
inc
));
free
(
env
);
}
else
{
addLine
(
"
Process belongs to different user
."
,
lines
,
panel
,
IncSet_filter
(
inc
));
addLine
(
"
Could not read process environment
."
,
lines
,
panel
,
IncSet_filter
(
inc
));
}
Vector_insertionSort
(
lines
);
...
...
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