summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository.pm23
1 files changed, 8 insertions, 15 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
index dfaacebab2b..40f14418dce 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageRepository.pm,v 1.121 2016/04/16 11:00:42 espie Exp $
+# $OpenBSD: PackageRepository.pm,v 1.122 2016/04/25 10:45:54 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -577,17 +577,21 @@ our @ISA=qw(OpenBSD::PackageRepository::Distant);
our %distant = ();
-sub try_drop
+sub drop_privileges_and_setup_env
{
- my ($self, $user) = @_;
+ my $self = shift;
+ my $user = '_pkgfetch';
+ # we can't cache anything, we happen after the fork,
+ # right before exec
if (my (undef, undef, $uid, $gid) = getpwnam($user)) {
$( = $gid;
$) = "$gid $gid";
$< = $uid;
$> = $uid;
} else {
- return 0;
+ $self->{state}->fatal("Couldn't change identity: can't find #1 user", $user);
}
+
# create sanitized env for ftp
my %newenv = (
HOME => '/var/empty',
@@ -618,17 +622,6 @@ sub try_drop
}
# don't forget to swap!
%ENV = %newenv;
- return 1;
-}
-
-sub drop_privileges_and_setup_env
-{
- my $self = shift;
- my $u1 = '_pkgfetch';
- my $u2 = '_pfetch';
- $self->try_drop($u1) or $self->try_drop($u2) or
- $self->{state}->fatal(
- "Couldn't change identity: missing #1 and #2 users", $u1, $u2);
}