linux-um archives
 help / color / mirror / Atom feed
From: Mattia Dongili <malattia@linux.it>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: UML-devel <user-mode-linux-devel@lists.sourceforge.net>
Subject: Re: [uml-devel] [RFC][PATCH] include /usr/lib/uml in PATH
Date: Sun, 2 Apr 2006 21:54:09 +0200	[thread overview]
Message-ID: <20060402195409.GA3695@inferi.kami.home> (raw)
In-Reply-To: <Pine.LNX.4.62.0604022027190.15153@pademelon.sonytel.be>

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

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 <malattia@linux.it>
-- 
mattia
:wq!

[-- Attachment #2: uml_net.diff --]
[-- Type: text/plain, Size: 1090 bytes --]

--- 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	other threads:[~2006-04-02 19:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-02 17:34 [uml-devel] [RFC][PATCH] include /usr/lib/uml in PATH Mattia Dongili
2006-04-02 18:29 ` Geert Uytterhoeven
2006-04-02 19:54   ` Mattia Dongili [this message]
2006-04-04  0:39     ` Blaisorblade
2006-04-05 21:11       ` Mattia Dongili
2006-04-07  6:45         ` Blaisorblade
2006-04-07 16:52           ` Mattia Dongili
2006-04-09 12:52             ` Stefano Melchior
2006-04-19  9:52               ` Blaisorblade
2006-04-19 19:07                 ` Mattia Dongili
2006-04-21 18:34                   ` Blaisorblade
2006-04-21 21:18             ` Blaisorblade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060402195409.GA3695@inferi.kami.home \
    --to=malattia@linux.it \
    --cc=geert@linux-m68k.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox