-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regress/check-perms: add test for broken CHECK_PERMS_AUTOFIX
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
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Regression test for mk/check/check-perms.mk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |