diff options
author | 2016-09-20 18:29:12 +0000 | |
---|---|---|
committer | 2016-09-20 18:29:12 +0000 | |
commit | c9d4bebc53da6c61703ccd0e6a986dac15ad20b2 (patch) | |
tree | df22ba8fa958af73c71cd6eb6ea6a0e7f5a45b40 | |
parent | When _LIBUNWIND_ARM_EHABI is defined, include <link.h> to get the (diff) | |
download | wireguard-openbsd-c9d4bebc53da6c61703ccd0e6a986dac15ad20b2.tar.xz wireguard-openbsd-c9d4bebc53da6c61703ccd0e6a986dac15ad20b2.zip |
Set correct owner for installed files. One step closer to noperm
builds.
initial diff and ok millert
-rw-r--r-- | gnu/usr.bin/cvs/Makefile.bsd-wrapper | 28 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/contrib/Makefile.in | 3 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/mkinstalldirs | 4 | ||||
-rw-r--r-- | gnu/usr.bin/perl/Makefile.bsd-wrapper | 9 | ||||
-rw-r--r-- | gnu/usr.bin/perl/install_lib.pl | 18 | ||||
-rw-r--r-- | gnu/usr.bin/perl/installperl | 24 |
6 files changed, 61 insertions, 25 deletions
diff --git a/gnu/usr.bin/cvs/Makefile.bsd-wrapper b/gnu/usr.bin/cvs/Makefile.bsd-wrapper index f228aec51e5..de468ca7bb6 100644 --- a/gnu/usr.bin/cvs/Makefile.bsd-wrapper +++ b/gnu/usr.bin/cvs/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.52 2014/10/21 00:12:46 daniel Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.53 2016/09/20 18:29:12 natano Exp $ .include <bsd.own.mk> @@ -28,21 +28,23 @@ CF= config: .FORCE -rm -f config.cache PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ - INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \ - INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \ - ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \ - MAKEINFO='makeinfo --no-split' \ - sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \ - --datadir=/usr/libdata ${CF} + INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ + INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ + INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE}" \ + ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \ + MAKEINFO='makeinfo --no-split' \ + sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \ + --datadir=/usr/libdata ${CF} config.status: PATH="/bin:/usr/bin:/sbin:/usr/sbin" \ - INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \ - INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY}" \ - ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \ - MAKEINFO='makeinfo --no-split' \ - sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \ - --datadir=/usr/libdata ${CF} + INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ + INSTALL_SCRIPT="${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ + INSTALL_DATA="${INSTALL} ${INSTALL_COPY} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE}" \ + ACLOCAL=true AUTOCONF=true AUTOMAKE=true AUTOHEADER=true \ + MAKEINFO='makeinfo --no-split' \ + sh ${.CURDIR}/configure --prefix=/usr --mandir=/usr/share/man \ + --datadir=/usr/libdata ${CF} .ifdef NOMAN maninstall: diff --git a/gnu/usr.bin/cvs/contrib/Makefile.in b/gnu/usr.bin/cvs/contrib/Makefile.in index 9b6db476971..a24816eba1b 100644 --- a/gnu/usr.bin/cvs/contrib/Makefile.in +++ b/gnu/usr.bin/cvs/contrib/Makefile.in @@ -363,7 +363,8 @@ install-data-local: echo "test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ echo " && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo $$p|sed '$(transform)'` ."; \ (test ! -e $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'` \ - && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo $$p|sed '$(transform)'` .) \ + && cd $(DESTDIR)$(bindir) && $(LN_S) $(contribscriptdir)/`echo $$p|sed '$(transform)'` . \ + && chown root:bin `echo $$p|sed '$(transform)'`) \ || (echo "Link creation failed" && if test -f $$p; then \ echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ diff --git a/gnu/usr.bin/cvs/mkinstalldirs b/gnu/usr.bin/cvs/mkinstalldirs index 33bb3e86733..83a8dcc1443 100644 --- a/gnu/usr.bin/cvs/mkinstalldirs +++ b/gnu/usr.bin/cvs/mkinstalldirs @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1.1.3 2001/09/28 22:45:35 tholo Exp $ +# $Id: mkinstalldirs,v 1.2 2016/09/20 18:29:12 natano Exp $ errstatus=0 @@ -24,7 +24,7 @@ do if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" - mkdir "$pathcomp" || lasterr=$? + install -d -o root -g wheel "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr diff --git a/gnu/usr.bin/perl/Makefile.bsd-wrapper b/gnu/usr.bin/perl/Makefile.bsd-wrapper index 313eeb844ea..a6b05d0f3f5 100644 --- a/gnu/usr.bin/perl/Makefile.bsd-wrapper +++ b/gnu/usr.bin/perl/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.103 2016/07/03 01:07:47 afresh1 Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.104 2016/09/20 18:29:12 natano Exp $ # # Build wrapper for Perl 5.20.1-RC2 # @@ -104,18 +104,21 @@ perly.c perly.h: perly.y -@true install: install.lib install.perl maninstall - -mkdir -p ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd + -${INSTALL} -d -o ${LIBOWN} -g ${LIBGRP} -m ${DIRMODE} \ + ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd (cd ${DESTDIR}/usr/include; ${H2PH} \ -d ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd \ `find . -name '*.h'`; \ pax -rw `find . -type l \! -name '*.h' | sed 's/^..//'` \ ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd) + chown -RP ${LIBOWN}:${LIBGRP} \ + ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd -chmod -R a+rX ${DESTDIR}/usr/libdata/perl5 install.perl: cd ${.OBJDIR}; INSTALL=${INSTALL} INSTALL_COPY=${INSTALL_COPY} \ STRIPFLAGS=${STRIPFLAGS} INSTALLFLAGS=-o NOLIBINSTALL=1 \ - LD_LIBRARY_PATH=${.OBJDIR} exec ./perl installperl --destdir=${DESTDIR} -o ${STRIPFLAGS} + LD_LIBRARY_PATH=${.OBJDIR} exec ./perl installperl --user=${LIBOWN} --group=${LIBGRP} --destdir=${DESTDIR} -o ${STRIPFLAGS} test: -@if [ -e Makefile ]; then ${MAKE} test; fi diff --git a/gnu/usr.bin/perl/install_lib.pl b/gnu/usr.bin/perl/install_lib.pl index aa9945a2f9c..d900bc6a769 100644 --- a/gnu/usr.bin/perl/install_lib.pl +++ b/gnu/usr.bin/perl/install_lib.pl @@ -6,7 +6,7 @@ use strict; use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $Is_Darwin $Is_NetWare %opts $packlist); -use subs qw(unlink link chmod); +use subs qw(unlink link chmod chown); require File::Path; BEGIN { @@ -96,6 +96,9 @@ sub link { unless -f $to and (chmod(0666, $to), unlink $to) and File::Copy::copy($from, $to) and ++$success; } + if (defined($opts{uid}) || defined($opts{gid})) { + chown($opts{uid}, $opts{gid}, $to) if $success; + } $packlist->{$xto} = { type => 'file' }; } $success; @@ -111,6 +114,16 @@ sub chmod { unless $opts{notify}; } +sub chown { + my($uid,$gid,$name) = @_; + + return if ($^O eq 'dos'); + printf " chown %s:%s %s\n", $uid, $gid, $name if $opts{verbose}; + CORE::chown($uid,$gid,$name) + || warn sprintf("Couldn't chown %s:%s %s: $!\n", $uid, $gid, $name) + unless $opts{notify}; +} + sub samepath { my($p1, $p2) = @_; @@ -142,7 +155,8 @@ sub safe_rename { } sub mkpath { - File::Path::mkpath(shift , $opts{verbose}, 0777) unless $opts{notify}; + File::Path::make_path(shift, {owner=>$opts{uid}, group=>$opts{gid}, + mode=>0777, verbose=>$opts{verbose}}) unless $opts{notify}; } 1; diff --git a/gnu/usr.bin/perl/installperl b/gnu/usr.bin/perl/installperl index 9a69ea75bf4..a8baa94c4ec 100644 --- a/gnu/usr.bin/perl/installperl +++ b/gnu/usr.bin/perl/installperl @@ -69,8 +69,8 @@ $opts{destdir} = ''; my $usage = 0; if (!GetOptions(\%opts, 'notify|n', 'strip|s', 'silent|S', 'skip-otherperls|o', 'force|f', 'verbose|V', 'archname|A', - 'netware', 'nopods|p', 'destdir:s', 'help|h|?', - 'versiononly|v' => \$versiononly, '<>' => sub { + 'netware', 'nopods|p', 'destdir:s', 'help|h|?', 'user|u:s', + 'group|g:s', 'versiononly|v' => \$versiononly, '<>' => sub { if ($_[0] eq '+v') { $versiononly = 0; } else { @@ -99,6 +99,8 @@ Usage $0: [switches] -A Also install perl with the architecture's name in the perl binary's name. -p Don't install the pod files. [This will break use diagnostics;] + -g group install files with the specified group + -u user install files with the specified user -netware Install correctly on a Netware server. -destdir Prefix installation directories by this string. -h Display this help message. @@ -106,6 +108,8 @@ EOT exit $usage; } } +$opts{'uid'} = getpwnam($opts{'user'}) if exists($opts{'user'}); +$opts{'gid'} = getgrnam($opts{'group'}) if exists($opts{'group'}); $versiononly = 1 if $Config{versiononly} && !defined $versiononly; my (@scripts, @tolink); @@ -462,6 +466,9 @@ if (!$Is_NetWare && $dbg eq '') { safe_unlink("$installbin/$base$exe_ext"); copy("x2p/a2p$exe_ext", "$installbin/$base$exe_ext"); strip("$installbin/$base$exe_ext"); + if (defined($opts{uid}) || defined($opts{gid})) { + chown($opts{uid}, $opts{gid}, "$installbin/$base$exe_ext"); + } chmod(0755, "$installbin/$base$exe_ext"); } } @@ -583,6 +590,9 @@ if (!$versiononly && !$opts{'skip-otherperls'}) { } $packlist->write() unless $opts{notify}; +if (defined($opts{uid}) || defined($opts{gid})) { + chown($opts{uid}, $opts{gid}, $packlist->packlist_file()); +} print " Installation complete\n" if $opts{verbose}; exit 0; @@ -621,6 +631,7 @@ sub safe_unlink { sub copy { my($from,$to) = @_; + my($success) = 0; my $xto = $to; $xto =~ s/^\Q$opts{destdir}\E//; @@ -628,11 +639,14 @@ sub copy { unless $opts{silent}; print " creating new version of $xto\n" if $Is_VMS and -e $to and !$opts{silent}; - unless ($opts{notify} or File::Copy::copy($from, $to)) { + unless ($opts{notify} or File::Copy::copy($from, $to) and ++$success) { # Might have been that F::C::c can't overwrite the target warn "Couldn't copy $from to $to: $!\n" unless -f $to and (chmod(0666, $to), unlink $to) - and File::Copy::copy($from, $to); + and File::Copy::copy($from, $to) and ++$success; + } + if (defined($opts{uid}) || defined($opts{gid})) { + chown($opts{uid}, $opts{gid}, $to) if $success; } $packlist->{$xto} = { type => 'file' }; } @@ -643,6 +657,8 @@ sub install { my $xto = $to; my $cmd = join(' ', @installcmd); $cmd .= " -m $mode" if $mode; + $cmd .= " -o $opts{uid}" if defined($opts{uid}); + $cmd .= " -g $opts{gid}" if defined($opts{gid}); $cmd .= " -s" if $opts{strip}; $cmd .= " $from $to"; $xto =~ s/^\Q$opts{destdir}\E// if $opts{destdir}; |