diff options
author | 2016-10-06 15:34:18 +0000 | |
---|---|---|
committer | 2016-10-06 15:34:18 +0000 | |
commit | 2da2f9e478a9be8c41686c415210a1bccde67424 (patch) | |
tree | 410ef5f5ada4ac6b70c3a67c6bad632acc945d23 | |
parent | Disable RTS for long frames in ral(4) for rt2560 chips. (diff) | |
download | wireguard-openbsd-2da2f9e478a9be8c41686c415210a1bccde67424.tar.xz wireguard-openbsd-2da2f9e478a9be8c41686c415210a1bccde67424.zip |
Use BUILDUSER as the owner of new links/directories created in 'make obj'
when started as root.
diff by millert with tweaks by me
ok tb deraadt
-rw-r--r-- | share/mk/bsd.obj.mk | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk index 0c2a67a5b75..c1414027d57 100644 --- a/share/mk/bsd.obj.mk +++ b/share/mk/bsd.obj.mk @@ -1,4 +1,4 @@ -# $OpenBSD: bsd.obj.mk,v 1.14 2013/11/22 15:43:18 espie Exp $ +# $OpenBSD: bsd.obj.mk,v 1.15 2016/10/06 15:34:18 natano Exp $ # $NetBSD: bsd.obj.mk,v 1.9 1996/04/10 21:08:05 thorpej Exp $ .if !target(obj) @@ -16,6 +16,16 @@ _SUBDIRUSE: obj! _SUBDIRUSE @cd ${.CURDIR}; \ + if [[ `id -u` -eq 0 && ${BUILDUSER} != root ]]; then \ + SETOWNER="chown -h ${BUILDUSER}"; \ + _mkdirs() { \ + su ${BUILDUSER} -c "mkdir -p $$1"; \ + }; \ + MKDIRS=_mkdirs; \ + else \ + MKDIRS="mkdir -p"; \ + SETOWNER=:; \ + fi; \ here=`/bin/pwd`; bsdsrcdir=`cd ${BSDSRCDIR}; /bin/pwd`; \ subdir=$${here#$${bsdsrcdir}/}; \ if test $$here != $$subdir ; then \ @@ -26,9 +36,10 @@ obj! _SUBDIRUSE then \ if test -e ${__objdir}; then rm -rf ${__objdir}; fi; \ ln -sf $$dest ${__objdir}; \ + $$SETOWNER ${__objdir}; \ fi; \ if test -d ${BSDOBJDIR}; then \ - test -d $$dest || mkdir -p $$dest; \ + test -d $$dest || $$MKDIRS $$dest; \ else \ if test -e ${BSDOBJDIR}; then \ echo "${BSDOBJDIR} is not a directory"; \ @@ -41,8 +52,10 @@ obj! _SUBDIRUSE dest=$$here/${__objdir} ; \ if test ! -d ${__objdir} ; then \ echo "making $$dest" ; \ - mkdir $$dest; \ + $$MKDIRS $$dest; \ fi ; \ fi; . endif .endif + +.include <bsd.own.mk> |