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

"@" symbol in directory path results in syntax error in Config_heavy.pl #22446

Closed
ZRE-Services opened this issue Jul 30, 2024 · 5 comments
Closed

Comments

@ZRE-Services
Copy link

ZRE-Services commented Jul 30, 2024

Description

Using a directory path with "@" in a Ubuntu system causes a syntax error. The "@" symbol is interpreted as a variable instead of a part of the directory name.

Steps to Reproduce

Set a directory path containing "@" and attempt to use it in a Perl script.
Example path: /home/bioinformatics@example.de/miniconda3/envs/bismark/lib/perl5/5.32/core_perl/Config_heavy.pl

Expected behavior
The path should be recognized correctly, and no syntax error should occur.

perl -V output goes here

Summary of my perl5 (revision 5 version 32 subversion 1) configuration:
   
  Platform:
    osname=linux
    osvers=6.2.0-1018-azure
    archname=x86_64-linux-thread-multi
    uname='linux a9829a0f1755 6.2.0-1018-azure #18~22.04.1-ubuntu smp tue nov 21 19:25:02 utc 2023 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark -Dvendorprefix=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark -Dscriptdir=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin -Dsitescript=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin -Dvendorscript=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin -Duserelocatableinc -Duseshrplib -Dinc_version_list=none -Dprivlib=.../../lib/perl5/core_perl -Dsitelib=.../../lib/perl5/site_perl -Dvendorlib=.../../lib/perl5/vendor_perl -Darchlib=.../../lib/perl5/5.32/core_perl -Dsitearch=.../../lib/perl5/5.32/site_perl -Dvendorarch=.../../lib/perl5/5.32/vendor_perl -Dinstallusrbinperl=n -Dusethreads -Dcccdlflags=-fPIC -Dldflags=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -Wl,-rpath-link,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -L/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib  -Ddefault_inc_excludes_dot=n -Dccflags=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/perl_1703310062586/work=/usr/local/src/conda/perl-5.32.1 -fdebug-prefix-map=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark=/usr/local/src/conda-prefix -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Dcc=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//bin/x86_64-conda-linux-gnu-gcc -Dar=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//bin/x86_64-conda-linux-gnu-ar -Dlddlflags=-shared -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -Wl,-rpath-link,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -L/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -Dsysroot=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot -Dmyhostname=conda -Dmydomain=.conda -Dperladmin=conda -Dcf_by=conda -Dcf_email=conda -Dsysman=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/man/man1 -Dman1dir=.../../man/man1 -Dman3dir=.../../man/man3'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=undef
    bincompat5005=undef
  Compiler:
    cc='/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//bin/x86_64-conda-linux-gnu-gcc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/perl_1703310062586/work=/usr/local/src/conda/perl-5.32.1 -fdebug-prefix-map=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark=/usr/local/src/conda-prefix -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'undef/miniconda3/envs/bismark/lib/perl5/5.32/core_perl/Config_heavy.pl
    optimize='-O2'
    cppflags='--sysroot=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot -D_REENTRANT -D_GNU_SOURCE -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/perl_1703310062586/work=/usr/local/src/conda/perl-5.32.1 -fdebug-prefix-map=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark=/usr/local/src/conda-prefix -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    ccversion=''
    gccversion='12.3.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//bin/x86_64-conda-linux-gnu-gcc'
    ldflags ='-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -Wl,-rpath-link,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -L/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib  -fstack-protector-strong'
    libpth=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//bin/../lib/gcc/x86_64-conda-linux-gnu/12.3.0/include-fixed /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot/usr/lib /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot/lib /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot/lib64 /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot/usr/lib64
    libs=-lpthread -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/../lib/perl5/5.32/core_perl/CORE'
    cccdlflags='-fPIC --sysroot=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot'
    lddlflags='-shared -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -Wl,-rpath-link,/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib -L/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib --sysroot=/home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/bin/..//x86_64-conda-linux-gnu/sysroot -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under linux
  Compiled at Dec 23 2023 05:47:44
  @INC:
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/5.32/site_perl
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/site_perl
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/5.32/vendor_perl
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/vendor_perl
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/5.32/core_perl
    /home/bioinformatics@zymoresearch.de/miniconda3/envs/bismark/lib/perl5/core_perl
    .

