develooper Front page | perl.perl5.porters | Postings from July 2018

[perl #133388] pp_gpwent - could skip shadow call when euid > 0 onlinux

Thread Previous | Thread Next
From:
Nicolas R.
Date:
July 17, 2018 18:05
Subject:
[perl #133388] pp_gpwent - could skip shadow call when euid > 0 onlinux
Message ID:
rt-4.0.24-4950-1531850725-1485.133388-75-0@perl.org
# New Ticket Created by  Nicolas R. 
# Please include the string:  [perl #133388]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133388 >


This is a bug report for perl from atoomic@cpan.org,
generated with the help of perlbug 1.40 running under perl 5.26.2.


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

The perl implementation of getpw* (pp_gpwent) does a calls to both the
normal getpw*() functions and getspnam(). When EUID !=0, the shadow file
will be unreadable, so this second getspnam() call is just wasted effort.
The comments in pp_gpwent acknowledge this fact, but make the call anyway
to handle platforms where the EUID is meaningless.

Here is an attempt to avoid this extra check on some "known platforms”

https://github.com/atoomic/perl5/pull/6

I'm not sure if __linux__ is the best preprocessor check here. Is it too
wide? Can we assume all linux platform will behave the same? Should not we
also add __APPLE__ ?

I will attach the patch and some benchmark metrics in a future reply to
this thread

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.26.2:

Configured by nicolas at Fri Apr 20 11:44:33 CEST 2018.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration:
  Commit id: c5b1997939178730653db9e80f90cd53d722fe8d
  Platform:
    osname=darwin
    osvers=17.5.0
    archname=darwin-2level
    uname='darwin macnico.local 17.5.0 darwin kernel version 17.5.0: mon
mar 5 22:24:32 pst 2018; root:xnu-4570.51.1~1release_x86_64 x86_64 '
    config_args='-Dcc=ccache gcc -Dusedevel -Doptimize=-g3 -des'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='ccache gcc'
    ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
-mmacosx-version-min=10.13 -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-g3'
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp
-mmacosx-version-min=10.13 -fno-strict-aliasing -pipe
-fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)'
    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='ccache gcc'
    ldflags =' -mmacosx-version-min=10.13 -fstack-protector-strong
-L/usr/local/lib'
    libpth=/usr/local/lib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.1.0/lib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib
/usr/lib
    libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.13 -bundle -undefined
dynamic_lookup -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.26.2:
    lib
    .
    /Users/nicolas/.dotfiles/perl-must-have/lib
    /Users/nicolas/perl5/lib/perl5/
    /usr/local/lib/perl5/site_perl/5.26.2/darwin-2level
    /usr/local/lib/perl5/site_perl/5.26.2
    /usr/local/lib/perl5/5.26.2/darwin-2level
    /usr/local/lib/perl5/5.26.2

---
Environment for perl 5.26.2:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/nicolas
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=/Users/nicolas/perl5/perlbrew/bin:/Users/nicolas/perl5/perlbrew/perls/perl-5.26.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/usr/local/git/bin:/Users/nicolas/.dotfiles/bin:/Users/nicolas/perl5/bin:/Applications/Rakudo/bin:/Applications/Rakudo/share/perl6/site/bin
    PERL5DB=use Devel::NYTProf

PERL5LIB=/Users/nicolas/.dotfiles/perl-must-have/lib:/Users/nicolas/perl5/lib/perl5/
    PERLBREW_HOME=/Users/nicolas/.perlbrew
    PERLBREW_MANPATH=/Users/nicolas/perl5/perlbrew/perls/perl-5.26.1/man

PERLBREW_PATH=/Users/nicolas/perl5/perlbrew/bin:/Users/nicolas/perl5/perlbrew/perls/perl-5.26.1/bin
    PERLBREW_PERL=perl-5.26.1
    PERLBREW_ROOT=/Users/nicolas/perl5/perlbrew
    PERLBREW_SHELLRC_VERSION=0.82
    PERLBREW_VERSION=0.82
    PERL_BADLANG (unset)
    PERL_CPANM_OPT=--quiet
    SHELL=/bin/zsh


Thread Previous | Thread Next


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