summaryrefslogtreecommitdiff
path: root/src/bin/e_ipc.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-06-29 14:13:34 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-06-29 14:13:34 +0000
commit2b8c0c4d6e2ab2b26346a6bbd972236d53457dfb (patch)
tree8fdb0335daddb98a24c238cefe10b4e96bdfe992 /src/bin/e_ipc.c
parent71bdb93fbab1e57685a3efa29d2cc36a7a11f36b (diff)
ecrustified
SVN revision: 60819
Diffstat (limited to 'src/bin/e_ipc.c')
-rw-r--r--src/bin/e_ipc.c200
1 files changed, 109 insertions, 91 deletions
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index 31280b6..4f6f4d8 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -2,9 +2,15 @@
2 2
3#ifdef USE_IPC 3#ifdef USE_IPC
4/* local subsystem functions */ 4/* local subsystem functions */
5static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event); 5static Eina_Bool _e_ipc_cb_client_add(void *data __UNUSED__,
6static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event); 6 int type __UNUSED__,
7static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event); 7 void *event);
8static Eina_Bool _e_ipc_cb_client_del(void *data __UNUSED__,
9 int type __UNUSED__,
10 void *event);
11static Eina_Bool _e_ipc_cb_client_data(void *data __UNUSED__,
12 int type __UNUSED__,
13 void *event);
8 14
9/* local subsystem globals */ 15/* local subsystem globals */
10static Ecore_Ipc_Server *_e_ipc_server = NULL; 16static Ecore_Ipc_Server *_e_ipc_server = NULL;
@@ -32,35 +38,35 @@ e_ipc_init(void)
32 } 38 }
33 else 39 else
34 { 40 {
35 struct stat st; 41 struct stat st;
36 42
37 if (stat(buf, &st) == 0) 43 if (stat(buf, &st) == 0)
38 { 44 {
39 if ((st.st_uid == 45 if ((st.st_uid ==
40 getuid()) && 46 getuid()) &&
41 ((st.st_mode & (S_IFDIR|S_IRWXU|S_IRWXG|S_IRWXO)) == 47 ((st.st_mode & (S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)) ==
42 (S_IRWXU|S_IFDIR))) 48 (S_IRWXU | S_IFDIR)))
43 { 49 {
44 } 50 }
45 else 51 else
46 { 52 {
47 e_error_message_show(_("Possible IPC Hack Attempt. The IPC socket\n" 53 e_error_message_show(_("Possible IPC Hack Attempt. The IPC socket\n"
48 "directory already exists BUT has permissions\n" 54 "directory already exists BUT has permissions\n"
49 "that are too leanient (must only be readable\n" "and writable by the owner, and nobody else)\n" 55 "that are too leanient (must only be readable\n" "and writable by the owner, and nobody else)\n"
50 "or is not owned by you. Please check:\n" 56 "or is not owned by you. Please check:\n"
51 "%s/enlightenment-%s\n"), tmp, user); 57 "%s/enlightenment-%s\n"), tmp, user);
52 return 0; 58 return 0;
53 } 59 }
54 } 60 }
55 else 61 else
56 { 62 {
57 e_error_message_show(_("The IPC socket directory cannot be created or\n" 63 e_error_message_show(_("The IPC socket directory cannot be created or\n"
58 "examined.\n" 64 "examined.\n"
59 "Please check:\n" 65 "Please check:\n"
60 "%s/enlightenment-%s\n"), 66 "%s/enlightenment-%s\n"),
61 tmp, user); 67 tmp, user);
62 return 0; 68 return 0;
63 } 69 }
64 } 70 }
65 snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid); 71 snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid);
66 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL); 72 _e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL);
@@ -84,8 +90,8 @@ e_ipc_shutdown(void)
84 e_ipc_codec_shutdown(); 90 e_ipc_codec_shutdown();
85 if (_e_ipc_server) 91 if (_e_ipc_server)
86 { 92 {
87 ecore_ipc_server_del(_e_ipc_server); 93 ecore_ipc_server_del(_e_ipc_server);
88 _e_ipc_server = NULL; 94 _e_ipc_server = NULL;
89 } 95 }
90#endif 96#endif
91 return 1; 97 return 1;
@@ -94,7 +100,9 @@ e_ipc_shutdown(void)
94#ifdef USE_IPC 100#ifdef USE_IPC
95/* local subsystem globals */ 101/* local subsystem globals */
96static Eina_Bool 102static Eina_Bool
97_e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event) 103_e_ipc_cb_client_add(void *data __UNUSED__,
104 int type __UNUSED__,
105 void *event)
98{ 106{
99 Ecore_Ipc_Event_Client_Add *e; 107 Ecore_Ipc_Event_Client_Add *e;
100 108
@@ -104,7 +112,9 @@ _e_ipc_cb_client_add(void *data __UNUSED__, int type __UNUSED__, void *event)
104} 112}
105 113
106static Eina_Bool 114static Eina_Bool
107_e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event) 115_e_ipc_cb_client_del(void *data __UNUSED__,
116 int type __UNUSED__,
117 void *event)
108{ 118{
109 Ecore_Ipc_Event_Client_Del *e; 119 Ecore_Ipc_Event_Client_Del *e;
110 120
@@ -119,7 +129,9 @@ _e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
119} 129}
120 130
121static Eina_Bool 131static Eina_Bool
122_e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event) 132_e_ipc_cb_client_data(void *data __UNUSED__,
133 int type __UNUSED__,
134 void *event)
123{ 135{
124 Ecore_Ipc_Event_Client_Data *e; 136 Ecore_Ipc_Event_Client_Data *e;
125 137
@@ -133,67 +145,73 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
133 case E_IPC_DOMAIN_EVENT: 145 case E_IPC_DOMAIN_EVENT:
134 switch (e->minor) 146 switch (e->minor)
135 { 147 {
136 case E_IPC_OP_EXEC_ACTION: 148 case E_IPC_OP_EXEC_ACTION:
137 { 149 {
138 E_Ipc_2Str *req = NULL; 150 E_Ipc_2Str *req = NULL;
139 151
140 if (e_ipc_codec_2str_dec(e->data, e->size, &req)) 152 if (e_ipc_codec_2str_dec(e->data, e->size, &req))
141 { 153 {
142 Eina_List *m = e_manager_list(); 154 Eina_List *m = e_manager_list();
143 int len, ok = 0; 155 int len, ok = 0;
144 void *d; 156 void *d;
145 157
146 if (m) 158 if (m)
147 { 159 {
148 E_Manager *man = eina_list_data_get(m); 160 E_Manager *man = eina_list_data_get(m);
149 161
150 if (man) 162 if (man)
151 { 163 {
152 E_Action *act = e_action_find(req->str1); 164 E_Action *act = e_action_find(req->str1);
153 165
154 if (act && act->func.go) 166 if (act && act->func.go)
155 { 167 {
156 act->func.go(E_OBJECT(man), req->str2); 168 act->func.go(E_OBJECT(man), req->str2);
157 ok = 1; 169 ok = 1;
158 } 170 }
159 } 171 }
160 } 172 }
161 173
162 d = e_ipc_codec_int_enc(ok, &len); 174 d = e_ipc_codec_int_enc(ok, &len);
163 if (d) 175 if (d)
164 { 176 {
165 ecore_ipc_client_send(e->client, 177 ecore_ipc_client_send(e->client,
166 E_IPC_DOMAIN_REPLY, 178 E_IPC_DOMAIN_REPLY,
167 E_IPC_OP_EXEC_ACTION_REPLY, 179 E_IPC_OP_EXEC_ACTION_REPLY,
168 0, 0, 0, d, len); 180 0, 0, 0, d, len);
169 free(d); 181 free(d);
170 } 182 }
171 183
172 if (req) 184 if (req)
173 { 185 {
174 E_FREE(req->str1); 186 E_FREE(req->str1);
175 E_FREE(req->str2); 187 E_FREE(req->str2);
176 E_FREE(req); 188 E_FREE(req);
177 } 189 }
178 } 190 }
179 } 191 }
180 break; 192 break;
181 default: 193
194 default:
182 break; 195 break;
183 } 196 }
184 break; 197 break;
198
185 case E_IPC_DOMAIN_THUMB: 199 case E_IPC_DOMAIN_THUMB:
186 e_thumb_client_data(e); 200 e_thumb_client_data(e);
187 break; 201 break;
202
188 case E_IPC_DOMAIN_FM: 203 case E_IPC_DOMAIN_FM:
189 e_fm2_client_data(e); 204 e_fm2_client_data(e);
190 break; 205 break;
206
191 case E_IPC_DOMAIN_INIT: 207 case E_IPC_DOMAIN_INIT:
192 e_init_client_data(e); 208 e_init_client_data(e);
193 break; 209 break;
210
194 default: 211 default:
195 break; 212 break;
196 } 213 }
197 return 1; 214 return 1;
198} 215}
216
199#endif 217#endif