All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Ruediger Meier <sweet_f_a@gmx.de>
Cc: util-linux@vger.kernel.org, Isaac Dunham <ibid.ag@gmail.com>
Subject: Re: question about hardcoded binary paths (swapon / mkswap)
Date: Wed, 1 Apr 2015 16:10:51 -0400	[thread overview]
Message-ID: <20150401201051.GP25224@vapier> (raw)
In-Reply-To: <201504011817.48428.sweet_f_a@gmx.de>

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

On 01 Apr 2015 18:17, Ruediger Meier wrote:
> On Wednesday 01 April 2015, Isaac Dunham wrote:
> > On Wed, Apr 01, 2015 at 01:42:56PM +0200, Ruediger Meier wrote:
> > > I wonder about some hardcoded binary paths.
> > >
> > > Example swapon.c:
> > >
> > > #define PATH_MKSWAP    "/sbin/mkswap"
> > >
> > > There are a two problems.
> > > 1. It's wrong. We should use $sbindir from configure.
> > > 2. When called from our test-suite it will use a wrong (or
> > >    non-existend, broken) binary. This happens in test
> > > swapon/fixpgsz.
> > >
> > > The question is how to fix this.
> > >
> > > I would prefer to use "mkwsap" from the same directory like swapon
> > > or to simply execvp "mkswap" from PATH. But don't know if we want
> > > this. If we really want to keep a hardcoded sbindir then we would
> > > need "#ifdef TEST_PROGRAM".
> > >
> > > Any comments?
> >
> > The approach that seems obvious to me (assuming you want to keep the
> > hardcoded path) is:
> > -add -DSBINDIR="$sbindir" to CFLAGS
> 
> Yes, this would be easy. But my preferred logic would be like this
> 
> If "swapon" was called from PATH then just take mkswap from PATH too.
> If "/whatever/path/swapon" was called then look for mkswap in the same 
> path.
> 
> Maybe both cases also with or without fallback $sbindir, /sbin or $PATH.
> 
> I guess we should agree how somthing like this should be handeled in 
> general. "eject" is also using hardcoded "/bin/umount". 

seems like $PATH should always be used.  if you broke $PATH, well that's your 
fualt ... tools shouldn't generally be expected to work in the fact of hostile 
environments like this.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-04-01 20:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 11:42 question about hardcoded binary paths (swapon / mkswap) Ruediger Meier
2015-04-01 13:38 ` Isaac Dunham
2015-04-01 16:17   ` Ruediger Meier
2015-04-01 20:10     ` Mike Frysinger [this message]
2015-04-01 21:06       ` Ruediger Meier
2015-04-01 21:38         ` Karel Zak
2015-04-02  1:12           ` Mike Frysinger
2015-04-02  8:20             ` Karel Zak
2015-04-02 16:19               ` Mike Frysinger
2015-04-02 19:15                 ` Karel Zak
2015-04-02 22:50                   ` Ruediger Meier
2015-04-03  1:15                   ` Mike Frysinger
2015-04-03  8:52                     ` Karel Zak
2015-04-03 23:16                       ` Mike Frysinger
2015-04-02 17:28               ` Isaac Dunham
2015-04-01 22:23         ` Mike Frysinger

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=20150401201051.GP25224@vapier \
    --to=vapier@gentoo.org \
    --cc=ibid.ag@gmail.com \
    --cc=sweet_f_a@gmx.de \
    --cc=util-linux@vger.kernel.org \
    /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.