Lines 926-935
Link Here
|
926 |
|
926 |
|
927 |
sub setuid_to_euid { |
927 |
sub setuid_to_euid { |
928 |
return if (RUNNING_ON_WINDOWS); |
928 |
return if (RUNNING_ON_WINDOWS); |
929 |
if ($< != $>) { |
929 |
|
930 |
dbg ("setting real uid from $< to match effective uid $>"); |
930 |
# remember the target uid, the first number is the important one |
931 |
$< = $>; |
931 |
my($touid) = split(/\s+/, $>); |
932 |
if ($< != $>) { die "setuid $< to $> failed!"; } |
932 |
|
|
|
933 |
if ($< != $touid) { |
934 |
dbg ("changing real uid from $< to match effective uid $touid"); |
935 |
$< = $touid; # try the simple method first |
936 |
|
937 |
# bug 3586: Some perl versions, typically those on a BSD-based |
938 |
# platform, require RUID==EUID (and presumably == 0) before $< |
939 |
# can be changed. So this is a kluge for us to get around the |
940 |
# typical spamd-ish behavior of: $< = 0, $> = someuid ... |
941 |
if ( $< != $touid ) { |
942 |
dbg("initial attempt to change real uid failed, trying BSD workaround"); |
943 |
|
944 |
$> = $<; # revert euid to ruid |
945 |
$< = $touid; # change ruid to target |
946 |
$> = "$touid $touid"; # change euid back to target |
947 |
} |
948 |
|
949 |
# Check that we have now accomplished the setuid |
950 |
if ($< != $touid) { |
951 |
die "setuid $< to $touid failed!"; |
952 |
} |
933 |
} |
953 |
} |
934 |
} |
954 |
} |
935 |
|
955 |
|