pcp
[Top] [All Lists]

PATH setting for PCP daemons and PMDAs

To: pcp@xxxxxxxxxxx
Subject: PATH setting for PCP daemons and PMDAs
From: Nathan Scott <nscott@xxxxxxxxxx>
Date: Fri, 11 Apr 2008 17:03:12 +1000
Cc: jamespeach@xxxxxxx
Organization: Aconex
Reply-to: nscott@xxxxxxxxxx
Sender: pcp-bounce@xxxxxxxxxxx
Hi all,

The snippit of code below from pcp.env fills me with fear
and loathing.  I know James is not a big fan either. :)

The explicit setting of LD_LIBRARY_PATH on Solaris gives
me some security concerns (this is used by the PCP start
and cron scripts, so is often executed as root) - it's
better to do that stuff through the /etc/ld.so.conf.d/
equivalent in Solaris, not here.  The Solaris-specific
part then specifies /usr/local/bin, which is respecified
later - a bit odd.

Also, theres no way to extend the PATH seen by PMDAs.  I
hit a situation yesterday where it would've been really
useful to have a configuration hook there.

Finally, every time we run PCP scripts, we potentially
have to go off and stat an ever-increasing number of
directories, many being there for other platforms, which
just isn't a clean design.

So, I'm thinking:
- the Solaris piece should be completely removed
- the platform-specific part could be replaced by a
pcp.conf variable $PCP_PLATFORM_PATHS, which sysadmins
can add to if they have "special" PATH needs for custom
PMDAs, like me!


This is the current code, read it and weep:

# This needs to be the union of directories in which PCP tools may
expect
# to find executable commands ...
#
PATH=""
if [ "$PCP_PLATFORM" = solaris ]
then
    # GNU tools and libs hide in /usr/local ... make sure we find these
    # early enough in the searching
    #
    PATH=/usr/local/bin:
    LD_LIBRARY_PATH=/usr/local/lib
    export LD_LIBRARY_PATH
fi
PATH=$PATH/usr/sbin:/sbin:/bin:/usr/bin:/etc:${PCP_BIN_DIR}:
${PCP_BINADM_DIR}:${PCP_SHARE_DIR}/bin:${PCP_SHARE_DIR}/lib \
# the more obscure ones are conditional
#
for dir in /usr/bsd /usr/etc /usr/bin/X11 /usr/local/bin \
        /opt/sfw/bin /usr/ccs/bin /cygdrive/c/WINDOWS/system32 \
        /usr/contrib/bin /opt/local/bin
do
    [ -d $dir ] || continue
    echo "$PATH" | egrep ":$dir(:|\$)" >/dev/null && continue
    PATH=$PATH:$dir
done
export PATH


New version:
PATH=/usr/sbin:/sbin:/bin:/usr/bin:/etc:${PCP_BIN_DIR}:
${PCP_BINADM_DIR}:${PCP_SHARE_DIR}/bin:${PCP_SHARE_DIR}/lib:
${PCP_PLATFORM_PATHS}

And PCP_PLATFORM_PATHS can be set to an explicit value inside
the configure script (so theres a bit of extra code in there
to be fair, but no runtime code).

Finally, can someone with access to the original rlog verify
and fill in the blanks in this platform<->path mapping:

/usr/bsd - FreeBSD
/usr/etc - IRIX
/usr/bin/X11 - UNIX platforms
/usr/local/bin - UNIX platforms
/opt/sfw/bin - ?
/usr/ccs/bin - ?
/cygdrive/c/WINDOWS/system32 - Windows/Cygwin
/usr/contrib/bin - ?
/opt/local/bin - Mac OS X

cheers.

-- 
Nathan


<Prev in Thread] Current Thread [Next in Thread>