On Sun, Apr 02, 2006 at 08:29:12PM +0200, Geert Uytterhoeven wrote:
> On Sun, 2 Apr 2006, Mattia Dongili wrote:
[...]
> > --- a/arch/um/os-Linux/helper.c     2006-04-02 16:32:38.340801686 +0200
> > +++ b/arch/um/os-Linux/helper.c     2006-04-02 16:34:13.454745936 +0200
> > @@ -22,6 +22,9 @@ struct helper_data {
> >     int fd;
> >  };
> >  
> > +/* PATH variable to find uml helpers  installed in FHS compliant locations 
> > */
> > +static char *alt_path = "PATH=:/bin:/usr/bin:/usr/lib/uml"; 
>                                  ^
> Woops, this puts the current directory first in your path, which is probably

Urgh! that was just the default path straight from the execle manpage.
The attached patch reimplements the thing appending /usr/lib/uml only
once before starting UML. Still using the above PATH if no PATH variable
exists as execle behaves in the same way.

Signed-off-by: Mattia Dongili <[EMAIL PROTECTED]>
-- 
mattia
:wq!
--- arch/um/os-Linux/main.c~clean       2006-04-02 21:08:26.782461831 +0200
+++ arch/um/os-Linux/main.c     2006-04-02 21:37:45.548377831 +0200
@@ -74,6 +74,31 @@ static void last_ditch_exit(int sig)
        exit(1);
 }
 
+static void setup_env_path(void) {
+       char *new_path = NULL;
+       char *old_path = NULL;
+       int path_len = 0;
+
+       old_path = getenv("PATH");
+       if (!old_path) {
+               /* if no PATH variable is set, just use 
+                * the default + /usr/lib/uml
+                */
+               putenv("PATH=:/bin:/usr/bin/:/usr/lib/uml");
+               return;
+       }
+
+       /* append /usr/lib/uml to the existing path */
+       path_len = strlen(old_path) + 19; 
+       new_path = malloc(path_len * sizeof(char));
+       if (!new_path) {
+               perror("coudn't malloc to set a new PATH");
+               return;
+       }
+       snprintf(new_path, path_len, "PATH=%s:/usr/lib/uml", old_path);
+       putenv(new_path);
+}
+
 extern int uml_exitcode;
 
 extern void scan_elf_aux( char **envp);
@@ -114,6 +139,8 @@ int main(int argc, char **argv, char **e
 
        set_stklim();
 
+       setup_env_path();
+
        new_argv = malloc((argc + 1) * sizeof(char *));
        if(new_argv == NULL){
                perror("Mallocing argv");

Reply via email to