summaryrefslogtreecommitdiffstats
path: root/src/socket-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket-util.c')
-rw-r--r--src/socket-util.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/socket-util.c b/src/socket-util.c
index f9451af8..f4648da5 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -14,6 +14,7 @@
#include <netinet/ip.h>
#include "socket-util.h"
+#include "util.h"
void pa_socket_peer_to_string(int fd, char *c, size_t l) {
struct stat st;
@@ -150,3 +151,41 @@ int pa_unix_socket_remove_stale(const char *fn) {
return 0;
}
+
+int pa_unix_socket_make_secure_dir(const char *fn) {
+ int ret = -1;
+ char *slash, *dir = strdup(fn);
+ assert(dir);
+
+ if (!(slash = strrchr(dir, '/')))
+ goto finish;
+ *slash = 0;
+
+ if (pa_make_secure_dir(dir) < 0)
+ goto finish;
+
+ ret = 0;
+
+finish:
+ free(dir);
+ return ret;
+}
+
+int pa_unix_socket_remove_secure_dir(const char *fn) {
+ int ret = -1;
+ char *slash, *dir = strdup(fn);
+ assert(dir);
+
+ if (!(slash = strrchr(dir, '/')))
+ goto finish;
+ *slash = 0;
+
+ if (rmdir(dir) < 0)
+ goto finish;
+
+ ret = 0;
+
+finish:
+ free(dir);
+ return ret;
+}