Subject: | Modification of built-in Perl variable $/ causes "Permission denied" |
Hi all,
simply try this script:
#-------
#!/usr/bin/perl -w
use Net::SSH::Perl;
$host="some_server_address";
# !!! Will not work, if the variable $/ modified
$/='';
my $sshdebug=1;
$connection=Net::SSH::Perl->new($host,(debug => $sshdebug,identity_files
=> ["/root/root/.ssh/id_dsa"],privileged => 0,protocol => 2));
$connection->login("root");
$cmd="banner test";
($dummy1, $dummy2, $code) = $connection->cmd($cmd);
print "$dummy1, $dummy2, $code \n";
#-------
The above script produces the following output:
#-------
some_server_address: Reading configuration data /root/rx14857/.ssh/config
some_server_address: Reading configuration data /etc/ssh_config
some_server_address: Connecting to ii06app1a1, port 22.
some_server_address: Remote version string: SSH-2.0-OpenSSH_3.7.1p2
some_server_address: Remote protocol version 2.0, remote software
version OpenSSH_3.7.1p2
some_server_address: Net::SSH::Perl Version 1.30, protocol version 2.0.
some_server_address: No compat match: OpenSSH_3.7.1p2.
some_server_address: Connection established.
some_server_address: Sent key-exchange init (KEXINIT), wait response.
some_server_address: Algorithms, c->s: 3des-cbc hmac-sha1 none
some_server_address: Algorithms, s->c: 3des-cbc hmac-sha1 none
some_server_address: Entering Diffie-Hellman Group 1 key exchange.
some_server_address: Sent DH public key, waiting for reply.
some_server_address: Received host key, type 'ssh-dss'.
some_server_address: Host 'ii06app1a1' is known and matches the host key.
some_server_address: Computing shared secret key.
some_server_address: Verifying server signature.
some_server_address: Waiting for NEWKEYS message.
some_server_address: Enabling incoming encryption/MAC/compression.
some_server_address: Send NEWKEYS, enable outgoing
encryption/MAC/compression.
some_server_address: Sending request for user-authentication service.
some_server_address: Service accepted: ssh-userauth.
some_server_address: Trying empty user-authentication request.
some_server_address: Authentication methods that can continue:
publickey,password.
some_server_address: Next method to try is publickey.
some_server_address: Trying pubkey authentication with key file
'/root/root/.ssh/id_dsa'
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Will not query passphrase for
'/root/root/.ssh/id_dsa' in batch mode.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Loading private key failed.
some_server_address: Next method to try is password.
some_server_address: Trying password authentication.
some_server_address: Will not query passphrase in batch mode.
some_server_address: Authentication methods that can continue:
publickey,password.
some_server_address: Next method to try is publickey.
some_server_address: Trying pubkey authentication with key file
'/root/root/.ssh/id_dsa'
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Will not query passphrase for
'/root/root/.ssh/id_dsa' in batch mode.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Loading private key failed.
some_server_address: Next method to try is password.
some_server_address: Trying password authentication.
some_server_address: Will not query passphrase in batch mode.
some_server_address: Authentication methods that can continue:
publickey,password.
some_server_address: Next method to try is publickey.
some_server_address: Trying pubkey authentication with key file
'/root/root/.ssh/id_dsa'
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Will not query passphrase for
'/root/root/.ssh/id_dsa' in batch mode.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Loading private key failed.
some_server_address: Next method to try is password.
some_server_address: Trying password authentication.
some_server_address: Will not query passphrase in batch mode.
some_server_address: Authentication methods that can continue:
publickey,password.
some_server_address: Next method to try is publickey.
some_server_address: Trying pubkey authentication with key file
'/root/root/.ssh/id_dsa'
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Will not query passphrase for
'/root/root/.ssh/id_dsa' in batch mode.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
Use of uninitialized value in substitution (s///) at
/usr/opt/perl5/lib/site_perl/5.8.2/Net/SSH/Perl/Key.pm line 78.
some_server_address: Loading private key failed.
some_server_address: Next method to try is password.
Permission denied at ./s.pl line 12
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#-------
As a result, "Permission denied" will occure during the login sequence.
If you leave the variable $/ unchanged, the script works as expected.
Sometimes, it is very useful to modify '$/' variable. Is it real bug or
do I do something wrong?
Thank you very much for your answer.
Have a nice day,
Lubos Lavicka
#--------------------
Perl Version:
(0)instibm1:sod# perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=aix, osvers=5.2.0.0, archname=aix-thread-multi
uname='aix perlfly 2 5 000ad7df4c00 '
config_args=''
hint=previous, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc_r', ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
-qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT
-q32 -D_LARGE_FILES -qlonglong',
optimize='-O',
cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
-qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT
-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384
-qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -q32
-D_LARGE_FILES -qlonglong -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
-qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT
-q32 -D_LARGE_FILES -qlonglong -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN
-DNEED_PTHREAD_INIT -q32 -D_LARGE_FILES -qlonglong -D_ALL_SOURCE
-D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384 -qnoansialias
-DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -q32 -D_LARGE_FILES -qlonglong
-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384
-qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -q32
-D_LARGE_FILES -qlonglong -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
-qmaxmem=16384 -qnoansialias -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT
-q32 -D_LARGE_FILES -qlonglong'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='ld', ldflags =' -brtl -b32 -bmaxdata:0x80000000'
libpth=/lib /usr/lib /usr/ccs/lib
libs=-lbind -lnsl -ldbm -ldl -lld -lm -lpthreads -lc_r -lcrypt -lbsd
-lPW
perllibs=-lbind -lnsl -ldl -lld -lm -lpthreads -lc_r -lcrypt -lbsd -lPW
libc=/lib/libc.a, so=a, useshrplib=true, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-bE:/usr/opt/perl5/lib/5.8.2/aix-thread-multi/CORE/perl.exp
-bE:/usr/opt/perl5/lib/5.8.2/aix-thread-multi/CORE/perl.exp
-bE:/usr/opt/perl5/lib/5.8.2/aix-thread-multi/CORE/perl.exp
-bE:/usr/opt/perl5/lib/5.8.2/aix-thread-multi/CORE/perl.exp'
cccdlflags=' ', lddlflags='-bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp
-bE:$(BASEEXT).exp -bnoentry -lpthreads -lc_r'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Built under aix
Compiled at Feb 13 2004 13:18:17
%ENV:
PERL5LIB="/export/admin/lib/perl"
@INC:
/export/admin/lib/perl
/usr/opt/perl5/lib/5.8.2/aix-thread-multi
/usr/opt/perl5/lib/5.8.2
/usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi
/usr/opt/perl5/lib/site_perl/5.8.2
/usr/opt/perl5/lib/site_perl
.
Server:
AIX some_server 3 5 005665FA4C00