develooper Front page | perl.perl5.porters | Postings from January 2022

pwent.t fails if /etc/passwd is not readable

From:
lembark
Date:
January 21, 2022 23:58
Subject:
pwent.t fails if /etc/passwd is not readable
Message ID:
5.34.0_25377_1642618863@jeeves.wrkhors.com

This is a bug report for perl from lembark@wrkhors.com,
generated with the help of perlbug 1.42 running under perl 5.34.0.


-----------------------------------------------------------------
[Please describe your issue here]

t/op/pwent.t includes a sanity check for /etc/passwd not existing.
It lacks a test for the file not being readalble, which is fairly
common these days in order to make RHEL distributions less usable
and maintainable. The 0700 mods leaves pwent.t failing when it
tries to open the file.
       
The fix is pretty simple: Add a test for readable /etc/passwd:
       
$ git diff t/op/pwent.t
diff --git a/t/op/pwent.t b/t/op/pwent.t
index e1fc1e1235..95cf1d2665 100644
--- a/t/op/pwent.t
+++ b/t/op/pwent.t
@@ -124,6 +124,8 @@ if (not defined $where) {
     if (!-f $PW) {
	skip_all($no_i_pwd) if $no_i_pwd;
	skip_all("no $PW file");
+    } elsif (!-r $PW) {
+	skip_all("non-readable $PW file");
     } elsif (open PW, '<', $PW) {
	if(defined <PW>) {
	    $where = $PW;
       
 
I've labled this as "high" becuase it prevents installing Perl
in our environment. This is also a pretty easy patch to test.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=install
    severity=high
---
This perlbug was built using Perl 5.34.0 - Wed Jan 19 13:43:18 EST 2022
It is being executed now by  Perl 5.34.0 - Sat Nov 27 14:21:10 EST 2021.

Site configuration information for perl 5.34.0:

Configured by root at Sat Nov 27 14:21:10 EST 2021.

Summary of my perl5 (revision 5 version 34 subversion 0) configuration:
  Commit id: 79a7b254d85a10b65126ad99bf10e70480569d68
  Platform:
    osname=linux
    osvers=5.10.61-gentoo-x86_64
    archname=x86_64-linux
    uname='linux dizzy 5.10.61-gentoo-x86_64 #1 smp sun oct 3 17:34:21 utc 2021 x86_64 amd opteron(tm) processor 6172 authenticamd gnulinux '
    config_args='-des -Duseshrplib -Dprefix=/opt/perl/5.34 -Doptimize=-O3 -march=native -pipe'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O3 -march=native -pipe'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='11.2.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='cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /lib64 /usr/lib64 /lib /usr/local/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.33.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.33'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/opt/perl/5.34/lib/5.34.0/x86_64-linux/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -O3 -march=native -pipe -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.34.0:
    /opt/perl/5.34/lib/site_perl/5.34.0/x86_64-linux
    /opt/perl/5.34/lib/site_perl/5.34.0
    /opt/perl/5.34/lib/5.34.0/x86_64-linux
    /opt/perl/5.34/lib/5.34.0

---
Environment for perl 5.34.0:
    HOME=/home/lembark
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ALL=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/var/lib/image/bin:/opt/bin:/usr/lib/llvm/8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/13/bin:/usr/lib/llvm/9/bin
    PERL_BADLANG (unset)
    PERL_CPANM_HOME=/home/lembark/tmp/cpan
    PERL_CPANM_OPT=--save-dists=/var/lib/CPAN
    SHELL=/bin/bash



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About