summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-30 22:26:30 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-01 12:03:01 +0900
commit8cabf2708520539cf25ca0a876f9c044f6d56a77 (patch)
treeb60490bc57dcd826529d09400c903f739586dbe5
parent1ff718fe4e772a3aa5386e3ad810c7667fda1e50 (diff)
e_sys - address security concerns with environment and gdb
1. clear out environment as best is possible before executing anything. especially PATH and IFS are set to minimal base defaults. also use clearenv() if available and unsetenv() 2. remove gdb method as it's just too dangerous. run it as normal as the user and if the kernel / distro dny that - then sorry. too bad. Conflicts: data/etc/sysactions.conf.in src/bin/e_sys_main.c
-rw-r--r--configure.ac2
-rw-r--r--data/etc/sysactions.conf.in1
-rw-r--r--src/bin/e_start_main.c3
-rw-r--r--src/bin/e_sys_main.c61
4 files changed, 27 insertions, 40 deletions
diff --git a/configure.ac b/configure.ac
index 174e567..1a10ae5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,8 @@ EFL_CHECK_PATH_MAX
74 74
75AC_CHECK_FUNCS(setenv) 75AC_CHECK_FUNCS(setenv)
76AC_CHECK_FUNCS(unsetenv) 76AC_CHECK_FUNCS(unsetenv)
77AC_CHECK_FUNCS(clearenv)
78AC_CHECK_HEADERS([features.h])
77 79
78efl_version="1.7.9" 80efl_version="1.7.9"
79AC_SUBST(efl_version) 81AC_SUBST(efl_version)
diff --git a/data/etc/sysactions.conf.in b/data/etc/sysactions.conf.in
index 6054a04..4e1c725 100644
--- a/data/etc/sysactions.conf.in
+++ b/data/etc/sysactions.conf.in
@@ -50,7 +50,6 @@ action: hibernate @HIBERNATE@
50action: /bin/mount /bin/mount 50action: /bin/mount /bin/mount
51action: /bin/umount /bin/umount 51action: /bin/umount /bin/umount
52action: /usr/bin/eject /usr/bin/eject 52action: /usr/bin/eject /usr/bin/eject
53action: gdb gdb
54 53
55# on FreeBSD use this instead of the above. 54# on FreeBSD use this instead of the above.
56#action suspend /usr/sbin/zzz 55#action suspend /usr/sbin/zzz
diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c
index 0afa0e0..65f3efc 100644
--- a/src/bin/e_start_main.c
+++ b/src/bin/e_start_main.c
@@ -517,8 +517,7 @@ main(int argc, char **argv)
517 { 517 {
518 /* call e_sys gdb */ 518 /* call e_sys gdb */
519 snprintf(buffer, 4096, 519 snprintf(buffer, 4096,
520 "%s/enlightenment/utils/enlightenment_sys gdb %i %s/.e-crashdump.txt", 520 "gdb %i %s/.e-crashdump.txt",
521 eina_prefix_lib_get(pfx),
522 child, 521 child,
523 home); 522 home);
524 r = system(buffer); 523 r = system(buffer);
diff --git a/src/bin/e_sys_main.c b/src/bin/e_sys_main.c
index 2364496..16aa14a 100644
--- a/src/bin/e_sys_main.c
+++ b/src/bin/e_sys_main.c
@@ -1,5 +1,11 @@
1#include "config.h" 1#include "config.h"
2 2
3#define __USE_MISC
4#define _SVID_SOURCE
5#ifdef HAVE_FEATURES_H
6# include <features.h>
7#endif
8
3#include <stdio.h> 9#include <stdio.h>
4#include <stdlib.h> 10#include <stdlib.h>
5#include <unistd.h> 11#include <unistd.h>
@@ -51,7 +57,6 @@ main(int argc,
51 const char *act; 57 const char *act;
52#endif 58#endif
53 gid_t gid, gl[65536], egid; 59 gid_t gid, gl[65536], egid;
54 int pid = 0;
55 60
56 for (i = 1; i < argc; i++) 61 for (i = 1; i < argc; i++)
57 { 62 {
@@ -73,21 +78,6 @@ main(int argc,
73 test = 1; 78 test = 1;
74 action = argv[2]; 79 action = argv[2];
75 } 80 }
76 else if (!strcmp(argv[1], "gdb"))
77 {
78 if (argc != 4) exit(1);
79 char *end = NULL;
80
81 action = argv[1];
82 pid = strtoul(argv[2], &end, 10);
83 if (end == NULL || *end != '\0')
84 {
85 printf("Invalid pid for '%s'.\n", argv[3]);
86 exit(0);
87 }
88
89 output = argv[3];
90 }
91#ifdef HAVE_EEZE_MOUNT 81#ifdef HAVE_EEZE_MOUNT
92 else 82 else
93 { 83 {
@@ -154,31 +144,28 @@ main(int argc,
154 exit(20); 144 exit(20);
155 } 145 }
156 146
157 if (!strcmp(action, "gdb")) 147 /* sanitize environment */
158 { 148#ifdef HAVE_UNSETENV
159 char buffer[4096]; 149# define NOENV(x) unsetenv(x)
160 int r; 150#else
161 151# define NOENV(x)
162 snprintf(buffer, 4096, 152#endif
163 "%s --pid=%i " 153 NOENV("IFS");
164 "-batch " 154 NOENV("LD_PRELOAD");
165 "-ex 'set logging file %s' " 155 NOENV("PYTHONPATH");
166 "-ex 'set logging on' " 156 NOENV("LD_LIBRARY_PATH");
167 "-ex 'thread apply all backtrace full' " 157#ifdef HAVE_CLEARENV
168 "-ex detach > /dev/null 2>&1 < /dev/zero", 158 clearenv();
169 cmd, 159#endif
170 pid, 160 /* set path and ifs to minimal defaults */
171 output ?: "e-output.txt"); 161 putenv("PATH=/bin:/usr/bin");
172 162 putenv("IFS= \t\n");
173 r = system(buffer); 163
174
175 exit(WEXITSTATUS(r));
176 }
177 if ((!test) 164 if ((!test)
178#ifdef HAVE_EEZE_MOUNT 165#ifdef HAVE_EEZE_MOUNT
179 && (!mnt) 166 && (!mnt)
180#endif 167#endif
181 ) 168 )
182 return system(cmd); 169 return system(cmd);
183#ifdef HAVE_EEZE_MOUNT 170#ifdef HAVE_EEZE_MOUNT
184 if (mnt) 171 if (mnt)