From ef422fa4ae626e9638ca70d1c56f27e701dd69c2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 29 Jun 2004 16:48:37 +0000 Subject: esound protocol git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@40 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/util.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 0383a0ad..95350421 100644 --- a/src/util.c +++ b/src/util.c @@ -1,9 +1,12 @@ +#include #include #include #include #include #include #include +#include +#include #include "util.h" @@ -60,3 +63,23 @@ void peer_to_string(char *c, size_t l, int fd) { snprintf(c, l, "Unknown client"); } + +int make_secure_dir(const char* dir) { + struct stat st; + + if (mkdir(dir, 0700) < 0) + if (errno != EEXIST) + return -1; + + if (lstat(dir, &st) < 0) + goto fail; + + if (!S_ISDIR(st.st_mode) || (st.st_uid != getuid()) || ((st.st_mode & 0777) != 0700)) + goto fail; + + return 0; + +fail: + rmdir(dir); + return -1; +} -- cgit