[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] New patch for entranced and entrance



Here's a new patch for entranced and entrance.

This time I did what the comment suggested in both places. I used strtok and parsed directly into a char ** which then gets run by execv/execvp.

If my code strikes you as ugly (I'm not sure if it should) be sure to tell me what I did wrong and I'll try to fix it some more.

BTW, this diff is made from e17/apps/entrance. I'm sorry, is this what you meant or should I have made it dirrectly from e17/ ?

Eugen.
Index: src/client/entrance_session.c
===================================================================
RCS file: /var/cvs/e/e17/apps/entrance/src/client/entrance_session.c,v
retrieving revision 1.84
diff -u -r1.84 entrance_session.c
--- src/client/entrance_session.c	3 Jun 2006 07:24:49 -0000	1.84
+++ src/client/entrance_session.c	27 Aug 2006 22:25:00 -0000
@@ -377,10 +377,16 @@
 {
    pid_t pid;
    char buf[PATH_MAX];
+   char *session_cmd_argv[32];
+
    char *shell = NULL;
    struct passwd *pwent = NULL;
    Entrance_X_Session *exs = NULL;
 
+   int i;
+
+   for (i=0;i<32;i++) session_cmd_argv[i]=NULL;
+
    if (e->session)
       exs = evas_hash_find(e->config->sessions.hash, e->session);
 
@@ -497,7 +503,13 @@
    entrance_session_free(e);
    /* replace this process with a clean small one that just waits for its */
    /* child to exit.. passed on the cmd-line */
-   execl("/bin/sh", "/bin/sh", "-l", "-c", buf, NULL);
+
+   session_cmd_argv[0]=strtok(buf," ");
+   i=1;
+   while ((session_cmd_argv[i]=strtok(NULL," "))!=NULL) {
+      i++;
+   }
+   execvp(session_cmd_argv[0], session_cmd_argv);
 }
 
 
Index: src/daemon/entranced_display.c
===================================================================
RCS file: /var/cvs/e/e17/apps/entrance/src/daemon/entranced_display.c,v
retrieving revision 1.2
diff -u -r1.2 entranced_display.c
--- src/daemon/entranced_display.c	1 Aug 2006 05:30:58 -0000	1.2
+++ src/daemon/entranced_display.c	27 Aug 2006 22:25:00 -0000
@@ -124,6 +124,11 @@
    double start_time;
    char x_cmd[PATH_MAX];
 
+   int i;
+   char *x_cmd_argv[32]; 
+
+   for (i=0;i<32;i++) x_cmd_argv[i]=NULL;
+
    /* Ecore_Exe *x_exe; */
    pid_t xpid;
 
@@ -160,9 +165,15 @@
         _entrance_x_sa.sa_flags = 0;
         sigemptyset(&_entrance_x_sa.sa_mask);
         sigaction(SIGUSR1, &_entrance_x_sa, NULL);
-      /* FIXME: need to parse command and NOT go thru /bin/sh!!!! */
-      /* why? some /bin/sh's wont pass on this SIGUSR1 thing... */
-        execl("/bin/sh", "/bin/sh", "-c", x_cmd, NULL);
+
+	x_cmd_argv[0]=strtok(x_cmd," ");
+	i=1;
+
+	while ((x_cmd_argv[i]=strtok(NULL," "))!=NULL) {
+	   i++;
+	}
+
+        execvp(x_cmd_argv[0], x_cmd_argv);
         syslog(LOG_WARNING, "Could not execute X server.");
         exit(1);
      default: