All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Ian Kent <raven@themaw.net>
Cc: autofs@linux.kernel.org
Subject: [PATCH] 5.0.0_beta1: use PATH in execXX()
Date: Wed, 26 Sep 2007 11:00:54 +0100	[thread overview]
Message-ID: <200709261100.54397.vda.linux@googlemail.com> (raw)

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

Hi Ian,

I want automount to use PATH when it tries to run e.g. "mount",
because I want it to work regardless where my mount binary is
(/bin or /usr/bin or...). I do have different system with different
paths to some binaries, and it is pain in the ass - I have
no way to explain to automount binary that it needs to look
in another directory.

I am trying to make automount using 'short' names it by passing
variables to configure:

MOUNT="mount" \
UMOUNT="umount" \
E2FSCK="fsck.ext2" \
E3FSCK="fsck.ext3" \
./configure ............

I think it's reasonably safe since automount is started by root
and root is expected to set PATH sanely.

And it still doesn't work, because you are using execv(), not execvp().

This patch replaces execv() with execvp().

It should change nothing for 'normally' configured automount since
it passes fully qualified names ("/bin/mount") to exec and PATH
is not used in this case.

Please consider applying.
--
vda

[-- Attachment #2: autofs-5.0.0_beta1-PATH.patch --]
[-- Type: text/x-diff, Size: 1642 bytes --]

diff -d -urpN autofs-5.0.0_beta1-stderr/daemon/spawn.c autofs-5.0.0_beta1-PATH/daemon/spawn.c
--- autofs-5.0.0_beta1-stderr/daemon/spawn.c	2006-05-02 08:37:35.000000000 +0100
+++ autofs-5.0.0_beta1-PATH/daemon/spawn.c	2007-09-26 10:35:59.000000000 +0100
@@ -291,8 +291,12 @@ static int do_spawn(logger *log, int use
 		dup2(pipefd[1], STDERR_FILENO);
 		close(pipefd[1]);
 
-		execv(prog, (char *const *) argv);
-		_exit(255);	/* execv() failed */
+		/* Why execv_p_? Normally argv[0] has fully qualified path
+		 * and it doesn't matter, but it can be overridden
+		 * at build time to e.g. simple "mount".
+		 * Clearly, user wants to use PATH in this case. */
+		execvp(prog, (char *const *) argv);
+		_exit(255);	/* exec() failed */
 	} else {
 		close(pipefd[1]);
 
diff -d -urpN autofs-5.0.0_beta1-stderr/modules/lookup_program.c autofs-5.0.0_beta1-PATH/modules/lookup_program.c
--- autofs-5.0.0_beta1-stderr/modules/lookup_program.c	2006-05-02 08:37:35.000000000 +0100
+++ autofs-5.0.0_beta1-PATH/modules/lookup_program.c	2007-09-26 10:36:24.000000000 +0100
@@ -171,8 +171,12 @@ int lookup_mount(struct autofs_point *ap
 		dup2(epipefd[1], STDERR_FILENO);
 		close(pipefd[1]);
 		close(epipefd[1]);
-		execl(ctxt->mapname, ctxt->mapname, name, NULL);
-		_exit(255);	/* execl() failed */
+		/* Why execl_p_? Normally argv[0] has fully qualified path
+		 * and it doesn't matter, but it can be overridden
+		 * at build time to e.g. simple "mount".
+		 * Clearly, user wants to use PATH in this case. */
+		execlp(ctxt->mapname, ctxt->mapname, name, NULL);
+		_exit(255);	/* exec() failed */
 	}
 	close(pipefd[1]);
 	close(epipefd[1]);

[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs

             reply	other threads:[~2007-09-26 10:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 10:00 Denys Vlasenko [this message]
2007-09-26 15:11 ` [PATCH] 5.0.0_beta1: use PATH in execXX() Ian Kent
2007-09-28  9:11 ` Ian Kent
2007-09-28 16:53   ` Jim Carter

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=200709261100.54397.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=autofs@linux.kernel.org \
    --cc=raven@themaw.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.