@mauke
Copy link
Contributor

mauke commented Jul 30, 2024

What do you mean by 'Set a directory path containing "@"'?

@ZRE-Services ZRE-Services changed the title "@" in path results in synthax error in Config_heavy.pl "@" symbol in directory path results in synthax error in Config_heavy.pl Jul 30, 2024
@ZRE-Services
Copy link
Author

What do you mean by 'Set a directory path containing "@"'?

For reasons out of my control, on our ubuntu system the user folders within the home directory are named according to the users email adress (e.g. /home/bioinformatics@zymoresearch.de/) and therefore contain the symbol "@". When using Perl in this environment, the file Config_heavy.pl contains many directory paths that all start with "/home/bioinformatics@zymoresearch.de/". These paths are not correctly recognized as literal directory paths, but the contained "@" symbol seems to lead to the issue that "@zymoresearch" is recognized as a variable and not a string.

Please let me know if this is unclear still. I'll be happy to give futher details and to describe the workaround that i used to make things work for me

@mauke
Copy link
Contributor

mauke commented Jul 30, 2024

I created a path with a @ in it:

$ mkdir -p ~/tmp/hello@world
$ cd ~/tmp/hello@world

Then I used perl in this directory:

$ perl -wE 'say "hi"'
hi
$ pwd
/home/mauke/tmp/hello@world

No errors.

@jkeenan jkeenan changed the title "@" symbol in directory path results in synthax error in Config_heavy.pl "@" symbol in directory path results in syntax error in Config_heavy.pl Jul 30, 2024
@ZRE-Services
Copy link
Author

I should have recreated the bug reliably before opening the issue.
I was only able to recreate the issue using the package manager/virtual env tool conda (see below)
Feel free to close the issue, it might be better placed at conda or bowtie2

# install conda 
# create new conda environment within directory that contains "@"
(base) bioinformatics@zymo-hilde01:/home$ conda create -n perl_bug
# activate environment
(base) bioinformatics@zymo-hilde01:/home$ conda activate perl_bug
# install perl
(perl_bug) bioinformatics@zymo-hilde01:/home$ conda install perl
# install the popular DNA alignment tool bowtie2
(perl_bug) bioinformatics@zymo-hilde01:/home$ conda install bowtie2
# testing bowtie2 results in error message regarding Config_heavy.pl
(perl_bug) bioinformatics@zymo-hilde01:/home$ bowtie2 --help
Possible unintended interpolation of @zymoresearch in string at /home/bioinformatics@zymoresearch.de/miniconda3/envs/perl_bug/lib/perl5/5.32/core_perl/Config_heavy.pl line 246.
[...]
Global symbol "@zymoresearch" requires explicit package name (did you forget to declare "my @zymoresearch"?) at /home/bioinformatics@zymoresearch.de/miniconda3/envs/perl_bug/lib/perl5/5.32/core_perl/Config_heavy.pl line 246.

@jkeenan
Copy link
Contributor

jkeenan commented Jul 30, 2024

I should have recreated the bug reliably before opening the issue. I was only able to recreate the issue using the package manager/virtual env tool conda (see below) Feel free to close the issue, it might be better placed at conda or bowtie2

# install conda 
# create new conda environment within directory that contains "@"
(base) bioinformatics@zymo-hilde01:/home$ conda create -n perl_bug
# activate environment
(base) bioinformatics@zymo-hilde01:/home$ conda activate perl_bug
# install perl
(perl_bug) bioinformatics@zymo-hilde01:/home$ conda install perl
# install the popular DNA alignment tool bowtie2
(perl_bug) bioinformatics@zymo-hilde01:/home$ conda install bowtie2
# testing bowtie2 results in error message regarding Config_heavy.pl
(perl_bug) bioinformatics@zymo-hilde01:/home$ bowtie2 --help
Possible unintended interpolation of @zymoresearch in string at /home/bioinformatics@zymoresearch.de/miniconda3/envs/perl_bug/lib/perl5/5.32/core_perl/Config_heavy.pl line 246.
[...]
Global symbol "@zymoresearch" requires explicit package name (did you forget to declare "my @zymoresearch"?) at /home/bioinformatics@zymoresearch.de/miniconda3/envs/perl_bug/lib/perl5/5.32/core_perl/Config_heavy.pl line 246.

