This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove "." from default @INC when default_inc_excludes_dot is set
authorH.Merijn Brand <h.m.brand@xs4all.nl>
Sat, 22 Oct 2016 11:46:08 +0000 (13:46 +0200)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Fri, 11 Nov 2016 15:27:20 +0000 (16:27 +0100)
Perl now provides a way to build perl without . in @INC by default. If you want
this feature, you can build with -Ddefault_inc_excludes_dot

Because the testing / make process for perl modules do not function well
with . missing from @INC, Perl now supports the environment variable
PERL_USE_UNSAFE_INC=1 which makes Perl behave as it previously did,
returning . to @INC in all child processes.

WARNING: PERL_USE_UNSAFE_INC has been provided during the perl 5.25 development
cycle and is not guaranteed to function in perl 5.26.

Update unit tests and default value files to work with the new %Config
variable "default_inc_excludes_dot"

15 files changed:
Configure
Cross/config.sh-arm-linux
NetWare/config.wc
Porting/Glossary
Porting/config.sh
config_h.SH
configure.com
plan9/config_sh.sample
symbian/config.sh
uconfig.h
uconfig.sh
uconfig64.sh
win32/config.ce
win32/config.gc
win32/config.vc

index 4492020..84a34bf 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -937,6 +937,7 @@ d_wcstombs=''
 d_wcsxfrm=''
 d_wctomb=''
 d_writev=''
+default_inc_excludes_dot=''
 dlext=''
 bin_ELF=''
 cccdlflags=''
@@ -20625,6 +20626,28 @@ EOCP
        ;;
 esac
 
+: Include . in @INC
+$cat <<EOM
+
+Historically Perl has provided a final fallback of the current working
+directory '.' when searching for a library. This, however, can lead to
+problems when a Perl program which loads optional modules is called from
+a shared directory. This can lead to executing unexpected code.
+
+EOM
+
+case "$default_inc_excludes_dot" in
+    $define|true|[yY]*) dflt="n" ;;
+    *)                  dflt='y' ;;
+esac
+
+rp='Provide '.' in @INC by default? '
+. ./myread
+case "$ans" in
+    [nN]*|define) default_inc_excludes_dot="$define" ;;
+    *)            default_inc_excludes_dot="$undef"  ;;
+esac
+
 : Check what kind of inf/nan your system has
 $echo "Checking the kind of infinities and nans you have..." >&4
 $echo "(The following tests may crash.  That's okay.)" >&4
@@ -24913,6 +24936,7 @@ db_prefixtype='$db_prefixtype'
 db_version_major='$db_version_major'
 db_version_minor='$db_version_minor'
 db_version_patch='$db_version_patch'
+default_inc_excludes_dot='$default_inc_excludes_dot'
 direntrytype='$direntrytype'
 dlext='$dlext'
 dlsrc='$dlsrc'
index 2626400..a20d723 100644 (file)
@@ -637,6 +637,7 @@ db_prefixtype='size_t'
 db_version_major=''
 db_version_minor=''
 db_version_patch=''
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 dlext='so'
 dlsrc='dl_dlopen.xs'
index 176a865..8535885 100644 (file)
@@ -628,6 +628,7 @@ db_version_minor='0'
 db_version_patch='0'
 def_perlroot='sys:\perl\scripts'
 def_temp='sys:\perl\temp'
+default_inc_excludes_dot=''
 direntrytype='DIR'
 dlext='nlm'
 dlsrc='dl_netware.xs'
index 522d356..1d2a6ea 100644 (file)
@@ -2959,6 +2959,9 @@ db_version_patch (i_db.U):
        Berkeley DB found in the <db.h> header file.
        For DB version 1 this is always 0.
 
+default_inc_excludes_dot (defaultincdot.U):
+       When defined, remove the legacy '.' from @INC
+
 direntrytype (i_dirent.U):
        This symbol is set to 'struct direct' or 'struct dirent' depending on
        whether dirent is available or not. You should use this pseudo type to
index ff6a5fe..c9aa2c2 100644 (file)
@@ -650,6 +650,7 @@ db_prefixtype='int'
 db_version_major='1'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 dlext='bundle'
 dlsrc='dl_dlopen.xs'
index c722657..e9b144f 100755 (executable)
@@ -3736,6 +3736,12 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
  */
 #$d_writev HAS_WRITEV          /**/
 
+/* DEFAULT_INC_EXCLUDES_DOT:
+ *     This symbol, if defined, removes the legacy default behavior of
+ *     including '.' at the end of @INC.
+ */
+#$default_inc_excludes_dot DEFAULT_INC_EXCLUDES_DOT    /**/
+
 /* USE_DYNAMIC_LOADING:
  *     This symbol, if defined, indicates that dynamic loading of
  *     some sort is available.
index 888d2d0..090d2ef 100644 (file)
@@ -6452,6 +6452,7 @@ $ WC "db_version_minor='" + "'"
 $ WC "db_version_patch='" + "'"
 $ WC "dbgprefix='" + dbgprefix + "'"
 $ WC "devtype='" + devtype + "'"
+$ WC "default_inc_excludes_dot=''"
 $ WC "direntrytype='struct dirent'"
 $ WC "dlext='" + dlext + "'"
 $ WC "dlobj='" + dlobj + "'"
index 9851e22..e7078a0 100644 (file)
@@ -636,6 +636,7 @@ db_prefixtype='size_t'
 db_version_major=''
 db_version_minor=''
 db_version_patch=''
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 dlext='none'
 dlsrc='dl_none.xs'
index 1c08bd3..e6ca7fb 100644 (file)
@@ -583,6 +583,7 @@ db_prefixtype='size_t'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 dlext='dll'
 dlsrc='dl_symbian.xs'
index d2c6a48..1540513 100644 (file)
--- a/uconfig.h
+++ b/uconfig.h
  */
 /*#define HAS_WRITEV           / **/
 
+/* DEFAULT_INC_EXCLUDES_DOT:
+ *     This symbol, if defined, removes the legacy default behavior of
+ *     including '.' at the end of @INC.
+ */
+# DEFAULT_INC_EXCLUDES_DOT     /**/
+
 /* USE_DYNAMIC_LOADING:
  *     This symbol, if defined, indicates that dynamic loading of
  *     some sort is available.
index 3174bba..a7b2615 100644 (file)
@@ -574,6 +574,7 @@ db_prefixtype='size_t'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
 doublekind='3'
index 1eb7eac..27d4a18 100644 (file)
@@ -575,6 +575,7 @@ db_prefixtype='size_t'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct dirent'
 doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'
 doublekind='3'
index 47042d8..3005086 100644 (file)
@@ -624,6 +624,7 @@ db_prefixtype='int'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct direct'
 dlext='dll'
 dlsrc='dl_win32.xs'
index 34b670e..b726e7d 100644 (file)
@@ -625,6 +625,7 @@ db_prefixtype='int'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct direct'
 dlext='dll'
 dlltool='~ARCHPREFIX~dlltool'
index cfac6e7..5731b88 100644 (file)
@@ -625,6 +625,7 @@ db_prefixtype='int'
 db_version_major='0'
 db_version_minor='0'
 db_version_patch='0'
+default_inc_excludes_dot=''
 direntrytype='struct direct'
 dlext='dll'
 dlsrc='dl_win32.xs'