-
Notifications
You must be signed in to change notification settings - Fork 577
pp_gpwent - could skip shadow call when euid > 0 on linux #16637
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
Comments
From @atoomicCreated by @atoomicThe perl implementation of getpw* (pp_gpwent) does a calls to both the Here is an attempt to avoid this extra check on some "known platforms” I'm not sure if __linux__ is the best preprocessor check here. Is it too I will attach the patch and some benchmark metrics in a future reply to Perl Info
|
From @atoomicHere's the suggested patch attached to the message On Tue, 17 Jul 2018 11:05:25 -0700, atoomic@cpan.org wrote:
|
From @atoomic0001-skip-shadow-call-when-euid-0-on-linux.patchFrom 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)
|
The RT System itself - Status changed from 'new' to 'open' |
From @atoomicSome 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 The numbers represent relative counts per loop iteration, compared to getpwuid blead blead+patch COND_m 100.00 104.34 Ir_m1 100.00 99.45 Ir_mm 100.00 100.00 getpwent blead blead+patch COND_m 100.00 100.57 Ir_m1 100.00 99.95 Ir_mm 100.00 100.00 getpwnam blead blead+patch COND_m 100.00 102.59 Ir_m1 100.00 99.95 Ir_mm 100.00 100.00 AVERAGE blead blead+patch COND_m 100.00 102.48 Ir_m1 100.00 99.79 Ir_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 The numbers represent relative counts per loop iteration, compared to getpwuid blead blead+patch COND_m 100.00 211.55 Ir_m1 100.00 1200.00 Ir_mm 100.00 100.00 getpwent blead blead+patch COND_m 100.00 123.67 Ir_m1 100.00 717.86 Ir_mm 100.00 - getpwnam blead blead+patch COND_m 100.00 211.11 Ir_m1 100.00 1040.00 Ir_mm 100.00 100.00 AVERAGE blead blead+patch COND_m 100.00 170.94 Ir_m1 100.00 941.06 Ir_mm 100.00 100.00 On Tue, 17 Jul 2018 12:02:43 -0700, atoomic wrote:
|
From @atoomic |
From @iabynOn Tue, Jul 17, 2018 at 11:05:25AM -0700, Nicolas R. (via RT) wrote:
Is this really a performance critical function? I'd be reluctant to add -- |
Suggested pull request is at #16 |
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?
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) |
Can we close this? |
The associated pull request was closed (withdrawn) on Oct 31 2019. So, yes, this is closable; doing so now. |
Migrated from rt.perl.org#133388 (status was 'open')
Searchable as RT133388$
The text was updated successfully, but these errors were encountered: