Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_ipc.c e_main.c e_remote_main.c 


Log Message:

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).

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_ipc.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -3 -r1.53 -r1.54
--- e_ipc.c     11 Mar 2006 16:18:27 -0000      1.53
+++ e_ipc.c     4 Jul 2006 18:36:29 -0000       1.54
@@ -16,13 +16,64 @@
 {
 #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);
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -3 -r1.168 -r1.169
--- e_main.c    22 Jun 2006 19:21:13 -0000      1.168
+++ e_main.c    4 Jul 2006 18:36:29 -0000       1.169
@@ -554,19 +554,7 @@
    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 @@
      }
 /* _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 @@
 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;
 }
 
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_remote_main.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -3 -r1.54 -r1.55
--- e_remote_main.c     13 May 2006 03:04:35 -0000      1.54
+++ e_remote_main.c     4 Jul 2006 18:36:29 -0000       1.55
@@ -43,44 +43,15 @@
 {
 #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 @@
 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 @@
    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;



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to