Skip to content

Commit

Permalink
regress/check-perms: add test for broken CHECK_PERMS_AUTOFIX
Browse files Browse the repository at this point in the history
The variable CHECK_PERMS_AUTOFIX has been existing since 2006 but is not
used in any package. This may be because it is not helpful in any way.
When a package sets this variables to yes, the permission errors are not
silently fixed, but the build still fails instead. This behavior is not
useful in any way and thus needs to be fixed.

See https://mail-index.netbsd.org/tech-pkg/2019/08/thread1.html#021828
  • Loading branch information
rillig committed Sep 19, 2019
1 parent cd72df5 commit a6a11c6
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
3 changes: 2 additions & 1 deletion regress/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.24 2019/07/17 18:34:16 rillig Exp $
# $NetBSD: Makefile,v 1.25 2019/09/19 23:53:36 rillig Exp $
#
# See https://www.netbsd.org/docs/pkgsrc/regression.html for more
# information about these tests.
Expand All @@ -11,6 +11,7 @@ SUBDIR+= bootstrap-install-sh
SUBDIR+= buildlink-libtool
SUBDIR+= buildlink-transform
SUBDIR+= buildlink-unwrap
SUBDIR+= check-perms
SUBDIR+= check-portability
SUBDIR+= compiler
SUBDIR+= env-vars
Expand Down
1 change: 1 addition & 0 deletions regress/check-perms/DESCR
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Regression test for mk/check/check-perms.mk.
25 changes: 25 additions & 0 deletions regress/check-perms/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# $NetBSD: Makefile,v 1.1 2019/09/19 23:53:36 rillig Exp $

DISTNAME= check-perms-1.0
CATEGORIES= regress
MASTER_SITES= # none
DISTFILES= # none

MAINTAINER= pkgsrc-users@NetBSD.org
COMMENT= Ensures that wrong file permissions are fixed
LICENSE= 2-clause-bsd

NO_CHECKSUM= yes
WRKSRC= ${WRKDIR}
BUILD_DIRS= # none
AUTO_MKDIRS= yes

USE_TOOLS+= pax

do-extract:
cd ${WRKSRC} && > demo-file && chmod 777 demo-file

do-install:
cd ${WRKSRC} && pax -wr -pp demo-file ${DESTDIR}${PREFIX}/share/regress-check-perms/

.include "../../mk/bsd.pkg.mk"
2 changes: 2 additions & 0 deletions regress/check-perms/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.1 2019/09/19 23:53:36 rillig Exp $
share/regress-check-perms/demo-file
58 changes: 58 additions & 0 deletions regress/check-perms/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#! /bin/sh
# $NetBSD: spec,v 1.1 2019/09/19 23:53:36 rillig Exp $
set -eu

do_cleanup() {
$TEST_MAKE deinstall clean
}

do_make() {
echo "Running test case $*"

#$TEST_MAKE "$@" show-all-check-perms

$TEST_MAKE "$@" deinstall clean install 1>"$TEST_OUTFILE" 2>&1 \
&& TEST_EXITSTATUS=0 || TEST_EXITSTATUS=$?
}

test_no_developer_no_autofix() {
do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=no

exit_status 0
}

test_no_developer_autofix() {
do_make PKG_DEVELOPER=no CHECK_PERMS_AUTOFIX=yes

# FIXME: The permissions must be fixed even though PKG_DEVELOPER=no.
exit_status 0
output_prohibit "^error: .*: world-writable file"
}

test_developer_no_autofix() {
do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=no

exit_status 1
output_require "^warning: .*/demo-file: too small to be a valid executable file"
output_require "^warning: .*/demo-file: group-writable file"
output_require "^error: .*/demo-file: world-writable file"
}

test_developer_autofix() {
do_make PKG_DEVELOPER=yes CHECK_PERMS_AUTOFIX=yes

# FIXME: Since all permission problems have been fixed, the exit status must be 0.
# This needs to be fixed in checkperms upstream.
exit_status 1
output_require "^warning: .*/demo-file: too small to be a valid executable file"
output_require "^warning: .*/demo-file: group-writable file"
output_require "^error: .*/demo-file: world-writable file"
output_require "^note: .*/demo-file: fixed permissions from 0777 to 0644"
}

do_test() {
test_no_developer_no_autofix
test_no_developer_autofix
test_developer_no_autofix
test_developer_autofix
}

0 comments on commit a6a11c6

Please sign in to comment.