summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2020-01-09 11:01:25 +0000
committerespie <espie@openbsd.org>2020-01-09 11:01:25 +0000
commit8660d718516063aff6b9fd707e94d58f988beba2 (patch)
tree31a8448b8b57a449218174136b230635caaa0649 /usr.sbin/pkg_add
parentCleanup ioctl(2) list. FIONBIO, FIOASYNC and FIONREAD are not defined (diff)
downloadwireguard-openbsd-8660d718516063aff6b9fd707e94d58f988beba2.tar.xz
wireguard-openbsd-8660d718516063aff6b9fd707e94d58f988beba2.zip
have ask_tree be more specific in its error reporting.
make sure the child has the same effective and real ids, as perl interprets it as "setuid, refuse to debug" go to the end of the pipe so the child doesn't exit prematurely (didn't use to happen but now it does) help from afresh1@ in diagnosing that one.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index 1feddbc76a0..40c2f106f0f 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.164 2019/11/07 15:36:51 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.165 2020/01/09 11:01:25 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -990,24 +990,33 @@ sub ask_tree
$state->fatal("cannot fork: $!");
}
if ($pid == 0) {
- # make things debuggable because this child doesn't matter
- $DB::inhibit_exit = 0;
- chdir $portsdir or exit 2;
- open STDERR, ">>", $errors;
$ENV{FULLPATH} = 'Yes';
delete $ENV{FLAVOR};
delete $ENV{SUBPACKAGE};
$ENV{SUBDIR} = $pkgpath;
$ENV{ECHO_MSG} = ':';
+
+ if (!chdir $portsdir) {
+ $state->errsay("Can't chdir #1: #2", $portsdir, $!);
+ exit(2);
+ }
+ open STDERR, ">>", $errors;
+ # make sure the child starts with a single identity
+ $( = $); $< = $>;
# XXX we're already running as ${BUILD_USER}
# so we can't do this again
push(@action, 'PORTS_PRIVSEP=No');
+ $DB::inhibit_exit = 0;
exec $make ('make', @action);
}
my $plist = OpenBSD::PackingList->read($fh, $data);
+ while(<$fh>) { # XXX avoid spurious errors from child
+ }
close($fh);
if ($? != 0) {
- $state->errsay("child failed: #1", $state->child_error);
+ $state->errsay("child running '#2' failed: #1",
+ $state->child_error,
+ join(' ', 'make', @action));
if (open my $fh, '<', $errors) {
while(<$fh>) {
$state->errprint("#1", $_);