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

Re: [E-devel] New patch for entranced and entrance



Eugen Minciu wrote:
On Mon, 28 Aug 2006 08:01:54 +0300
Eugen Minciu <minciue@gmail.com> wrote:

And here is another version that frees the memory it allocates in the correct place.

Sorry about so many posts on what should have been a simple thingie. It's the first patch I'm sending you guys, I promise I'll try to shut up a bit more from now on ;)
I've tested this here and it doesn't start Enlightement at all. The DISPLAY environment variable is not set, but I'm not sure that simply setting it like you set the PATH variable is a good work-around. It will probably hide something else untill it blows up in our collective faces :)

I'm going to commit the bash before sh work around, which at least works.

Do you think you could find out how gdm and kdm even xdm solves this problem? Display Managers have evolved so I'm guessing this is an already solved problem. If you think you need anyhelp... shout... at me even :). Other safe targets for *help-me* are (in no order of preference really), raster, raster, raster, rephorm, rephorm, rephorm, Codewarrior, Codewarrior, Codewarrior [there... without adding me, you now have 9 ppl!!! you can get help from) :P

/me boards the next space-shuttle headed for pluto - catch me if you can ;)

Cheers,
Essien
On Mon, 28 Aug 2006 05:04:10 +0100
Essien Ita Essien <essien@wazobialinux.com> wrote:

Ouch, sorry, lol :)
Here it is

Eugen Minciu wrote:
On Sun, 27 Aug 2006 23:22:38 +0300
Eugen Minciu <minciue@gmail.com> wrote:
And finally, I've got it.

The problem was in entrance_auth_setup_environment() which called clearenv().

For some reasong calling getenv() there did not return the path either. So I added an extra parameter, const char *path.

This finally works, I can run apps and everything appears to be working correctly.
Nice, but no patch attached ;)
Eugen.
On Sun, 27 Aug 2006 22:36:31 +0300
Eugen Minciu <minciue@gmail.com> wrote:
I've figured out what causes the problem, but I don't know how to fix it this time.

This happens because once I replace the execl() call in entrance_session_start_user_session, the environment variables for the user are no longer loaded. If anyone could tell me how to load these settings from C code, I'd very much appreciate it.

As things stand, at this point, entrance does work with this, and the E17 session starts, but many issues can quickly be noticed, probably caused by not setting the environment variables to some proper values.

On Sun, 27 Aug 2006 22:30:58 +0300
Eugen Minciu <minciue@gmail.com> wrote:

Sorry, it seems that if I use this I get some issues within e. If I try to start an application from the run command thingie, it will tell me that the application failed to start.

I'll try to see what causes this. If anyone would be willing to investigate and/or give me any clues it would be appreciated.

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.

-------------------------------------------------------------------------
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-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

------------------------------------------------------------------------

Index: src/client/entrance_auth.c
===================================================================
RCS file: /var/cvs/e/e17/apps/entrance/src/client/entrance_auth.c,v
retrieving revision 1.26
diff -u -r1.26 entrance_auth.c
--- src/client/entrance_auth.c	9 Aug 2005 08:11:32 -0000	1.26
+++ src/client/entrance_auth.c	28 Aug 2006 08:15:59 -0000
@@ -377,7 +377,7 @@
  * I'm not sure if this is correct, but for now it works.
  */
 void
-entrance_auth_setup_environment(Entrance_Auth * e, const char *display)
+entrance_auth_setup_environment(Entrance_Auth * e, const char *display, const char *path)
 {
    extern char **environ;
    int size;
@@ -394,10 +394,15 @@
    environ = NULL;
 #endif
+ /* We purge the config but keep $PATH in place */
+   /* We need this because we're not running "sh -l" anymore */
+
+
    e->env = environ;
    snprintf(buf, PATH_MAX, "%s/.Xauthority", e->pw->pw_dir);
    setenv("XAUTHORITY", buf, 1);
    setenv("TERM", "vt100", 0);  // TERM=linux?
+   setenv("PATH", path, 1);
    setenv("HOME", e->pw->pw_dir, 1);
    setenv("SHELL", e->pw->pw_shell, 1);
    setenv("USER", e->pw->pw_name, 1);
Index: src/client/entrance_auth.h
===================================================================
RCS file: /var/cvs/e/e17/apps/entrance/src/client/entrance_auth.h,v
retrieving revision 1.13
diff -u -r1.13 entrance_auth.h
--- src/client/entrance_auth.h	28 May 2005 09:31:14 -0000	1.13
+++ src/client/entrance_auth.h	28 Aug 2006 08:15:59 -0000
@@ -77,7 +77,7 @@
/* 0 on success, 1 on no user by that name */
 int entrance_auth_user_set(Entrance_Auth * e, const char *str);
-void entrance_auth_setup_environment(Entrance_Auth * e, const char *display);
+void entrance_auth_setup_environment(Entrance_Auth * e, const char *display,const char *path);
 void entrance_auth_reset(Entrance_Auth * e);
#endif
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	28 Aug 2006 08:16:00 -0000
@@ -355,9 +355,12 @@
 entrance_session_setup_user_session(Entrance_Session * e)
 {
    char *homedir;
+   char *path;
- entrance_auth_setup_environment(e->auth, e->display);
    homedir = getenv("HOME");
+   path = strdup(getenv("PATH"));
+   entrance_auth_setup_environment(e->auth, e->display, strdup(getenv("PATH")));
+   free(path);
    if (entrance_ipc_connected_get())
       entrance_ipc_request_xauth(homedir, e->auth->pw->pw_uid,
                                  e->auth->pw->pw_gid);
@@ -377,14 +380,24 @@
 {
    pid_t pid;
    char buf[PATH_MAX];
+   char *session_cmd_argv[32];
+
    char *shell = NULL;
+   char *path = NULL;
    struct passwd *pwent = NULL;
    Entrance_X_Session *exs = NULL;
+   int i;
+
+   path=strdup(getenv("PATH"));
+
+   for (i=0;i<32;i++) session_cmd_argv[i]=NULL;
if (e->session)
       exs = evas_hash_find(e->config->sessions.hash, e->session);
- entrance_auth_setup_environment(e->auth, e->display);
+   entrance_auth_setup_environment(e->auth, e->display, path);
+   free(path);
+
    if ((exs->session) && (exs->session[0] != 0))
    {
       if (!strcmp(exs->session, "default"))
@@ -497,7 +510,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	28 Aug 2006 08:16:02 -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:
------------------------------------------------------------------------

-------------------------------------------------------------------------
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-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel