mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
Move check for SUID into the caps functions.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1119 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
8d2dc9c4d1
commit
57d8a315ea
2 changed files with 11 additions and 4 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
#include <sys/capability.h>
|
||||
|
|
@ -80,6 +81,10 @@ int pa_limit_caps(void) {
|
|||
cap_t caps;
|
||||
cap_value_t nice_cap = CAP_SYS_NICE;
|
||||
|
||||
/* Only drop caps when called SUID */
|
||||
if (getuid() != 0)
|
||||
return 0;
|
||||
|
||||
caps = cap_init();
|
||||
assert(caps);
|
||||
|
||||
|
|
@ -106,6 +111,10 @@ int pa_drop_caps(void) {
|
|||
cap_t caps;
|
||||
int r = -1;
|
||||
|
||||
/* Only drop caps when called SUID */
|
||||
if (getuid() != 0)
|
||||
return 0;
|
||||
|
||||
caps = cap_init();
|
||||
assert(caps);
|
||||
|
||||
|
|
|
|||
|
|
@ -328,8 +328,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
if (getuid() != 0)
|
||||
pa_limit_caps();
|
||||
pa_limit_caps();
|
||||
|
||||
#ifdef HAVE_GETUID
|
||||
suid_root = getuid() != 0 && geteuid() == 0;
|
||||
|
|
@ -377,8 +376,7 @@ int main(int argc, char *argv[]) {
|
|||
if (conf->high_priority && conf->cmd == PA_CMD_DAEMON)
|
||||
pa_raise_priority();
|
||||
|
||||
if (getuid() != 0)
|
||||
pa_drop_caps();
|
||||
pa_drop_caps();
|
||||
|
||||
if (suid_root)
|
||||
pa_drop_root();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue