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

pp_gpwent - could skip shadow call when euid > 0 on linux #16637

Closed
p5pRT opened this issue Jul 17, 2018 · 11 comments
Closed

pp_gpwent - could skip shadow call when euid > 0 on linux #16637

p5pRT opened this issue Jul 17, 2018 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 17, 2018

Migrated from rt.perl.org#133388 (status was 'open')

Searchable as RT133388$

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

From @atoomic

Created by @atoomic

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”

atoomic#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

Perl Info

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

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

From @atoomic

Here's the suggested patch attached to the message

On Tue, 17 Jul 2018 11​:05​:25 -0700, atoomic@​cpan.org wrote​:

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”

atoomic#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​: c5b1997
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

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

From @atoomic

0001-skip-shadow-call-when-euid-0-on-linux.patch
From b6c147cd2c970a847fdde502af2f9423c103872d Mon Sep 17 00:00:00 2001
From: Nicolas R <atoomic@cpan.org>
Date: Mon, 16 Jul 2018 11:26:59 -0600
Subject: [PATCH] skip shadow call when euid > 0 on linux

maybe __linux__ is not restrictive enough
and we could consider using a hint sh file
to enable it only on some specific distro?
---
 pp_sys.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pp_sys.c b/pp_sys.c
index 4ae475d460..08b2752572 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -5562,7 +5562,11 @@ PP(pp_gpwent)
 	 * --jhi */
 	/* Some AIX setups falsely(?) detect some getspnam(), which
 	 * has a different API than the Solaris/IRIX one. */
+
 #   if defined(HAS_GETSPNAM) && !defined(_AIX)
+#      ifdef __linux__
+    if (!PerlProc_geteuid())
+#      endif
 	{
 	    dSAVE_ERRNO;
 	    const struct spwd * const spwent = getspnam(pwent->pw_name);
-- 
2.15.2 (Apple Git-101.1)

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

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

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

From @atoomic

Some basic benchmark using the attached file bench-getpw and the Porting/bench.pl tool

** when run as root ** close to no difference

./perl -Ilib Porting/bench.pl --benchfile=/tmp/bench-getpw ../perl2/perl=blead ./perl=blead+patch
Key​:
  Ir Instruction read
  Dr Data read
  Dw Data write
  COND conditional branches
  IND indirect branches
  _m branch predict miss
  _m1 level 1 cache miss
  _mm last cache (e.g. L3) miss
  - indeterminate percentage (e.g. 1/0)

The numbers represent relative counts per loop iteration, compared to
blead at 100.0%.
Higher is better​: for example, using half as many instructions gives 200%,
while using twice as many gives 50%.

getpwuid
getpwuid

  blead blead+patch
  ------ -----------
  Ir 100.00 99.92
  Dr 100.00 99.92
  Dw 100.00 99.93
  COND 100.00 99.94
  IND 100.00 98.99

COND_m 100.00 104.34
IND_m 100.00 97.37

Ir_m1 100.00 99.45
Dr_m1 100.00 100.00
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

getpwent
getpwent

  blead blead+patch
  ------ -----------
  Ir 100.00 99.97
  Dr 100.00 99.97
  Dw 100.00 99.97
  COND 100.00 99.98
  IND 100.00 99.39

COND_m 100.00 100.57
IND_m 100.00 97.29

Ir_m1 100.00 99.95
Dr_m1 100.00 110.53
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

getpwnam
getpwnam(root)

  blead blead+patch
  ------ -----------
  Ir 100.00 99.93
  Dr 100.00 99.92
  Dw 100.00 99.94
  COND 100.00 99.95
  IND 100.00 98.99

COND_m 100.00 102.59
IND_m 100.00 97.37

Ir_m1 100.00 99.95
Dr_m1 100.00 100.00
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

AVERAGE

  blead blead+patch
  ------ -----------
  Ir 100.00 99.94
  Dr 100.00 99.94
  Dw 100.00 99.94
  COND 100.00 99.96
  IND 100.00 99.12

COND_m 100.00 102.48
IND_m 100.00 97.34

Ir_m1 100.00 99.79
Dr_m1 100.00 103.28
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

** when run as non root ** this is where the improvement can be noticed

./perl -Ilib Porting/bench.pl --benchfile=/tmp/bench-getpw ../perl2/perl=blead ./perl=blead+patch
Key​:
  Ir Instruction read
  Dr Data read
  Dw Data write
  COND conditional branches
  IND indirect branches
  _m branch predict miss
  _m1 level 1 cache miss
  _mm last cache (e.g. L3) miss
  - indeterminate percentage (e.g. 1/0)

The numbers represent relative counts per loop iteration, compared to
blead at 100.0%.
Higher is better​: for example, using half as many instructions gives 200%,
while using twice as many gives 50%.

getpwuid
getpwuid

  blead blead+patch
  ------ -----------
  Ir 100.00 137.64
  Dr 100.00 130.24
  Dw 100.00 146.70
  COND 100.00 137.26
  IND 100.00 117.57

COND_m 100.00 211.55
IND_m 100.00 117.24

Ir_m1 100.00 1200.00
Dr_m1 100.00 100.00
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

getpwent
getpwent

  blead blead+patch
  ------ -----------
  Ir 100.00 117.19
  Dr 100.00 117.45
  Dw 100.00 122.08
  COND 100.00 116.20
  IND 100.00 115.85

COND_m 100.00 123.67
IND_m 100.00 114.08

Ir_m1 100.00 717.86
Dr_m1 100.00 130.00
Dw_m1 100.00 33.33

Ir_mm 100.00 -
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

getpwnam
getpwnam(root)

  blead blead+patch
  ------ -----------
  Ir 100.00 137.34
  Dr 100.00 129.98
  Dw 100.00 146.59
  COND 100.00 136.53
  IND 100.00 117.57

COND_m 100.00 211.11
IND_m 100.00 117.24

Ir_m1 100.00 1040.00
Dr_m1 100.00 100.00
Dw_m1 100.00 100.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

AVERAGE

  blead blead+patch
  ------ -----------
  Ir 100.00 129.99
  Dr 100.00 125.60
  Dw 100.00 137.43
  COND 100.00 129.22
  IND 100.00 116.99

COND_m 100.00 170.94
IND_m 100.00 116.17

Ir_m1 100.00 941.06
Dr_m1 100.00 108.33
Dw_m1 100.00 60.00

Ir_mm 100.00 100.00
Dr_mm 100.00 100.00
Dw_mm 100.00 100.00

On Tue, 17 Jul 2018 12​:02​:43 -0700, atoomic wrote​:

Here's the suggested patch attached to the message

On Tue, 17 Jul 2018 11​:05​:25 -0700, atoomic@​cpan.org wrote​:

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”

atoomic#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​: c5b1997
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

@p5pRT
Copy link
Author

p5pRT commented Jul 17, 2018

From @atoomic

bench-getpw

@p5pRT
Copy link
Author

p5pRT commented Jul 18, 2018

From @iabyn

On Tue, Jul 17, 2018 at 11​:05​:25AM -0700, Nicolas R. (via RT) wrote​:

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”

Is this really a performance critical function? I'd be reluctant to add
extra complexity and platform-specific hard coding to an already complex
function?

--
My get-up-and-go just got up and went.

@toddr
Copy link
Member

toddr commented Oct 20, 2019

Suggested pull request is at #16

atoomic added a commit to atoomic/perl5 that referenced this issue Oct 20, 2019
Resolves Perl#16637

maybe __linux__ is not restrictive enough
and we could consider using a hint sh file
to enable it only on some specific distro?
@Leont
Copy link
Contributor

Leont commented Oct 20, 2019

Is this really a performance critical function? I'd be reluctant to add
extra complexity and platform-specific hard coding to an already complex
function?

Agreed. Also, I'm not so sure the logic is correct, or that it's easy to get it correct (e.g. correct may change over time)

@khwilliamson
Copy link
Contributor

Can we close this?

@jkeenan
Copy link
Contributor

jkeenan commented Apr 17, 2022

Can we close this?

The associated pull request was closed (withdrawn) on Oct 31 2019. So, yes, this is closable; doing so now.

@jkeenan jkeenan closed this as completed Apr 17, 2022
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

6 participants