diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-25 12:19:25 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-25 12:19:25 +0000 |
commit | f061d29c5976a0051a2ebfb63b52306950dea57a (patch) | |
tree | 65b06657f6842f6d7c8cd02202f2b58cb63a6679 /usr.sbin | |
parent | 5a4dcafffb63ebc6b614b4d72a933b2fa88280be (diff) |
move the mode checker code from pkg_create into ArcCheck, so that pkg_add
can reuse it.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/ArcCheck.pm | 33 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 26 |
2 files changed, 35 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm index 8ee643f042d..92f37184365 100644 --- a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: ArcCheck.pm,v 1.6 2007/05/02 15:05:29 espie Exp $ +# $OpenBSD: ArcCheck.pm,v 1.7 2007/05/25 12:19:24 espie Exp $ # # Copyright (c) 2005-2006 Marc Espie <espie@openbsd.org> # @@ -55,6 +55,37 @@ sub check_linkname return 0; } +use POSIX; + +sub verify_modes +{ + my ($o, $item) = @_; + my $result = 1; + + if (!defined $item->{owner} && !$o->isSymLink) { + if ($o->{uname} ne 'root' && $o->{uname} ne 'bin') { + print STDERR "Error: no \@owner for ", + $item->fullname, " (", $o->{uname}, ")\n"; + $result = 0; + } + } + if (!defined $item->{group} && !$o->isSymLink) { + if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') { + print STDERR "Warning: no \@group for ", + $item->fullname, " (", $o->{gname}, ")\n"; + } + } + if (!defined $item->{mode} && $o->isFile) { + if (($o->{mode} & (S_ISUID | S_ISGID | S_IWOTH)) != 0) { + print STDERR "Error: weird mode for ", + $item->fullname, ": ", + sprintf("%4o", $o->{mode} & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID)), "\n"; + $result = 0; + } + } + return $result; +} + # copy long items, avoiding duplicate long names. sub copy_long { diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index 45fbc0b9f52..4ee39f8b66c 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.101 2007/05/22 14:06:30 jmc Exp $ +# $OpenBSD: pkg_create,v 1.102 2007/05/25 12:19:23 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -122,34 +122,14 @@ 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++; - } + if (!$o->verify_modes($self)) { + $main::errors++; } return $o; } |