summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2005-08-10 12:10:26 +0000
committerespie <espie@openbsd.org>2005-08-10 12:10:26 +0000
commit2483d4068fe704f7dce01083ac765adf3c5f8748 (patch)
tree630d5ebd62d852c9309e3202b5046d8a8753d241
parentbug fix: if default is not available, do not push it for installation. (diff)
downloadwireguard-openbsd-2483d4068fe704f7dce01083ac765adf3c5f8748.tar.xz
wireguard-openbsd-2483d4068fe704f7dce01083ac765adf3c5f8748.zip
record unsafe operations in a journal, so that we can give a much
more specific message than `package XXX contains unsafe operations'.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm48
1 files changed, 37 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 5ed22ee32c0..dc32889de4e 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.52 2005/07/26 09:16:48 espie Exp $
+# $OpenBSD: Update.pm,v 1.53 2005/08/10 12:10:26 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -25,8 +25,11 @@ sub can_update
{
my ($self, $install, $state) = @_;
- if (!$self->updatable($install)) {
+ my $issue = $self->update_issue($install);
+
+ if (defined $issue) {
$state->{okay} = 0;
+ push(@{$state->{journal}}, $issue);
}
}
@@ -34,7 +37,7 @@ sub validate_depend
{
}
-sub updatable($$) { 1 }
+sub update_issue($$) { undef }
sub extract
{
@@ -109,29 +112,44 @@ sub extract
}
package OpenBSD::PackingElement::ScriptFile;
-sub updatable($$) { 0 }
+sub update_issue($$)
+{
+ return $_[0]->{name}." script";
+}
package OpenBSD::PackingElement::FINSTALL;
-sub updatable($$) { !$_[1] }
+sub update_issue($$)
+{
+ return undef if !$_[1];
+ return $_[0]->SUPER::update_issue($_[1]);
+}
package OpenBSD::PackingElement::FDEINSTALL;
-sub updatable($$) { $_[1] }
+sub update_issue($$)
+{
+ return undef if $_[1];
+ return $_[0]->SUPER::update_issue($_[1]);
+}
package OpenBSD::PackingElement::Exec;
-sub updatable($$) { !$_[1] }
+sub update_issue($$)
+{
+ return undef if !$_[1];
+ return '@exec '.$_[0]->{expanded};
+}
package OpenBSD::PackingElement::Unexec;
-sub updatable($$)
+sub update_issue($$)
{
- return 1 if $_[1];
+ return undef if $_[1];
my $self = $_[0];
# those are deemed innocuous
if ($self->{expanded} =~ m|^/sbin/ldconfig\s+\-R\b| or
$self->{expanded} =~ m|^install-info\s+\-\-delete\b|) {
- return 1;
+ return undef;
} else {
- return 0;
+ return '@unexec '.$self->{expanded};
}
}
@@ -256,9 +274,13 @@ sub can_do
if (!defined $plist) {
Fatal "Couldn't find packing-list for $toreplace\n";
}
+ $state->{journal} = [];
$plist->visit('can_update', 0, $state);
if ($state->{okay} == 0) {
Warn "Old package ", $plist->pkgname(), " contains unsafe operations\n";
+ for my $i (@{$state->{journal}}) {
+ Warn "\t$i\n";
+ }
if ($state->{forced}->{update}) {
Warn "(forcing update)\n";
$state->{okay} = 1;
@@ -299,10 +321,14 @@ sub is_safe
{
my ($plist, $state) = @_;
$state->{okay} = 1;
+ $state->{journal} = [];
$plist->visit('can_update', 1, $state);
if ($state->{okay} == 0) {
Warn "New package ", $plist->pkgname(),
" contains unsafe operations\n";
+ for my $i (@{$state->{journal}}) {
+ Warn "\t$i\n";
+ }
if ($state->{forced}->{update}) {
Warn "(forcing update)\n";
$state->{okay} = 1;