deprecated has asked for the wisdom of the Perl Monks concerning the following question:

I'm not accustomed to not being root on a machine. So when I came to this site as a perl programmer, but wasnt root, I was faced with the interesting situation of developing scripts with my own copy of perl living under ~alex. So while I have figured out how to make perldoc in the shell point to my directory, 'vi' doesnt understand this if i do a [esc]:!perldoc Mail::POP3Client or the like.

So this is a unix question, I guess, but it is directly related to how we use perl. I need to know how to make my perldoc supersede the perldoc on the system for commands I execute.

This is a SunOS 5.6 (yeah yeah) box.

Thanks,
brother dep.

say, arent there two 'p's in stupid?

--
Laziness, Impatience, Hubris, and Generosity.

Replies are listed 'Best First'.
Re: Isolating perldoc from the system perldoc
by Masem (Monsignor) on Apr 27, 2001 at 18:37 UTC
    You need to have the path that contains your perldoc ahead of the standard system paths; eg:
    PATH=~alex/bin/;/usr/local/bin/;/usr/bin/;...
    (Setting the PATH depends on your shell, but make sure your path is firt).

    WARNING DANGER WILL ROBINSON - putting user dirs for your path before the system paths can lead to some bad attacks if your box gets comprimised; if ~alex/bin/cp is put in your dir, and you use "cp stuff" without noticing, you could be doing very bad things. Which is why it's highly recommended that you never have "." in your path, and avoiding using anything beyond standard paths if you are root.


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: Isolating perldoc from the system perldoc
by virtualsue (Vicar) on Apr 27, 2001 at 18:46 UTC
    I don't see why you're having a problem, unless you're setting up your environment outside of the normal automagic mechanisms (.profile, .login, .kshrc, .cshrc, whatever).

    How are you setting things up?

      Well, just because you asked, I'll go into the ugly details (this is mostly academic help for other people who will get into this situation too).

      I'm normally a Linux/BSD type of guy. I have run solaris and played in it before, but never a solaris pre 7. So when I came to this site to start working on some new tools for them, and I was given a SunOS 5.6 account, I was without all sorts of tools.

      So after getting bash built okay, I started setting things up in my .bashrc. For example, 'make' and 'cc' live in very different places on old SunOS boxes than they do on BSD or GNU (/usr/ccs/bin and /usr/ucb in this case, respectively). Also, the default path given to me was /bin and /usr/bin, which was absolutely pathetic. So I figured out that I wanted my path to include all the Solaris binaries (i'll be damned if i have to go and build 'ls'), so I have a path laid out like this in my .bashrc:

      PATH='' PATH=$PATH:/bin PATH=$PATH:/sbin PATH=$PATH:/usr/bin PATH=$PATH:/usr/sbin PATH=$PATH:/usr/local/bin PATH=$PATH:/usr/local/sbin PATH=$PATH:/usr/ccs/bin PATH=$PATH:/usr/ucb PATH=$PATH:$HOME/bin PATH=$PATH:$HOME/perl/bin
      However, when vi goes to execute perldoc, as Masem just pointed out, it is looking through the path and finding first perldoc in /usr/local/bin , which then points to /usr/local/lib/perl { ... }, and I (not being of rootly powers) cannot put new modules there. So I (innocently and successfully but probably not correctly) just put an alias in my .bashrc which made 'perl' and 'perldoc' point to the appropriate binaries under my home directory.

      I'm not convinced putting my homedir/bin paths above the SunOS paths is a better, safer idea than using an alias (because of the very issues Masem suggested), but it is the only way, apparently, to make vi understand that I dont want the system perldoc, I want _my_ perldoc.

      Thanks Masem, virtualsue.
      brother dep.

      --
      Laziness, Impatience, Hubris, and Generosity.

        One more possibility, and this depends on the shell, is to alias "perldoc" to expand to point to your localcopy, similar to how many shells alias "ls" to "ls --color". But again, if your system is comprimised (at the user account level), and overwrites your perldoc with something by the same name but more malicious, you're in just as much trouble.

        A further one would be to install in /usr/local/bin a shell script called perldoc, along with your perldoc (call it perldoc-andy). The shell checks the user of the script, and if it's root or andy, it uses perldoc-andy, and if not, perldoc. All parts of this can be chown'd root (avoiding the problems with user-level intrusion) with permissions like 755. You cna then put /usr/local/bin in front of /usr/bin in the path to do that. A bit more work, but a bit more secure as well (requiring being rooted to break, but if you're there already, you're already screwed).


        Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
        All I was looking for was info on how you were invoking your own version of perl from the command line outside vi. :-)

        I see no reason why you can't move your $HOME/perl/bin above the other directories in your PATH. It isn't *that* big of a security risk for users other than root.

Re: Isolating perldoc from the system perldoc
by Desdinova (Friar) on Apr 27, 2001 at 20:22 UTC
    what about naming your copy of perldoc something slightly different like perldoc2. Note this is any better than other solutions but it hasnt been mentioned. As for the risks people are talking about. If you are running anything in your own file space and it gets compromised it can do evil things. The only thing you can really do is run something like tripwire