Skip Menu |

This queue is for tickets about the Cwd CPAN distribution.

Report information
The Basics
Id: 13255
Status: resolved
Priority: 0/
Queue: Cwd

People
Owner: Nobody in particular
Requestors: neil.watkiss [...] sophos.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.21
Fixed in: (no value)



Subject: [PATCH] Cwd.pm leaves $ENV{IFS} = undef on 5.6
Package: Cwd-2.21 ----8<---- tanktest root # /opt/perl/bin/perl -V Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=freebsd, osvers=5.4-release, archname=i386-freebsd-thread-multi uname='freebsd tanktest 5.4-release freebsd 5.4-release #0: tue jun 7 18:16:04 pdt 2005 neilw@tankpc05.tank:usrhomeneilwfreebsdtmp.objsophok i386 ' config_args='-des -Dcc=gcc -Dcf_by=Sophos -Dcf_email=PureMessage-Support@sophos.com -Dmyhostname=localhost -Dmydomain=localdomain -Uinstallusrbinperl -Ud_sigsetjmp -Ui_db -Dusethreads -Duseithreads -Accflags=-DPERL_DISABLE_PMC -Accflags=-DPMX_BUILD=150000 -Dprefix=/opt/perl' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='gcc', ccflags ='-DPERL_DISABLE_PMC -DPMX_BUILD=150000 -fno-strict-aliasing', optimize='-O', cppflags='-DPERL_DISABLE_PMC -DPMX_BUILD=150000 -fno-strict-aliasing' ccversion='', gccversion='3.4.2 [FreeBSD] 20040728', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='gcc', ldflags ='-pthread -Wl,-E ' libpth=/usr/lib libs=-ldb -lm -lc_r -lcrypt -lutil perllibs=-lm -lc_r -lcrypt -lutil libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fpic', lddlflags='-shared ' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: ActivePerl Build 635 [PureMessage-Perl build 150000] Built under freebsd Compiled at Jun 13 2005 22:33:25 @INC: /opt/perl/lib/5.6.1/i386-freebsd-thread-multi /opt/perl/lib/5.6.1 /opt/perl/lib/site_perl/5.6.1/i386-freebsd-thread-multi /opt/perl/lib/site_perl/5.6.1 /opt/perl/lib/site_perl . tanktest root # uname -a FreeBSD tanktest 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Tue Jun 7 18:16:04 PDT 2005 neilw@tankpc05.tank:/usr/home/neilw/freebsd/tmp.obj/SOPHOK i386 ---->8---- The problem is in _backtick_pwd(): ----8<---- # The 'natural and safe form' for UNIX (pwd may be setuid root) sub _backtick_pwd { local @ENV{qw(PATH IFS CDPATH ENV BASH_ENV)}; my $cwd = `$pwd_cmd`; # Belt-and-suspenders in case someone said "undef $/". local $/ = "\n"; # `pwd` may fail e.g. if the disk is full chomp($cwd) if defined $cwd; $cwd; } ---->8---- Unfortunately, on Perl 5.6.1 (at least the version I'm using here), this leaves %ENV corrupted. To reproduce, try this one-liner: ----8<---- tanktest root # perl -MCwd -MData::Dumper -e 'print Dumper(\%ENV); cwd; print Dumper(\%ENV)' $VAR1 = { '_' => '/opt/perl/bin/perl', 'HISTFILESIZE' => '5000', 'STY' => '29048.autobld', 'SHLVL' => '3', 'HISTSIZE' => '5000', 'PWD' => '/root', 'INPUTRC' => '/etc/inputrc', 'PS1' => '\\[\\033[01;31m\\]\\h \\[\\033[01;34m\\]\\W \\$ \\[\\033[00m\\]', 'PAGER' => '/usr/bin/less', 'EDITOR' => '/usr/bin/vim', 'USER' => 'root', 'HOME' => '/root', 'OLDPWD' => '/opt/devel/lib', 'HISTFILE' => '/root/.bash_history', 'TERM' => 'screen-bce', 'LOGNAME' => 'root', 'PATH' => '/opt/devel/lib/ccache/bin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/devel/bin', 'HISTCONTROL' => 'ignoredups', 'SHELL' => '/bin/bash', 'MAIL' => '/var/mail/root' }; $VAR1 = { 'BASH_ENV' => undef, 'IFS' => undef, '_' => '/opt/perl/bin/perl', 'HISTFILESIZE' => '5000', 'STY' => '29048.autobld', 'CDPATH' => undef, 'SHLVL' => '3', 'ENV' => undef, 'HISTSIZE' => '5000', 'PWD' => '/root', 'INPUTRC' => '/etc/inputrc', 'PS1' => '\\[\\033[01;31m\\]\\h \\[\\033[01;34m\\]\\W \\$ \\[\\033[00m\\]', 'PAGER' => '/usr/bin/less', 'EDITOR' => '/usr/bin/vim', 'USER' => 'root', 'HOME' => '/root', 'OLDPWD' => '/opt/devel/lib', 'HISTFILE' => '/root/.bash_history', 'TERM' => 'screen-bce', 'LOGNAME' => 'root', 'PATH' => '/opt/devel/lib/ccache/bin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/devel/bin', 'HISTCONTROL' => 'ignoredups', 'SHELL' => '/bin/bash', 'MAIL' => '/var/mail/root' }; ---->8---- Notice the $ENV{IFS} = undef? That's naughty. That actually sets $IFS, the input field separator, for subsequently launched /bin/sh programs. Here's a simple patch that fixes the problem: ----8<---- --- Cwd.pm~ 2005/05/05 11:07:31 +++ Cwd.pm 2005/06/14 11:08:07 @@ -292,7 +292,8 @@ # The 'natural and safe form' for UNIX (pwd may be setuid root) sub _backtick_pwd { - local @ENV{qw(PATH IFS CDPATH ENV BASH_ENV)}; + my @localize = grep exists $ENV{$_}, qw(PATH IFS CDPATH ENV BASH_ENV); + local @ENV{@localize}; my $cwd = `$pwd_cmd`; # Belt-and-suspenders in case someone said "undef $/". local $/ = "\n"; ---->8---- Cheers, Neil
Thanks, Neil - this is now committed. -Ken