[X2Go-Dev] Bug#1133: Bug#1133: Bug#1133: Inconsistent Perl used by server or its agent on connect

Stefan Baur X2Go-ML-1 at baur-itcs.de
Wed Jan 11 10:05:46 CET 2017


Control: close -1
thanks

[re-sent as the original message went to Ted's personal mailbox only]

Am 11.01.2017 um 02:48 schrieb Ted Toal:
> > perl has the -l option for specifying the PERL5LIB path.  That
option can, and I think should, be used on the shebang of the x2go perl
scripts:
> >
> > #!/usr/bin/perl -l /usr/lib/perl5
> >
> > or something like that.  I know the shebang line allows args.

Ted,

while we agree that options *can* be used on the shebang line, I
disagree that they should be used in our scripts for specifying
something that *is the default*.
You would, indeed, change the shebang to "#!/usr/bin/perl -T" if you
wanted to run the script in taint mode, which is a non-default setting.

Also, the parameter to set the library path is not -l (lower-case L),
but -I (upper-case i).  I would suggest using a font that displays them
differently, it makes coding a lot easier.

Why explicitly setting the PERL5LIB path in the shebang line is a bad
idea can be shown like this:

First, run
perl -e 'print "@INC\n";'
to display the default.

On my system, this returns:
/etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
/usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
/usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
/usr/share/perl/5.20 /usr/local/lib/site_perl .

Next, run
perl -I /foo -e 'print "@INC\n";'
which corresponds to setting -I /foo on the shebang line.

On my system, this returns:
/foo /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
/usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
/usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
/usr/share/perl/5.20 /usr/local/lib/site_perl .

Notice how the search path is extended, not replaced, by /foo ending up
at the beginning.

Now let's see what happens when combining -I *and* a set PERL5LIB variable:
PERL5LIB=/bar perl -I /foo -e 'print "@INC\n";'

This results in:
/foo /bar /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
/usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
/usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
/usr/share/perl/5.20 /usr/local/lib/site_perl .

You can see that /foo and /bar are added to the search path, with the
value of -I taking precedence, as in being listed and thus searched
first, over PERL5LIB.

And this is exactly NOT what a user expects, even though it would solve
your percieved problem:

Standard Unix practice is that when an environment variable is set, it
should take precedence over any default, and a command line option set
should take precedence over any environment variable.

Adding -I /path/to/libs at the shebang line would break what is expected
behavior.

No one keeps you from running a search and replace on all X2Go-related
scripts after installing them, though ...

However, I would strongly recommend against that and suggest un-setting
PERL5LIB in .bashrc when an X2Go-related bash invocation is detected,
instead.

Why this doesn't work for you the way it does for us is what we're
tracking in Bug #1134, so again, closing this bug.

Kind Regards,
Stefan Baur
-- 
BAUR-ITCS UG (haftungsbeschränkt)
Geschäftsführer: Stefan Baur
Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364
Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.x2go.org/pipermail/x2go-dev/attachments/20170111/bb1f49e6/attachment.pgp>


More information about the x2go-dev mailing list