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
This commit is contained in:
parent
349071a114
commit
cda26e2af7
|
@ -16,13 +16,64 @@ e_ipc_init(void)
|
|||
{
|
||||
#ifdef USE_IPC
|
||||
char buf[1024];
|
||||
char *disp;
|
||||
char *tmp, *user, *disp;
|
||||
int pid;
|
||||
|
||||
tmp = getenv("TMPDIR");
|
||||
if (!tmp) tmp = "/tmp";
|
||||
user = getenv("USER");
|
||||
if (!user) user = "__unknown__";
|
||||
disp = getenv("DISPLAY");
|
||||
if (!disp) disp = ":0";
|
||||
snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp);
|
||||
_e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, buf, 0, NULL);
|
||||
pid = (int)getpid();
|
||||
snprintf(buf, sizeof(buf), "%s/enlightenment-%s", tmp, user);
|
||||
if (mkdir(buf, S_IRWXU) == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(buf, &st) == 0)
|
||||
{
|
||||
if ((st.st_uid ==
|
||||
getuid()) &&
|
||||
((st.st_mode & S_IFDIR|S_IRWXU|S_IRWXG|S_IRWXO) ==
|
||||
S_IRWXU|S_IFDIR))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buf, sizeof(buf),
|
||||
_("Possible IPC Hack Attempt. The IPC socket\n"
|
||||
"directory already exists BUT has permissions\n"
|
||||
"that are too leanient (must only be readable\n"
|
||||
"and writable by the owner, and nobody else)\n"
|
||||
"or is not owned by you. Please check:\n"
|
||||
"%s/enlightenment-%s\n"),
|
||||
tmp, user);
|
||||
e_error_message_show(buf);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buf, sizeof(buf),
|
||||
_("The IPC socket directory cannot be created or\n"
|
||||
"examined.\n"
|
||||
"Please check:\n"
|
||||
"%s/enlightenment-%s\n"),
|
||||
tmp, user);
|
||||
e_error_message_show(buf);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s/enlightenment-%s/disp-%s-%i", tmp, user, disp, pid);
|
||||
_e_ipc_server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, buf, 0, NULL);
|
||||
e_util_env_set("E_IPC_SOCKET", "");
|
||||
if (!_e_ipc_server) return 0;
|
||||
e_util_env_set("E_IPC_SOCKET", buf);
|
||||
printf("INFO: E_IPC_SOCKET=%s\n", buf);
|
||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _e_ipc_cb_client_add, NULL);
|
||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _e_ipc_cb_client_del, NULL);
|
||||
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _e_ipc_cb_client_data, NULL);
|
||||
|
|
|
@ -554,19 +554,7 @@ main(int argc, char **argv)
|
|||
e_error_gui_set(1);
|
||||
|
||||
/* setup e ipc service */
|
||||
if (!_e_main_ipc_init())
|
||||
{
|
||||
e_error_message_show(_("Enlightenment cannot set up the IPC socket.\n"
|
||||
"It likely is already in use by an existing copy of Enlightenment.\n"
|
||||
"Double check to see if Enlightenment is not already on this display,\n"
|
||||
"but if that fails try deleting all files in ~/.ecore/enlightenment-*\n"
|
||||
"and try running again.\n"
|
||||
"\n"
|
||||
"If you use AFS then maybe you might want to make a symlink from\n"
|
||||
"~/.ecore to /tmp/my_directory/ecore where sockets can be made."));
|
||||
ipc_failed = 1;
|
||||
}
|
||||
else
|
||||
if (_e_main_ipc_init())
|
||||
_e_main_shutdown_push(_e_main_ipc_shutdown);
|
||||
|
||||
/* setup generic msg handling etc */
|
||||
|
@ -641,14 +629,6 @@ main(int argc, char **argv)
|
|||
}
|
||||
/* _e_main_shutdown_push(e_desklock_shutdown); */
|
||||
|
||||
if (ipc_failed)
|
||||
e_error_dialog_show(_("Enlightenment IPC setup error!"),
|
||||
_("Enlightenment cannot set up the IPC socket.\n"
|
||||
"It likely is already in use by an existing copy of Enlightenment.\n"
|
||||
"Double check to see if Enlightenment is not already on this display,\n"
|
||||
"but if that fails try deleting all files in ~/.ecore/enlightenment-*\n"
|
||||
"and try running again."));
|
||||
|
||||
/* add in a handler that just before we go idle we flush x */
|
||||
_e_main_idle_enterer_flusher = ecore_idle_enterer_add(_e_main_cb_x_flusher, NULL);
|
||||
|
||||
|
@ -1132,11 +1112,7 @@ _e_main_path_shutdown(void)
|
|||
static int
|
||||
_e_main_ipc_init(void)
|
||||
{
|
||||
if (!e_ipc_init())
|
||||
{
|
||||
e_error_message_show("Cannot init IPC subsystem!\n");
|
||||
return 0;
|
||||
}
|
||||
if (!e_ipc_init()) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,44 +43,15 @@ main(int argc, char **argv)
|
|||
{
|
||||
#ifdef USE_IPC
|
||||
int i;
|
||||
char *s, buf[1024];
|
||||
|
||||
/* fix up DISPLAY to be :N.0 if no .screen is in it */
|
||||
s = getenv("DISPLAY");
|
||||
if (s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strrchr(s, ':');
|
||||
if (!p)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s);
|
||||
putenv(strdup(buf));
|
||||
}
|
||||
else
|
||||
{
|
||||
p = strrchr(p, '.');
|
||||
if (!p)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s);
|
||||
putenv(strdup(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle some command-line parameters */
|
||||
display_name = (const char *)getenv("DISPLAY");
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if ((!strcmp(argv[i], "-display")) && (i < (argc - 1)))
|
||||
{
|
||||
i++;
|
||||
display_name = argv[i];
|
||||
}
|
||||
else if ((!strcmp(argv[i], "-h")) ||
|
||||
(!strcmp(argv[i], "-help")) ||
|
||||
(!strcmp(argv[i], "--h")) ||
|
||||
(!strcmp(argv[i], "--help")))
|
||||
if ((!strcmp(argv[i], "-h")) ||
|
||||
(!strcmp(argv[i], "-help")) ||
|
||||
(!strcmp(argv[i], "--h")) ||
|
||||
(!strcmp(argv[i], "--help")))
|
||||
{
|
||||
_e_help();
|
||||
exit(0);
|
||||
|
@ -145,15 +116,18 @@ _e_cb_signal_exit(void *data, int ev_type, void *ev)
|
|||
static int
|
||||
_e_ipc_init(void)
|
||||
{
|
||||
char buf[1024];
|
||||
char *disp;
|
||||
char *sdir;
|
||||
|
||||
disp = (char *)display_name;
|
||||
if (!disp) disp = ":0";
|
||||
snprintf(buf, sizeof(buf), "enlightenment-(%s)", disp);
|
||||
_e_ipc_server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, buf, 0, NULL);
|
||||
/* FIXME: we shoudl also try the generic ":0" if the display is ":0.0" */
|
||||
/* similar... */
|
||||
sdir = getenv("E_IPC_SOCKET");
|
||||
if (!sdir)
|
||||
{
|
||||
printf("The E_IPC_SOCKET environment variable is not set. This is\n"
|
||||
"exported by Enlightenment to all processes it launches.\n"
|
||||
"This environment variable must be set and must point to\n"
|
||||
"Enlightenment's IPC socket file (minus port number).\n");
|
||||
return 0;
|
||||
}
|
||||
_e_ipc_server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, sdir, 0, NULL);
|
||||
if (!_e_ipc_server) return 0;
|
||||
|
||||
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, _e_ipc_cb_server_add, NULL);
|
||||
|
@ -260,7 +234,6 @@ _e_help(void)
|
|||
printf(" -help This help\n");
|
||||
printf(" --help This help\n");
|
||||
printf(" --h This help\n");
|
||||
printf(" -display OPT1 Connect to E running on display 'OPT1'\n");
|
||||
for (j = 0; j < (int)(sizeof(opts) / sizeof(Opt)); j++)
|
||||
{
|
||||
Opt *opt;
|
||||
|
|
Loading…
Reference in New Issue