Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leading spaces on cpan configuration causes failure #6994

Closed
p5pRT opened this issue Dec 18, 2003 · 9 comments
Closed

leading spaces on cpan configuration causes failure #6994

p5pRT opened this issue Dec 18, 2003 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 18, 2003

Migrated from rt.perl.org#24691 (status was 'resolved')

Searchable as RT24691$

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2003

From warrend@tek.com

Created by warrend@tek.com

When I started cpan for the first time on perl-5.8.2 and started the
configuration process I was cutting and pasting from a file. I grabbed the
cpan directory location with leading spaces and pasted it.

The results were this as the next prompt

first line
CPAN build and cache directory? [/login/warrend/.cpan] /proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8
second line
The path ' /proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8' is not an absolute path. Please specify an absolute path
third line
CPAN build and cache directory? [/proj/wdtold/warrend/gnusrc/900180+perl-5.8.2/perl-5.8.2_sun5.8/ /proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8]

This surprised me as the leading spaces were actually used. Many other areas
they are stripped. I assume this is an oversite but I have been wrong in the past.

Perl Info

Flags:
    category=utilities
    severity=low

Site configuration information for perl v5.8.2:

Configured by warrend at Thu Dec 18 11:49:31 PST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
    uname='sunos rosewood 5.8 generic_108528-18 sun4u sparc sunw,ultra-5_10 solaris '
    config_args=''
    hint=recommended, 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='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing -I/proj/wdt/sun5.8/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-D_REENTRANT -fno-strict-aliasing -I/proj/wdt/sun5.8/include'
    ccversion='', gccversion='3.3.2', gccosandvers='solaris2.8'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' '
    libpth=/usr/lib /usr/ccs/lib /proj/wdt/sun5.8/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lpthread -lc
    perllibs=-lsocket -lnsl -ldl -lm -lpthread -lc
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl582.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-E -R /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/5.8.2/sun4-solaris-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags=' -Wl,-E -G'

Locally applied patches:
    


@INC for perl v5.8.2:
    /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/5.8.2/sun4-solaris-thread-multi
    /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/5.8.2
    /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/site_perl/5.8.2/sun4-solaris-thread-multi
    /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/site_perl/5.8.2
    /proj/wdt/gnu_sun5.8/perl-5.8.2/lib/site_perl
    .


Environment for perl v5.8.2:
    HOME=/login/warrend
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/tools/eda/ldv/bin:/proj/eda/ldv/ldv/cur/tools/inca/lib:/proj/eda/ldv/ldv/cur/tools/lib
    LOGDIR (unset)
    PATH=/stdapps/lsf/5.8/sparcv9/bin:/stdapps/lsf/local/bin:.:/proj/wdt/gnu_sun5.8/perl-5.8.2/bin:/proj/wdt/bin:/proj/wdt/sun5.8/bin:/proj/wdt/X.V11R6/sun5.8/bin:/login/warrend:/login/warrend/bin:/login/warrend/bin/sun5.8:/usr/ucb:/usr/openwin/bin:/usr/ccs/bin:/usr/bin:/etc:/usr/sbin:/proj/dpl/harry/bin:/tools/citrix6.0:/proj/mbcc/hfd/bin:/tools/eda/psd/15.0e/tools/pcb/bin:/tools/eda/psd/15.0e/tools/bin:/tools/eda/psd/15.0e/tools/dfII/bin:/tools/eda/psd/15.0e/tools/fet/bin:/tools/eda/psd/15.0e/tools/specctra/bin:/tools/eda/fetools/psd150/bin:/tools/eda/cadtools/psd150/bin:/tools/eda/ldv/LSF:/tools/eda/ldv/bin:/proj/eda/ldv/ldv/cur/tools/bin:/proj/eda/ldv/ldv/cur/tools/inca/bin:/proj/eda/ldv/lec/cur/bin:/proj/eda/ldv/debussy/cur/bin:/proj/eda/ldv/nLint/cur/bin:/proj/eda/common/vim/cur/bin:/stdapps/cms/bin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2005

From @schwern

[warrend@​tek.com - Thu Dec 18 15​:43​:42 2003]​:
When I started cpan for the first time on perl-5.8.2 and started the
configuration process I was cutting and pasting from a file. I grabbed
the
cpan directory location with leading spaces and pasted it.

