raster pushed a commit to branch master.
commit 2520c73d04049f1c84c67cc5e3e55c10d2078025
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date: Sun Aug 18 19:51:03 2013 +0900
check permissions on socket dirs and complain if they fail - fallback too
---
src/bin/e_ipc.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 file 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)
#ifdef USE_IPC
char buf[4096], buf2[128], buf3[4096];
char *tmp, *user, *disp, *base;
- int pid, trynum = 0;
+ int pid, trynum = 0, id1 = 0;
+ struct stat st;
tmp = getenv("TMPDIR");
if (!tmp) tmp = "/tmp";
base = tmp;
tmp = getenv("XDG_RUNTIME_DIR");
- if (tmp) base = tmp;
+ if (tmp)
+ {
+ if (stat(tmp, &st) == 0)
+ {
+ if ((st.st_uid == getuid()) &&
+ ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
+ (S_IRWXU | S_IFDIR)))
+ base = tmp;
+ else
+ ERR("XDG_RUNTIME_DIR of '%s' failed permissions check", tmp);
+ }
+ else
+ ERR("XDG_RUNTIME_DIR of '%s' cannot be accessed", tmp);
+ }
+
tmp = getenv("SD_USER_SOCKETS_DIR");
- if (tmp) base = tmp;
+ if (tmp)
+ {
+ if (stat(tmp, &st) == 0)
+ {
+ if ((st.st_uid == getuid()) &&
+ ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
+ (S_IRWXU | S_IFDIR)))
+ base = tmp;
+ else
+ ERR("SD_USER_SOCKETS_DIR of '%s' failed permissions check",
tmp);
+ }
+ else
+ ERR("SD_USER_SOCKETS_DIR of '%s' cannot be accessed", tmp);
+ }
user = getenv("USER");
if (!user)
@@ -50,9 +78,6 @@ e_ipc_init(void)
pid = (int)getpid();
for (trynum = 0; trynum <= 4096; trynum++)
{
- struct stat st;
- int id1 = 0;
-
snprintf(buf, sizeof(buf), "%s/e-%s@%x",
base, user, id1);
mkdir(buf, S_IRWXU);
@@ -71,7 +96,11 @@ e_ipc_init(void)
}
id1 = rand();
}
- if (!_e_ipc_server) return 0;
+ if (!_e_ipc_server)
+ {
+ ERR("Gave up after 4096 sockets in '%s'. All failed", base);
+ return 0;
+ }
e_util_env_set("E_IPC_SOCKET", buf3);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD,
--
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk