diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-04-30 11:23:23 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-04-30 11:23:23 +0000 |
commit | d27d34271834fbf6068ab232b7164336eb13582c (patch) | |
tree | b588359627c65996579d954e9d7d3739bad40d34 /usr.sbin/pkg_add | |
parent | 3e616ce66cf9bec72086fbc507867a0fe9605ee7 (diff) |
archive special files exactly like we archive normal files. This provides
for more checks in very fishy cases (like if we end up with /var/db belonging
to the wrong person).
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index 0f1d6723a18..486daef1653 100644 --- a/usr.sbin/pkg_add/pkg_create +++ b/usr.sbin/pkg_add/pkg_create @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_create,v 1.76 2007/04/30 11:12:54 espie Exp $ +# $OpenBSD: pkg_create,v 1.77 2007/04/30 11:23:22 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -132,6 +132,38 @@ sub verify_checksum_filename } } +use POSIX; + +sub prepare_for_archival +{ + my ($self, $arc) = @_; + + my $o = $arc->prepare_long($self); + if (!defined $self->{owner} && !$o->isSymLink()) { + if ($o->{uname} ne 'root' && $o->{uname} ne 'bin') { + print STDERR "Error: no \@owner for ", + $self->fullname(), " (", $o->{uname}, ")\n"; + $main::errors++; + } + } + if (!defined $self->{group} && !$o->isSymLink()) { + if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') { + print STDERR "Warning: no \@group for ", + $self->fullname(), " (", $o->{gname}, ")\n"; +# $main::errors++; + } + } + if (!defined $self->{mode} && $o->isFile()) { + if (($o->{mode} & (S_ISUID | S_ISGID | S_IWOTH)) != 0) { + print STDERR "Error: weird mode for ", + $self->fullname(), ": ", + sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n"; + $main::errors++; + } + return $o; + } +} + package OpenBSD::PackingElement::PkgConflict; sub avert_duplicates_and_other_checks { @@ -153,9 +185,7 @@ sub avert_duplicates_and_other_checks package OpenBSD::PackingElement::SpecialFile; sub archive { - my ($self, $arc, $base) = @_; - my $o = $arc->prepare($self->{name}); - $o->write(); + &OpenBSD::PackingElement::FileBase::archive; } sub comment_create_package @@ -205,43 +235,12 @@ sub comment_create_package } package OpenBSD::PackingElement::FileBase; -use POSIX; - -sub prepare_item -{ - my ($self, $arc) = @_; - - my $o = $arc->prepare_long($self); - if (!defined $self->{owner} && !$o->isSymLink()) { - if ($o->{uname} ne 'root' && $o->{uname} ne 'bin') { - print STDERR "Error: no \@owner for ", - $self->fullname(), " (", $o->{uname}, ")\n"; - $main::errors++; - } - } - if (!defined $self->{group} && !$o->isSymLink()) { - if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') { - print STDERR "Warning: no \@group for ", - $self->fullname(), " (", $o->{gname}, ")\n"; -# $main::errors++; - } - } - if (!defined $self->{mode} && $o->isFile()) { - if (($o->{mode} & (S_ISUID | S_ISGID | S_IWOTH)) != 0) { - print STDERR "Error: weird mode for ", - $self->fullname(), ": ", - sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n"; - $main::errors++; - } - return $o; - } -} sub archive { my ($self, $arc, $base) = @_; - my $o = $self->prepare_item($arc); + my $o = $self->prepare_for_archival($arc); $o->write() unless $main::errors; } |