This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorNicholas Clark <nick@ccl4.org>
Sun, 19 Oct 2003 17:55:17 +0000 (17:55 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 19 Oct 2003 17:55:17 +0000 (17:55 +0000)
[ 21438]
Subject: Re: [perl #24122] setreuid and friends borked on darwin/osx
From: Slaven Rezic <slaven@rezic.de>
Date: 07 Oct 2003 00:04:34 +0200
Message-ID: <87ekxq6n0t.fsf@vran.herceg.de>

[ 21440]
Subject: [perl #24122] setreuid and friends borked on darwin/osx
From: "pxm@nubz.org (via RT)" <perlbug-followup@perl.org>
Date: 5 Oct 2003 20:55:56 -0000
Message-ID: <rt-24122-65678.14.2411168523081@rt.perl.org>
p4raw-link: @21440 on //depot/perl: 75870ed3a2061db7a09c0f054d3cc6b0d00f0b51
p4raw-link: @21438 on //depot/perl: 0cad7ed8738f312f479a2c3ee36c6cc1b76d037e

p4raw-id: //depot/maint-5.8/perl@21494
p4raw-integrated: from //depot/perl@21493 'merge in' hints/darwin.sh
(@20733..) mg.c (@21360..)

hints/darwin.sh
mg.c

index c1e3bad..b7266b4 100644 (file)
@@ -13,6 +13,12 @@ perl_version=`awk '/define[  ]+PERL_VERSION/ {print $3}' $src/patchlevel.h`
 perl_subversion=`awk '/define[         ]+PERL_SUBVERSION/ {print $3}' $src/patchlevel.h`
 version="${perl_revision}.${perl_version}.${perl_subversion}"
 
+# Pretend that Darwin doesn't know about those system calls [perl #24122]
+d_setregid='undef'
+d_setreuid='undef'
+d_setrgid='undef'
+d_setruid='undef'
+
 # This was previously used in all but causes three cases
 # (no -Ddprefix=, -Dprefix=/usr, -Dprefix=/some/thing/else)
 # but that caused too much grief.
diff --git a/mg.c b/mg.c
index 4926c5a..66b7ff1 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2251,9 +2251,14 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
 #ifdef HAS_SETRESUID
       (void)setresuid((Uid_t)PL_uid, (Uid_t)-1, (Uid_t)-1);
 #else
-       if (PL_uid == PL_euid)          /* special case $< = $> */
+       if (PL_uid == PL_euid) {                /* special case $< = $> */
+#ifdef PERL_DARWIN
+           /* workaround for Darwin's setuid peculiarity, cf [perl #24122] */
+           if (PL_uid != 0 && PerlProc_getuid() == 0)
+               (void)PerlProc_setuid(0);
+#endif
            (void)PerlProc_setuid(PL_uid);
-       else {
+       else {
            PL_uid = PerlProc_getuid();
            Perl_croak(aTHX_ "setruid() not implemented");
        }