summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorpxm@nubz.org <pxm@nubz.org>2003-10-05 20:55:56 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-10-12 19:58:05 +0000
commit75870ed3a2061db7a09c0f054d3cc6b0d00f0b51 (patch)
treecc39d6297712df5263f8735d4bc42ac3a5ec01d2 /mg.c
parent15634f32600dfd7c267231a107a89655e6a68433 (diff)
downloadperl-75870ed3a2061db7a09c0f054d3cc6b0d00f0b51.tar.gz
[perl #24122] setreuid and friends borked on darwin/osx
From: "pxm@nubz.org (via RT)" <perlbug-followup@perl.org> Message-ID: <rt-24122-65678.14.2411168523081@rt.perl.org> p4raw-id: //depot/perl@21440
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index df75970be2..bcb0188f8b 100644
--- a/mg.c
+++ b/mg.c
@@ -2240,9 +2240,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");
}