From: "Kevin O'Gorman" <kogorman@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and grow
Date: Fri, 7 Jul 2006 11:31:38 -0700 [thread overview]
Message-ID: <9acccfe50607071131t70e6d718uf5e198827afbeb45@mail.gmail.com> (raw)
In-Reply-To: <200607051433.51500.bss03@volumehost.net>
On 7/5/06, Boyd Stephen Smith Jr. <bss03@volumehost.net> wrote:
> On Saturday 03 June 2006 16:11, znx <znxster@gmail.com> wrote about 'Re:
> [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and
> grow':
> > On 27/05/06, Kevin O'Gorman <kogorman@gmail.com> wrote:
> > > Open to debate. I'd think it's not very dangerous at the *end* of
> > > the PATH.
> >
> > True, I have modified the script so that a . may enter the PATH (etc)
> > only as the final entry. Also good point about ~/bin .. it is just as
> > dangerous.
>
> Actually, it's not as dangerous. ~/bin is a well-known location that is
> (normally) only writable by the user themselves. '.' is a floating
> location, that may (from time to time) refer to a directory that is
> world-writable like /tmp, /var/tmp, or /dev/shm.
>
> Having '.' in your path allows arbitrary guest users to run programs with
> your permissions. Putting it at the end of your PATH prevents them from
> shadowing existing commands, but doesn't prevent them from taking
> advantage of typos.
>
> Having ~/bin or even just ~ in your PATH does not open this security hole
> unless you also make that directory world writable.
Good point.
I've also fooled around with the script a bit, and arrived at something that's
easier for me to read, and a bit more permissive. YMMV
compresspath ()
{
local var="${1:-PATH}" # arg 1; default to $PATH
local newpath=:
local entry
for entry in ${!var//:/ }; # change ":" to space (so separates words)
do
case $newpath in
*:${entry}:*) # already there -- do nothing
;;
*)
newpath=$newpath$entry:
;;
esac
done
newpath="${newpath#:}"; # drop leading ":"
newpath="${newpath%:}"; # drop trailing ":"
eval "$var"'="${newpath}"'
}
++ kevin
--
Kevin O'Gorman, PhD
--
gentoo-user@gentoo.org mailing list
prev parent reply other threads:[~2006-07-07 18:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-21 22:56 [gentoo-user] bash wizardry needed: PATH and MANPATH grow and grow and grow Kevin O'Gorman
2006-05-23 20:06 ` znx
2006-05-24 14:58 ` Kevin O'Gorman
2006-05-26 1:27 ` znx
2006-05-27 2:52 ` Kevin O'Gorman
2006-06-03 21:11 ` znx
2006-07-05 19:33 ` Boyd Stephen Smith Jr.
2006-07-07 18:31 ` Kevin O'Gorman [this message]
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=9acccfe50607071131t70e6d718uf5e198827afbeb45@mail.gmail.com \
--to=kogorman@gmail.com \
--cc=gentoo-user@lists.gentoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox