summaryrefslogtreecommitdiff
path: root/src/bin/e_ipc.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-07-04 18:36:29 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-07-04 18:36:29 +0000
commitcda26e2af7cd322cd56239aacab17c78d4b45f49 (patch)
treea7513f5193ce79d6afb548caf8972198deb84bff /src/bin/e_ipc.c
parent349071a114431ef04b3569dce70f675530510fff (diff)
ipc socket setup will be much more robust now. relies on E_IPC_SOCKET
environment var (but every subprocess of e should inherit this - like DISPLAY). SVN revision: 23714
Diffstat (limited to 'src/bin/e_ipc.c')
-rw-r--r--src/bin/e_ipc.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index 3261800..7e67623 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -16,13 +16,64 @@ e_ipc_init(void)
16{ 16{
17#ifdef USE_IPC 17#ifdef USE_IPC
18 char buf[1024]; 18 char buf[1024];
19 char *disp; 19 char *tmp, *user, *disp;
20 int pid;
20 21
22 tmp = getenv("TMPDIR");
23 if (!tmp) tmp = "/tmp";
24 user = getenv("USER");
25 if (!user) user = "__unknown__";
21 disp = getenv("DISPLAY"); 26 disp = getenv("DISPLAY");
22 if (!disp) disp = ":0"; 27 if (!disp) disp = ":0";
23 snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp); 28 pid = (int)getpid();
24 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, buf, 0, NULL); 29 snprintf(buf, sizeof(buf), "%s/enlightenment-%s", tmp, user);
30 if (mkdir(buf, S_IRWXU) == 0)
31 {
32 }
33 else
34 {
35 struct stat st;
36
37 if (stat(buf, &st) == 0)
38 {
39 if ((st.st_uid ==
40 getuid()) &&
41 ((st.st_mode & S_IFDIR|S_IRWXU|S_IRWXG|S_IRWXO) ==
42 S_IRWXU|S_IFDIR))
43 {
44 }
45 else
46 {
47 snprintf(buf, sizeof(buf),
48 _("Possible IPC Hack Attempt. The IPC socket\n"
49 "directory already exists BUT has permissions\n"
50 "that are too leanient (must only be readable\n"
51 "and writable by the owner, and nobody else)\n"
52 "or is not owned by you. Please check:\n"
53 "%s/enlightenment-%s\n"),
54 tmp, user);
55 e_error_message_show(buf);
56 return 0;
57 }
58 }
59 else
60 {
61 snprintf(buf, sizeof(buf),
62 _("The IPC socket directory cannot be created or\n"
63 "examined.\n"
64 "Please check:\n"
65 "%s/enlightenment-%s\n"),
66 tmp, user);
67 e_error_message_show(buf);
68 return 0;
69 }
70 }
71 snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid);
72 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL);
73 e_util_env_set("E_IPC_SOCKET", "");
25 if (!_e_ipc_server) return 0; 74 if (!_e_ipc_server) return 0;
75 e_util_env_set("E_IPC_SOCKET", buf);
76 printf("INFO: E_IPC_SOCKET=%s\n", buf);
26 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL); 77 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL);
27 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL); 78 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL);
28 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL); 79 ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL);