summaryrefslogtreecommitdiff
path: root/src/bin/e_ipc.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-08-18 19:51:03 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-08-18 21:28:03 +0900
commit2520c73d04049f1c84c67cc5e3e55c10d2078025 (patch)
tree939ffd64d48bbb691f12694e54af0e91593f3958 /src/bin/e_ipc.c
parent5f4027dbca5dd9864caceaa89de4726a25e87f71 (diff)
check permissions on socket dirs and complain if they fail - fallback too
Diffstat (limited to 'src/bin/e_ipc.c')
-rw-r--r--src/bin/e_ipc.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index 24d7c18..765b56e 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -17,16 +17,44 @@ e_ipc_init(void)
17#ifdef USE_IPC 17#ifdef USE_IPC
18 char buf[4096], buf2[128], buf3[4096]; 18 char buf[4096], buf2[128], buf3[4096];
19 char *tmp, *user, *disp, *base; 19 char *tmp, *user, *disp, *base;
20 int pid, trynum = 0; 20 int pid, trynum = 0, id1 = 0;
21 struct stat st;
21 22
22 tmp = getenv("TMPDIR"); 23 tmp = getenv("TMPDIR");
23 if (!tmp) tmp = "/tmp"; 24 if (!tmp) tmp = "/tmp";
24 base = tmp; 25 base = tmp;
25 26
26 tmp = getenv("XDG_RUNTIME_DIR"); 27 tmp = getenv("XDG_RUNTIME_DIR");
27 if (tmp) base = tmp; 28 if (tmp)
29 {
30 if (stat(tmp, &st) == 0)
31 {
32 if ((st.st_uid == getuid()) &&
33 ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
34 (S_IRWXU | S_IFDIR)))
35 base = tmp;
36 else
37 ERR("XDG_RUNTIME_DIR of '%s' failed permissions check", tmp);
38 }
39 else
40 ERR("XDG_RUNTIME_DIR of '%s' cannot be accessed", tmp);
41 }
42
28 tmp = getenv("SD_USER_SOCKETS_DIR"); 43 tmp = getenv("SD_USER_SOCKETS_DIR");
29 if (tmp) base = tmp; 44 if (tmp)
45 {
46 if (stat(tmp, &st) == 0)
47 {
48 if ((st.st_uid == getuid()) &&
49 ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
50 (S_IRWXU | S_IFDIR)))
51 base = tmp;
52 else
53 ERR("SD_USER_SOCKETS_DIR of '%s' failed permissions check", tmp);
54 }
55 else
56 ERR("SD_USER_SOCKETS_DIR of '%s' cannot be accessed", tmp);
57 }
30 58
31 user = getenv("USER"); 59 user = getenv("USER");
32 if (!user) 60 if (!user)
@@ -50,9 +78,6 @@ e_ipc_init(void)
50 pid = (int)getpid(); 78 pid = (int)getpid();
51 for (trynum = 0; trynum <= 4096; trynum++) 79 for (trynum = 0; trynum <= 4096; trynum++)
52 { 80 {
53 struct stat st;
54 int id1 = 0;
55
56 snprintf(buf, sizeof(buf), "%s/e-%s@%x", 81 snprintf(buf, sizeof(buf), "%s/e-%s@%x",
57 base, user, id1); 82 base, user, id1);
58 mkdir(buf, S_IRWXU); 83 mkdir(buf, S_IRWXU);
@@ -71,7 +96,11 @@ e_ipc_init(void)
71 } 96 }
72 id1 = rand(); 97 id1 = rand();
73 } 98 }
74 if (!_e_ipc_server) return 0; 99 if (!_e_ipc_server)
100 {
101 ERR("Gave up after 4096 sockets in '%s'. All failed", base);
102 return 0;
103 }
75 104
76 e_util_env_set("E_IPC_SOCKET", buf3); 105 e_util_env_set("E_IPC_SOCKET", buf3);
77 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, 106 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,