mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-17 06:59:56 -05:00
use O_NOFOLLOW when creating PID file, to avoid symlink vulnerability
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1891 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
de079ac404
commit
2860685269
1 changed files with 8 additions and 4 deletions
|
|
@ -88,7 +88,12 @@ static int open_pid_file(const char *fn, int mode) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if ((fd = open(fn, mode, S_IRUSR|S_IWUSR)) < 0) {
|
if ((fd = open(fn, mode|O_NOCTTY
|
||||||
|
#ifdef O_NOFOLLOW
|
||||||
|
|O_NOFOLLOW
|
||||||
|
#endif
|
||||||
|
, S_IRUSR|S_IWUSR
|
||||||
|
)) < 0) {
|
||||||
if (mode != O_RDONLY || errno != ENOENT)
|
if (mode != O_RDONLY || errno != ENOENT)
|
||||||
pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
|
pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -184,7 +189,7 @@ int pa_pid_file_create(void) {
|
||||||
fail:
|
fail:
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
pa_lock_fd(fd, 0);
|
pa_lock_fd(fd, 0);
|
||||||
|
|
||||||
if (pa_close(fd) < 0) {
|
if (pa_close(fd) < 0) {
|
||||||
pa_log("Failed to close PID file '%s': %s", fn, pa_cstrerror(errno));
|
pa_log("Failed to close PID file '%s': %s", fn, pa_cstrerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
@ -204,8 +209,7 @@ int pa_pid_file_remove(void) {
|
||||||
pa_runtime_path("pid", fn, sizeof(fn));
|
pa_runtime_path("pid", fn, sizeof(fn));
|
||||||
|
|
||||||
if ((fd = open_pid_file(fn, O_RDWR)) < 0) {
|
if ((fd = open_pid_file(fn, O_RDWR)) < 0) {
|
||||||
pa_log_warn("Failed to open PID file '%s': %s",
|
pa_log_warn("Failed to open PID file '%s': %s", fn, pa_cstrerror(errno));
|
||||||
fn, pa_cstrerror(errno));
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue