summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-01 14:04:19 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-01 19:25:36 +0200
commitb3786aa83a55ec910b65ab86be3e44c59d1c01e3 (patch)
treeb428a4d2e2439bd7a41ccc8b524a9b1796c17b70
parent35986549652d3ed1eb9af0baffa064a1ea21adc8 (diff)
exactness: protect against forked calls
there came up a issue, where a excatness spawned processes were bringing up a efreetd instance, when the efreetd instance turned off itself, the files for exactness were written again, which is wrong. This ensures that forked instances do not take any actions. Differential Revision: https://phab.enlightenment.org/D11634
-rw-r--r--src/bin/exactness/common.c25
-rw-r--r--src/bin/exactness/common.h3
-rw-r--r--src/bin/exactness/player.c14
-rw-r--r--src/bin/exactness/recorder.c16
4 files changed, 47 insertions, 11 deletions
diff --git a/src/bin/exactness/common.c b/src/bin/exactness/common.c
index d1bb1340a5..f957003117 100644
--- a/src/bin/exactness/common.c
+++ b/src/bin/exactness/common.c
@@ -4,6 +4,31 @@
4 4
5#include "common.h" 5#include "common.h"
6 6
7Eina_Bool
8ex_is_original_app(void)
9{
10 const char *original_pid_env = getenv("EXACTNESS_ORIGINAL_PID");
11 if (original_pid_env)
12 {
13 pid_t original_pid = atoi(original_pid_env);
14 if (original_pid == getpid())
15 return EINA_TRUE;
16 }
17 return EINA_FALSE;
18}
19
20void
21ex_set_original_envvar(void)
22{
23 const char *original_pid_env = getenv("EXACTNESS_ORIGINAL_PID");
24 if (!original_pid_env)
25 {
26 char pid[30];
27 snprintf(pid, sizeof(pid), "%d", getpid());
28 setenv("EXACTNESS_ORIGINAL_PID", pid, 0);
29 }
30}
31
7void 32void
8ex_prepare_elm_overloay(void) 33ex_prepare_elm_overloay(void)
9{ 34{
diff --git a/src/bin/exactness/common.h b/src/bin/exactness/common.h
index d931973b31..acec924598 100644
--- a/src/bin/exactness/common.h
+++ b/src/bin/exactness/common.h
@@ -260,6 +260,9 @@ typedef struct
260Evas *(*_evas_new)(void); 260Evas *(*_evas_new)(void);
261const char *_exactness_action_type_to_string_get(Exactness_Action_Type type); 261const char *_exactness_action_type_to_string_get(Exactness_Action_Type type);
262 262
263
264Eina_Bool ex_is_original_app(void);
265void ex_set_original_envvar(void);
263Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **diff_img); 266Eina_Bool exactness_image_compare(Exactness_Image *img1, Exactness_Image *img2, Exactness_Image **diff_img);
264Exactness_Unit *exactness_unit_file_read(const char *filename); 267Exactness_Unit *exactness_unit_file_read(const char *filename);
265Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename); 268Eina_Bool exactness_unit_file_write(Exactness_Unit *unit, const char *filename);
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c
index 1240070f37..2440657409 100644
--- a/src/bin/exactness/player.c
+++ b/src/bin/exactness/player.c
@@ -1039,6 +1039,8 @@ eina_init(void)
1039 1039
1040 ORIGINAL_CALL("eina_init"); 1040 ORIGINAL_CALL("eina_init");
1041 1041
1042 ex_set_original_envvar();
1043
1042 if (original_return == 1) 1044 if (original_return == 1)
1043 { 1045 {
1044 const char *dest = getenv("EXACTNESS_DEST"); 1046 const char *dest = getenv("EXACTNESS_DEST");
@@ -1080,7 +1082,7 @@ ecore_evas_init(void)
1080 1082
1081 ORIGINAL_CALL("ecore_evas_init") 1083 ORIGINAL_CALL("ecore_evas_init")
1082 1084
1083 if (original_return == 1) 1085 if (ex_is_original_app() && original_return == 1)
1084 { 1086 {
1085 _setup_ee_creation(); 1087 _setup_ee_creation();
1086 } 1088 }
@@ -1095,7 +1097,7 @@ elm_init(int argc, char **argv)
1095 int original_return; 1097 int original_return;
1096 ORIGINAL_CALL("elm_init", argc, argv) 1098 ORIGINAL_CALL("elm_init", argc, argv)
1097 1099
1098 if (original_return == 1) 1100 if (ex_is_original_app() && original_return == 1)
1099 ex_prepare_elm_overloay(); 1101 ex_prepare_elm_overloay();
1100 1102
1101 return original_return; 1103 return original_return;
@@ -1106,7 +1108,8 @@ ecore_main_loop_begin(void)
1106{ 1108{
1107 int original_return; 1109 int original_return;
1108 ORIGINAL_CALL("ecore_main_loop_begin") 1110 ORIGINAL_CALL("ecore_main_loop_begin")
1109 _write_unit_file(); 1111 if (ex_is_original_app())
1112 _write_unit_file();
1110 (void)original_return; 1113 (void)original_return;
1111} 1114}
1112 1115
@@ -1115,7 +1118,8 @@ efl_loop_begin(Eo *obj)
1115{ 1118{
1116 Eina_Value *original_return; 1119 Eina_Value *original_return;
1117 ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj); 1120 ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj);
1118 _write_unit_file(); 1121 if (ex_is_original_app())
1122 _write_unit_file();
1119 return original_return; 1123 return original_return;
1120} 1124}
1121 1125
@@ -1125,7 +1129,7 @@ eina_shutdown(void)
1125 int original_return; 1129 int original_return;
1126 static Eina_Bool output_written = EINA_FALSE; 1130 static Eina_Bool output_written = EINA_FALSE;
1127 ORIGINAL_CALL("eina_shutdown") 1131 ORIGINAL_CALL("eina_shutdown")
1128 if (original_return == 1 && !output_written) 1132 if (ex_is_original_app() &&original_return == 1 && !output_written)
1129 { 1133 {
1130 output_written = EINA_TRUE; 1134 output_written = EINA_TRUE;
1131 _write_unit_file(); 1135 _write_unit_file();
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 6c881f950f..d7c6e7a1d8 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -314,7 +314,9 @@ eina_init(void)
314 314
315 ORIGINAL_CALL("eina_init"); 315 ORIGINAL_CALL("eina_init");
316 316
317 if (original_return == 1) 317 ex_set_original_envvar();
318
319 if (ex_is_original_app() && original_return == 1)
318 { 320 {
319 _log_domain = eina_log_domain_register("exactness_recorder", NULL); 321 _log_domain = eina_log_domain_register("exactness_recorder", NULL);
320 322
@@ -336,7 +338,7 @@ ecore_evas_init(void)
336 338
337 ORIGINAL_CALL("ecore_evas_init") 339 ORIGINAL_CALL("ecore_evas_init")
338 340
339 if (original_return == 1) 341 if (ex_is_original_app() && original_return == 1)
340 { 342 {
341 _setup_ee_creation(); 343 _setup_ee_creation();
342 344
@@ -352,7 +354,7 @@ elm_init(int argc, char **argv)
352 int original_return; 354 int original_return;
353 ORIGINAL_CALL("elm_init", argc, argv) 355 ORIGINAL_CALL("elm_init", argc, argv)
354 356
355 if (original_return == 1) 357 if (ex_is_original_app() && original_return == 1)
356 ex_prepare_elm_overloay(); 358 ex_prepare_elm_overloay();
357 359
358 return original_return; 360 return original_return;
@@ -363,7 +365,8 @@ ecore_main_loop_begin(void)
363{ 365{
364 int original_return; 366 int original_return;
365 ORIGINAL_CALL("ecore_main_loop_begin") 367 ORIGINAL_CALL("ecore_main_loop_begin")
366 _output_write(); 368 if (ex_is_original_app())
369 _output_write();
367 (void)original_return; 370 (void)original_return;
368} 371}
369 372
@@ -372,7 +375,8 @@ efl_loop_begin(Eo *obj)
372{ 375{
373 Eina_Value *original_return; 376 Eina_Value *original_return;
374 ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj); 377 ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj);
375 _output_write(); 378 if (ex_is_original_app())
379 _output_write();
376 return original_return; 380 return original_return;
377} 381}
378 382
@@ -382,7 +386,7 @@ eina_shutdown(void)
382 int original_return; 386 int original_return;
383 static Eina_Bool output_written = EINA_FALSE; 387 static Eina_Bool output_written = EINA_FALSE;
384 ORIGINAL_CALL("eina_shutdown") 388 ORIGINAL_CALL("eina_shutdown")
385 if (original_return == 1 && !output_written) 389 if (ex_is_original_app() && original_return == 1 && !output_written)
386 { 390 {
387 output_written = EINA_TRUE; 391 output_written = EINA_TRUE;
388 _output_write(); 392 _output_write();