Package: NXAGENT Version: 3.5.0
My .bash_profile defines Perl environment variables for Active Perl, and adds the Active Perl bin directory to the start of the path. This causes an x2go session to fail with the message: Connection failed. /usr/bin/perl: symbol lookup error: /share/carvajal-archive/PACKAGES/local/ActivePerl-5.24/lib/auto/Sys/Hostname/Hostname.so: undefined symbol: Perl_xs_handshake NXAGENT is user /usr/bin/perl and ignoring the Perl bin directory at the start of the path, but it is nevertheless using the Perl environment variables and so is looking in the wrong place for the Perl library.
Control: close -1 Control: tag -1 not-a-bug
Am 10.01.2017 um 22:15 schrieb Ted Toal:
Package: NXAGENT Version: 3.5.0
My .bash_profile defines Perl environment variables for Active Perl, and adds the Active Perl bin directory to the start of the path. This causes an x2go session to fail with the message: Connection failed. /usr/bin/perl: symbol lookup error: /share/carvajal-archive/PACKAGES/local/ActivePerl-5.24/lib/auto/Sys/Hostname/Hostname.so: undefined symbol: Perl_xs_handshake NXAGENT is user /usr/bin/perl and ignoring the Perl bin directory at the start of the path, but it is nevertheless using the Perl environment variables and so is looking in the wrong place for the Perl library.
I'd say this isn't a bug, but actually expected behavior. If you need different values for variables depending on which software you run, you either need to prefix them manually each time you call that software, or write a wrapper script, or use if/then clauses in your .bash_profile. The latter is what you seem to have decided to do, and ran into problems with, judging from your bug report #1134, thus closing this one.
-Stefan
-- 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
I disagree. Perl behavior is to look at env. var. PERL5LIB to find its library. This should be set to match the Perl that is being invoked, which is normally done by placing that Perl’s bin directory on the path. Since I did place it on the path, there are only two possibilities for why x2go ran /usr/bin/perl: either it hard-coded the path to Perl, in which case it should first set PERL5LIB (or maybe there is a Perl command line arg to specify the library folder), OR x2go ignored my changes to PATH when it ran perl (in which case it should also ignore PERL5LIB).
On Jan 10, 2017, at 2:35 PM, Stefan Baur <X2Go-ML-1@baur-itcs.de> wrote:
Control: close -1 Control: tag -1 not-a-bug
Am 10.01.2017 um 22:15 schrieb Ted Toal:
Package: NXAGENT Version: 3.5.0
My .bash_profile defines Perl environment variables for Active Perl, and adds the Active Perl bin directory to the start of the path. This causes an x2go session to fail with the message: Connection failed. /usr/bin/perl: symbol lookup error: /share/carvajal-archive/PACKAGES/local/ActivePerl-5.24/lib/auto/Sys/Hostname/Hostname.so: undefined symbol: Perl_xs_handshake NXAGENT is user /usr/bin/perl and ignoring the Perl bin directory at the start of the path, but it is nevertheless using the Perl environment variables and so is looking in the wrong place for the Perl library.
I'd say this isn't a bug, but actually expected behavior. If you need different values for variables depending on which software you run, you either need to prefix them manually each time you call that software, or write a wrapper script, or use if/then clauses in your .bash_profile. The latter is what you seem to have decided to do, and ran into problems with, judging from your bug report #1134, thus closing this one.
-Stefan
-- 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
Ted,
let's examine a few things here:
You're saying that nxagent is doing things in Perl, and not the right things. When examining the contents of the nxagent package, all I'm seeing wrt/ executables are bash scripts and compiled binaries, but nothing written in Perl. So the nxagent package can't be at fault.
We *do* have scripts that are written in Perl, and that might throw the error you quoted. Those are e.g. in the package with the name x2goserver (and I wouldn't be surprised to find more of them in other packages that have names beginning with x2go*).
grep '^#!.*perl*' /usr/bin/x2go* returns a list of scripts that all have #!/usr/bin/perl as shebang, so yes, it's probably safe to say that the use of /usr/bin/perl as the Perl interpreter for our scripts is hardcoded.
But again, that's not a bug, but how scripting works on Linux/Unix. First line with shebang tells the shell which interpreter to use, so you don't have to prefix the script name with the name of the interpreter each time.
And of course, if you set a variable with a name matching one that "a" Perl interpreter (be it ActivePerl or the system standard shipped with your distribution) looks for, it will use it.
Your statement that the version of Perl being used depends on which one comes first in the path might be true on Windows; on Unix, it will only be true for when you type "perl" without a path in an interactive shell, or for when call it from within, say, a bash script without preceding it with a path. Once you chmod +x a Perl script and call it by its name, without prefacing the name and full path to the interpreter, the shebang line will be used to determine the interpreter.
So, if you need to set PERL5LIB for your ActivePerl installation, it should be unset (by adding a suitable if/then clause) when your .bashrc / .bash_profile are read and parsed by an X2Go task. It's kind of weird that, according to your other bug report, you have exactly 0 indication that you're running from within an X2Go session. I can see how that makes it difficult to script around it ;-) - but let's track that in the other bug report.
Kind Regards, Stefan Baur
Am 10.01.2017 um 23:48 schrieb Ted Toal:
I disagree. Perl behavior is to look at env. var. PERL5LIB to find its library. This should be set to match the Perl that is being invoked, which is normally done by placing that Perl’s bin directory on the path. Since I did place it on the path, there are only two possibilities for why x2go ran /usr/bin/perl: either it hard-coded the path to Perl, in which case it should first set PERL5LIB (or maybe there is a Perl command line arg to specify the library folder), OR x2go ignored my changes to PATH when it ran perl (in which case it should also ignore PERL5LIB).
- Ted
On Jan 10, 2017, at 2:35 PM, Stefan Baur <X2Go-ML-1@baur-itcs.de> wrote:
Control: close -1 Control: tag -1 not-a-bug
Am 10.01.2017 um 22:15 schrieb Ted Toal:
Package: NXAGENT Version: 3.5.0
My .bash_profile defines Perl environment variables for Active Perl, and adds the Active Perl bin directory to the start of the path. This causes an x2go session to fail with the message: Connection failed. /usr/bin/perl: symbol lookup error: /share/carvajal-archive/PACKAGES/local/ActivePerl-5.24/lib/auto/Sys/Hostname/Hostname.so: undefined symbol: Perl_xs_handshake NXAGENT is user /usr/bin/perl and ignoring the Perl bin directory at the start of the path, but it is nevertheless using the Perl environment variables and so is looking in the wrong place for the Perl library.
I'd say this isn't a bug, but actually expected behavior. If you need different values for variables depending on which software you run, you either need to prefix them manually each time you call that software, or write a wrapper script, or use if/then clauses in your .bash_profile. The latter is what you seem to have decided to do, and ran into problems with, judging from your bug report #1134, thus closing this one.
-Stefan
-- 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
-- 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
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
On Jan 10, 2017, at 3:42 PM, Stefan Baur <X2Go-ML-1@baur-itcs.de> wrote:
Ted,
let's examine a few things here:
You're saying that nxagent is doing things in Perl, and not the right things. When examining the contents of the nxagent package, all I'm seeing wrt/ executables are bash scripts and compiled binaries, but nothing written in Perl. So the nxagent package can't be at fault.
We *do* have scripts that are written in Perl, and that might throw the error you quoted. Those are e.g. in the package with the name x2goserver (and I wouldn't be surprised to find more of them in other packages that have names beginning with x2go*).
grep '^#!.*perl*' /usr/bin/x2go* returns a list of scripts that all have #!/usr/bin/perl as shebang, so yes, it's probably safe to say that the use of /usr/bin/perl as the Perl interpreter for our scripts is hardcoded.
But again, that's not a bug, but how scripting works on Linux/Unix. First line with shebang tells the shell which interpreter to use, so you don't have to prefix the script name with the name of the interpreter each time.
And of course, if you set a variable with a name matching one that "a" Perl interpreter (be it ActivePerl or the system standard shipped with your distribution) looks for, it will use it.
Your statement that the version of Perl being used depends on which one comes first in the path might be true on Windows; on Unix, it will only be true for when you type "perl" without a path in an interactive shell, or for when call it from within, say, a bash script without preceding it with a path. Once you chmod +x a Perl script and call it by its name, without prefacing the name and full path to the interpreter, the shebang line will be used to determine the interpreter.
So, if you need to set PERL5LIB for your ActivePerl installation, it should be unset (by adding a suitable if/then clause) when your .bashrc / .bash_profile are read and parsed by an X2Go task. It's kind of weird that, according to your other bug report, you have exactly 0 indication that you're running from within an X2Go session. I can see how that makes it difficult to script around it ;-) - but let's track that in the other bug report.
Kind Regards, Stefan Baur
Am 10.01.2017 um 23:48 schrieb Ted Toal:
I disagree. Perl behavior is to look at env. var. PERL5LIB to find its library. This should be set to match the Perl that is being invoked, which is normally done by placing that Perl’s bin directory on the path. Since I did place it on the path, there are only two possibilities for why x2go ran /usr/bin/perl: either it hard-coded the path to Perl, in which case it should first set PERL5LIB (or maybe there is a Perl command line arg to specify the library folder), OR x2go ignored my changes to PATH when it ran perl (in which case it should also ignore PERL5LIB).
- Ted
On Jan 10, 2017, at 2:35 PM, Stefan Baur <X2Go-ML-1@baur-itcs.de> wrote:
Control: close -1 Control: tag -1 not-a-bug
Am 10.01.2017 um 22:15 schrieb Ted Toal:
Package: NXAGENT Version: 3.5.0
My .bash_profile defines Perl environment variables for Active Perl, and adds the Active Perl bin directory to the start of the path. This causes an x2go session to fail with the message: Connection failed. /usr/bin/perl: symbol lookup error: /share/carvajal-archive/PACKAGES/local/ActivePerl-5.24/lib/auto/Sys/Hostname/Hostname.so: undefined symbol: Perl_xs_handshake NXAGENT is user /usr/bin/perl and ignoring the Perl bin directory at the start of the path, but it is nevertheless using the Perl environment variables and so is looking in the wrong place for the Perl library.
I'd say this isn't a bug, but actually expected behavior. If you need different values for variables depending on which software you run, you either need to prefix them manually each time you call that software, or write a wrapper script, or use if/then clauses in your .bash_profile. The latter is what you seem to have decided to do, and ran into problems with, judging from your bug report #1134, thus closing this one.
-Stefan
-- 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
-- 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
x2go-dev mailing list x2go-dev@lists.x2go.org http://lists.x2go.org/listinfo/x2go-dev
Control: reassign -1 x2goserver 4.0.1.20
On 11.01.2017 02:48 AM, Ted Toal wrote:
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.
If you explicitly break your setup by defining random variables in shell startup scripts, you'll have to handle the outcome.
Following the same line of original reasoning, users COULD potentially replace /usr/bin/perl with /bin/false. It's unreasonable to expect stuff to check whether /usr/bin/perl actually is a Perl interpreter.
In your case, the proper workaround would be to change the perl hashbangs to "#!/usr/bin/env perl" instead, so that the first matching perl binary in $PATH is used. I won't change that in x2goserver, though, as we have literally no idea what users do to their PATH variable (and shouldn't assume.) Note, that this may still not work, as I vaguely remember at least X2Go Client to export a sane PATH value before executing any command remotely, though.
If anything, we could explicitly unset PERL5LIB in the client application for additional sanitation. Would that make sense?
Mihai
If you explicitly break your setup by defining random variables in shell startup scripts, you'll have to handle the outcome.
I did not break perl, I replaced perl with a different perl, which involved adding a PATH and changing Perl env. vars. In a sense, the real problem is that Perl finds its libraries in a stupid way. But given that it is this way, I don’t know what the best way to deal with this situation is. Fixing it with ‘if’ statements in .bashrc is a lousy solution, an annoyance to a lot of people.
If anything, we could explicitly unset PERL5LIB in the client application for additional sanitation. Would that make sense?
Yes it would. But then I don’t know if Perl will still find the libraries it needs. It might, because it may have the default library paths hard-coded. I seem to remember reading that Perl puts some paths in place when it is compiled. Maybe the Active Perl I use was not compiled correctly to get the correct default paths, and if it had been maybe I wouldn’t need to set PERL5LIB.
ted
Mihai
On Jan 11, 2017, at 12:58 AM, Mihai Moldovan <ionic@ionic.de> wrote:
Control: reassign -1 x2goserver 4.0.1.20
On 11.01.2017 02:48 AM, Ted Toal wrote:
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.
If you explicitly break your setup by defining random variables in shell startup scripts, you'll have to handle the outcome.
Following the same line of original reasoning, users COULD potentially replace /usr/bin/perl with /bin/false. It's unreasonable to expect stuff to check whether /usr/bin/perl actually is a Perl interpreter.
In your case, the proper workaround would be to change the perl hashbangs to "#!/usr/bin/env perl" instead, so that the first matching perl binary in $PATH is used. I won't change that in x2goserver, though, as we have literally no idea what users do to their PATH variable (and shouldn't assume.) Note, that this may still not work, as I vaguely remember at least X2Go Client to export a sane PATH value before executing any command remotely, though.
If anything, we could explicitly unset PERL5LIB in the client application for additional sanitation. Would that make sense?
Mihai
Control: close -1 thanks
[re-sent as the original message went to Ted's personal mailbox only]
perl has the -l option for specifying the PERL5LIB path. That
Am 11.01.2017 um 02:48 schrieb Ted Toal: 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.
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
Sorry for the mixup about lower case l and capital I. I don’t know that using a different font would have helped in this case. I had the wrong one specified and you found it and used it despite the font. Btw, the web site where I found the option (perlmaven.com) also used a font that didn’t distinguish it, which is how it propagated to me.
Perhaps that option on the shebang is not the best way to handle this. But you are wrong to think that people should not or will not be setting PERL5LIB in their .bashrc. It is normal practice among Perl users, and in fact I would guess that the majority of Perl users do so. And that breaks x2go. x2go should never assume that the environment variables used by a program it is invoking, especially /usr/lib/perl, will be set the way it wants them set, after .bashrc has run.
ted
On Jan 11, 2017, at 1:05 AM, Stefan Baur <X2Go-ML-1@baur-itcs.de> wrote:
Control: close -1 thanks
[re-sent as the original message went to Ted's personal mailbox only]
perl has the -l option for specifying the PERL5LIB path. That
Am 11.01.2017 um 02:48 schrieb Ted Toal: 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
Processing control commands:
close -1 Bug #1133 [nxagent] Inconsistent Perl used by server or its agent on connect Marked Bug as done tag -1 not-a-bug Bug #1133 {Done: Stefan Baur <X2Go-ML-1@baur-itcs.de>} [nxagent] Inconsistent Perl used by server or its agent on connect Added tag(s) not-a-bug.
-- 1133: http://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=1133 X2Go Bug Tracking System Contact owner@bugs.x2go.org with problems
Processing control commands:
reassign -1 x2goserver 4.0.1.20 Bug #1133 {Done: Stefan Baur <X2Go-ML-1@baur-itcs.de>} [nxagent] Inconsistent Perl used by server or its agent on connect Bug reassigned from package 'nxagent' to 'x2goserver'. No longer marked as found in versions 3.5.0. Ignoring request to alter fixed versions of bug #1133 to the same values previously set Bug #1133 {Done: Stefan Baur <X2Go-ML-1@baur-itcs.de>} [x2goserver] Inconsistent Perl used by server or its agent on connect There is no source info for the package 'x2goserver' at version '4.0.1.20' with architecture '' Unable to make a source version for version '4.0.1.20' Marked as found in versions 4.0.1.20.
-- 1133: http://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=1133 X2Go Bug Tracking System Contact owner@bugs.x2go.org with problems
Processing control commands:
close -1 Bug #1133 {Done: Stefan Baur <X2Go-ML-1@baur-itcs.de>} [x2goserver] Inconsistent Perl used by server or its agent on connect Bug 1133 is already marked as done; not doing anything.
-- 1133: http://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=1133 X2Go Bug Tracking System Contact owner@bugs.x2go.org with problems