I downloaded a tarball of perl-5.40, unpacked it, and built it in a directory containing an @ sign.

$ sh ./Configure -des -Dprefix=/tmp/bioinformatics@zymoresearch.de && make install

I inspected the resulting ./lib/perl5/5.40.0/x86_64-linux/Config_heavy.pl.

$ grep -n 'prefix=' ./lib/perl5/5.40.0/x86_64-linux/Config_heavy.pl
248:config_arg2='-Dprefix=/tmp/bioinformatics@zymoresearch.de'
250:config_args='-des -Dprefix=/tmp/bioinformatics@zymoresearch.de'
1037:installprefix='/tmp/bioinformatics@zymoresearch.de'
1181:prefix='/tmp/bioinformatics@zymoresearch.de'
1265:siteprefix='/tmp/bioinformatics@zymoresearch.de'
1375:usevendorprefix='undef'
1401:vendorprefix=''

I then installed a couple of modules with the corresponding cpan. They installed correctly.

So I agree with you that the problem is not with perl. Closing. Thanks for the report.

@jkeenan jkeenan closed this as completed Jul 30, 2024
mauke added a commit to mauke/perl5 that referenced this issue Jul 30, 2024
If you build and test perl from a directory whose name contains an `@`
sign (such as `/tmp/hello@world/perl5`, one of the tests in
`t/io/pipe.t` fails.

This is because it takes the path to the perl binary (which is
`/tmp/hello@world/perl5/perl` in our example) and interpolates it in
double-quotes into a string that is then eval'd and run (via
`fresh_perl()`). Thus the code that the interpreter in the child process
sees is:

    $Perl = "/tmp/hello@world/perl5/perl";

which of course tries to interpolate the (non-existent) `@world` array.
(Similar problems would be caused by paths containing `$` or `"`
characters).

Switching to single quotes, as in

    $Perl = '/tmp/hello@world/perl5/perl';

would fix this case, but would still be vulnerable to a path containing
`'` symbols.

Sidestep the problem by using `q` (to prevent variable interpolation)
with a NUL byte delimiter (which cannot occur in path names).

Found while investigating Perl#22446.
mauke added a commit to mauke/perl5 that referenced this issue Jul 31, 2024
If you build and test perl from a directory whose name contains an `@`
sign (such as `/tmp/hello@world/perl5`), one of the tests in
`t/io/pipe.t` fails.

This is because it takes the path to the perl binary (which is
`/tmp/hello@world/perl5/perl` in our example) and interpolates it in
double-quotes into a string that is then eval'd and run (via
`fresh_perl()`). Thus the code that the interpreter in the child process
sees is:

    $Perl = "/tmp/hello@world/perl5/perl";

which of course tries to interpolate the (non-existent) `@world` array.
(Similar problems would be caused by paths containing `$` or `"`
characters).

Switching to single quotes, as in

    $Perl = '/tmp/hello@world/perl5/perl';

would fix this case, but would still be vulnerable to a path containing
`'` symbols.

Sidestep the problem by using `q` (to prevent variable interpolation)
with a NUL byte delimiter (which cannot occur in path names).

Found while investigating Perl#22446.
mauke added a commit that referenced this issue Jul 31, 2024
If you build and test perl from a directory whose name contains an `@`
sign (such as `/tmp/hello@world/perl5`), one of the tests in
`t/io/pipe.t` fails.

This is because it takes the path to the perl binary (which is
`/tmp/hello@world/perl5/perl` in our example) and interpolates it in
double-quotes into a string that is then eval'd and run (via
`fresh_perl()`). Thus the code that the interpreter in the child process
sees is:

    $Perl = "/tmp/hello@world/perl5/perl";

which of course tries to interpolate the (non-existent) `@world` array.
(Similar problems would be caused by paths containing `$` or `"`
characters).

Switching to single quotes, as in

    $Perl = '/tmp/hello@world/perl5/perl';

would fix this case, but would still be vulnerable to a path containing
`'` symbols.

Sidestep the problem by using `q` (to prevent variable interpolation)
with a NUL byte delimiter (which cannot occur in path names).

Found while investigating #22446.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants