From 33675991507b04df8142bf687bcb7d4d651c1c95 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 21 Oct 2006 05:57:27 +0000 Subject: [PATCH] force people to do things right and use enlightenment_start SVN revision: 26726 --- src/bin/e_main.c | 12 ++++++++++++ src/bin/e_start_main.c | 36 +++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 3e8fb673a..5f75b3fcd 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -337,6 +337,18 @@ main(int argc, char **argv) _e_main_shutdown(-1); } _e_main_shutdown_push(e_alert_shutdown); + + /* we want to have been launched by enlightenment_start. there is a very */ + /* good reason we want to have been launched this way, thus check */ + if (!getenv("E_START")) + { + e_alert_show("You are executing enlightenment directly. This is bad. Please do not execute the\n" + "\"enlightenment\" binary. Use the \"enlightenment_start\" launcher. It will\n" + "handle setting up environment variables, paths, and launching any other required\n" + "services etc. before enlightenment itself begins running.\n"); + exit(-1); + } + if (!e_xinerama_init()) { e_error_message_show(_("Enlightenment cannot setup xinerama wrapping.\n" diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index 6fc168ae8..6286ea211 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -1,8 +1,11 @@ +#include "config.h" #include #include #include #include -#include "config.h" +#ifdef HAVE_ALLOCA_H +#include +#endif static void env_set(const char *var, const char *val); static int prefix_determine(char *argv0); @@ -15,8 +18,9 @@ env_set(const char *var, const char *val) #ifdef HAVE_SETENV setenv(var, val, 1); #else - char buf[8192]; + char *buf; + buf = alloca(strlen(var) + 1 + strlen(val) + 1); snprintf(buf, sizeof(buf), "%s=%s", var, val); if (getenv(var)) putenv(buf); @@ -248,31 +252,29 @@ int main(int argc, char **argv) { int i; - char buf[16384]; - char **args; - char *p; + char buf[16384], **args, *p; prefix_determine(argv[0]); + + env_set("E_START", argv[0]); + p = getenv("PATH"); - if (p) - snprintf(buf, sizeof(buf), "%s/bin:%s", _prefix_path, p); - else - snprintf(buf, sizeof(buf), "%s/bin", _prefix_path); + if (p) snprintf(buf, sizeof(buf), "%s/bin:%s", _prefix_path, p); + else snprintf(buf, sizeof(buf), "%s/bin", _prefix_path); env_set("PATH", buf); p = getenv("LD_LIBRARY_PATH"); - if (p) - snprintf(buf, sizeof(buf), "%s/lib:%s", _prefix_path, p); - else - snprintf(buf, sizeof(buf), "%s/lib", _prefix_path); + if (p) snprintf(buf, sizeof(buf), "%s/lib:%s", _prefix_path, p); + else snprintf(buf, sizeof(buf), "%s/lib", _prefix_path); env_set("LD_LIBRARY_PATH", buf); - args = malloc((argc + 1) * sizeof(char *)); + args = alloca((argc + 1) * sizeof(char *)); args[0] = "enlightenment"; - for (i = 1; i < argc; i++) - args[i] = argv[i]; + for (i = 1; i < argc; i++) args[i] = argv[i]; args[i] = NULL; snprintf(buf, sizeof(buf), "%s/bin/enlightenment", _prefix_path); - return execv(buf, args); + execv(buf, args); + perror("execv"); + return -1; }