The results were this as the next prompt

first line
CPAN build and cache directory? [/login/warrend/.cpan]
/proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8
The path ' /proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8' is not an
absolute path. Please specify an absolute path

The attached patch makes CPAN​::FirstTime consistent in its stripping of
leading and trailing spaces by building it directly into its prompt()
function rather than hoping the caller deals with it.

In two places I've left the input unstripped, the proxy username and
password. Concievably one could have a username and password which
begins or ends with spaces so its best to leave that unaltered.

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2005

From @schwern

CPAN_FirstTime.patch
--- lib/CPAN/FirstTime.pm	2005/07/12 06:41:25	1.1
+++ lib/CPAN/FirstTime.pm	2005/07/12 06:55:31
@@ -12,7 +12,7 @@
 package CPAN::FirstTime;
 
 use strict;
-use ExtUtils::MakeMaker qw(prompt);
+use ExtUtils::MakeMaker ();
 use FileHandle ();
 use File::Basename ();
 use File::Path ();
@@ -68,23 +68,22 @@
 
 ];
 
-    my $manual_conf =
-	ExtUtils::MakeMaker::prompt("Are you ready for manual configuration?",
-				    "yes");
+    my $manual_conf = prompt("Are you ready for manual configuration?", "yes");
     my $fastread;
     {
-      local $^W;
-      if ($manual_conf =~ /^\s*y/i) {
+      if ($manual_conf =~ /^y/i) {
 	$fastread = 0;
-	*prompt = \&ExtUtils::MakeMaker::prompt;
       } else {
 	$fastread = 1;
 	$CPAN::Config->{urllist} ||= [];
+
+        local $^W = 0;
 	# prototype should match that of &MakeMaker::prompt
-	*prompt = sub ($;$) {
+	*_real_prompt = sub ($;$) {
 	  my($q,$a) = @_;
 	  my($ret) = defined $a ? $a : "";
 	  printf qq{%s [%s]\n\n}, $q, $ret;
+
 	  $ret;
 	};
       }
@@ -198,8 +197,8 @@
     defined($default = $CPAN::Config->{cache_metadata}) or $default = 1;
     do {
         $ans = prompt("Cache metadata (yes/no)?", ($default ? 'yes' : 'no'));
-    } while ($ans !~ /^\s*[yn]/i);
-    $CPAN::Config->{cache_metadata} = ($ans =~ /^\s*y/i ? 1 : 0);
+    } while ($ans !~ /^[yn]/i);
+    $CPAN::Config->{cache_metadata} = ($ans =~ /^y/i ? 1 : 0);
 
     #
     # term_is_latin
@@ -222,8 +221,8 @@
     do {
         $ans = prompt("Your terminal expects ISO-8859-1 (yes/no)?",
                       ($default ? 'yes' : 'no'));
-    } while ($ans !~ /^\s*[yn]/i);
-    $CPAN::Config->{term_is_latin} = ($ans =~ /^\s*y/i ? 1 : 0);
+    } while ($ans !~ /^[yn]/i);
+    $CPAN::Config->{term_is_latin} = ($ans =~ /^y/i ? 1 : 0);
 
     #
     # save history in file histfile
@@ -241,8 +240,6 @@
     defined($default = $CPAN::Config->{histfile}) or
         $default = File::Spec->catfile($CPAN::Config->{cpan_home},"histfile");
     $ans = prompt("File to save your history?", $default);
-    $ans =~ s/^\s+//;
-    $ans =~ s/\s+\z//;
     $CPAN::Config->{histfile} = $ans;
 
     if ($CPAN::Config->{histfile}) {
@@ -428,7 +425,7 @@
 be asked for your username in every future session.
 
 };
-        if ($CPAN::Config->{proxy_user} = prompt("Your proxy user id?",$default)) {
+        if ($CPAN::Config->{proxy_user} = prompt_no_strip("Your proxy user id?",$default)) {
             print qq{
 
 Your password for the authenticating proxy can also be stored
@@ -448,7 +445,7 @@
 
 };
             }
-            $CPAN::Config->{proxy_pass} = prompt("Your proxy password?");
+            $CPAN::Config->{proxy_pass} = prompt_no_strip("Your proxy password?");
             if ($CPAN::META->has_inst("Term::ReadKey")) {
                 Term::ReadKey::ReadMode("restore");
             }
@@ -692,8 +689,6 @@
         $ans = prompt ($prompt, "");
 
         if ($ans) {
-            $ans =~ s/^\s+//;  # no leading spaces
-            $ans =~ s/\s+\z//; # no trailing spaces
             $ans =~ s|/?\z|/|; # has to end with one slash
             $ans = "file:$ans" unless $ans =~ /:/; # without a scheme is a file:
             if ($ans =~ /^\w+:\/./) {
@@ -715,5 +710,29 @@
     print "New set of picks:\n";
     map { print "  $_\n" } @{$CPAN::Config->{urllist}};
 }
+
+
+sub _strip_spaces {
+    $_[0] =~ s/^\s+//;  # no leading spaces
+    $_[0] =~ s/\s+\z//; # no trailing spaces
+}
+
+
+sub prompt ($;$) {
+    my $ans = _real_prompt(@_);
+
+    _strip_spaces($ans);
+
+    return $ans;
+}
+
+
+sub prompt_no_strip ($;$) {
+    return _real_prompt(@_);
+}
+
+
+*_real_prompt = \*ExtUtils::MakeMaker::prompt;
+
 
 1;

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @steve-m-hay

Michael G Schwern via RT wrote​:

[warrend@​tek.com - Thu Dec 18 15​:43​:42 2003]​:
When I started cpan for the first time on perl-5.8.2 and started the
configuration process I was cutting and pasting from a file. I grabbed
the
cpan directory location with leading spaces and pasted it.

The results were this as the next prompt

first line
CPAN build and cache directory? [/login/warrend/.cpan]
/proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8
The path ' /proj/wdtold/warrend/cpan_perl-5.8.2_sun5.8' is not an
absolute path. Please specify an absolute path

The attached patch makes CPAN​::FirstTime consistent in its stripping of
leading and trailing spaces by building it directly into its prompt()
function rather than hoping the caller deals with it.

In two places I've left the input unstripped, the proxy username and
password. Concievably one could have a username and password which
begins or ends with spaces so its best to leave that unaltered.

Given the discussions about leading/trailing spaces in Unix paths in the
last day or two, it is also conceivable that one could have a path which
begins or ends with spaces.

Your patch works on the basis that such paths are unlikely so anyone
entering a path with a leading space *almost* certainly didn't intend
the space to be taken as part of the path.

I would agree with this, even though it does mean that if you actually
wanted to enter a path with a leading space then now you can't.

Before this patch goes in, does anyone disagree?

And if we're agreed that leading spaces should be removed from paths on
the basis that they are very unlikely then perhaps there is no reason to
treat username and password any differently? Isn't that equally
unlikely (at least for the username)?


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 13, 2005

From @schwern

On Wed, Jul 13, 2005 at 09​:39​:43AM +0100, Steve Hay wrote​:

And if we're agreed that leading spaces should be removed from paths on
the basis that they are very unlikely then perhaps there is no reason to
treat username and password any differently? Isn't that equally
unlikely (at least for the username)?

I can see that for the username but not for the password.

--
Michael G Schwern schwern@​pobox.com http​://www.pobox.com/~schwern
'All anyone gets in a mirror is themselves,' she said. 'But what you
gets in a good gumbo is everything.'
  -- "Witches Abroad" by Terry Prachett

@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2005

From @steve-m-hay

Michael G Schwern wrote​:

On Wed, Jul 13, 2005 at 09​:39​:43AM +0100, Steve Hay wrote​:

And if we're agreed that leading spaces should be removed from paths on
the basis that they are very unlikely then perhaps there is no reason to
treat username and password any differently? Isn't that equally
unlikely (at least for the username)?

I can see that for the username but not for the password.

OK - applied as change 25147 with the username stripped of spaces but
not the password.


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2005

From @steve-m-hay

Now fixed in bleadperl. Should be in 5.8.8 (or otherwise in 5.10), and
in the next CPAN.pm release.

@p5pRT p5pRT closed this as completed Jul 15, 2005
@p5pRT
Copy link
Author

p5pRT commented Jul 15, 2005

@steve-m-hay - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant