summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-06-29 16:48:37 +0000
committerLennart Poettering <lennart@poettering.net>2004-06-29 16:48:37 +0000
commitef422fa4ae626e9638ca70d1c56f27e701dd69c2 (patch)
tree1dd62aee8ec44f3d3c7d5f4bacb3d2b38769e5b3 /src/util.c
parenta74cd2a1bd92eac6a4140d0794ac4b557be6c133 (diff)
esound protocol
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@40 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c23
1 files changed, 23 insertions, 0 deletions
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 <errno.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
#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;
+}