* [PATCH V2] selinux-testsuite: Allow nfs test script to close cleanly
@ 2020-02-21 13:18 Richard Haines
2020-02-25 14:07 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Richard Haines @ 2020-02-21 13:18 UTC (permalink / raw)
To: selinux; +Cc: Richard Haines
Whenever a failure, close NFS cleanly.
Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
V2 Changes:
Revamp error handling to cover all cases
tools/nfs.sh | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/tools/nfs.sh b/tools/nfs.sh
index 314f898..7ba4cfc 100755
--- a/tools/nfs.sh
+++ b/tools/nfs.sh
@@ -1,14 +1,33 @@
#!/bin/sh -e
MOUNT=`stat --print %m .`
TESTDIR=`pwd`
-systemctl start nfs-server
+MAKE_TEST=0
+
+function err_exit() {
+ if [ $MAKE_TEST -eq 1 ]; then
+ echo "Closing down NFS"
+ popd
+ else
+ echo "Error on line: $1 - Closing down NFS"
+ fi
+ umount /mnt/selinux-testsuite
+ exportfs -u localhost:$MOUNT
+ rmdir /mnt/selinux-testsuite
+ systemctl stop nfs-server
+ exit 1
+}
+
+trap 'err_exit $LINENO' ERR
+systemctl start nfs-server
# Run the full testsuite on a labeled NFS mount.
exportfs -orw,no_root_squash,security_label localhost:$MOUNT
mkdir -p /mnt/selinux-testsuite
mount -t nfs -o vers=4.2 localhost:$TESTDIR /mnt/selinux-testsuite
pushd /mnt/selinux-testsuite
+MAKE_TEST=1
make test
+MAKE_TEST=0
popd
umount /mnt/selinux-testsuite
@@ -18,7 +37,7 @@ echo "Testing context mount of a security_label export."
fctx=`secon -t -f /mnt/selinux-testsuite`
if [ "$fctx" != "etc_t" ]; then
echo "Context mount failed: got $fctx instead of etc_t."
- exit 1
+ err_exit $LINENO
fi
umount /mnt/selinux-testsuite
exportfs -u localhost:$MOUNT
@@ -30,7 +49,7 @@ echo "Testing context mount of a non-security_label export."
fctx=`secon -t -f /mnt/selinux-testsuite`
if [ "$fctx" != "etc_t" ]; then
echo "Context mount failed: got $fctx instead of etc_t."
- exit 1
+ err_exit $LINENO
fi
umount /mnt/selinux-testsuite
@@ -40,7 +59,7 @@ echo "Testing non-context mount of a non-security_label export."
fctx=`secon -t -f /mnt/selinux-testsuite`
if [ "$fctx" != "nfs_t" ]; then
echo "Context mount failed: got $fctx instead of nfs_t."
- exit 1
+ err_exit $LINENO
fi
umount /mnt/selinux-testsuite
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] selinux-testsuite: Allow nfs test script to close cleanly
2020-02-21 13:18 [PATCH V2] selinux-testsuite: Allow nfs test script to close cleanly Richard Haines
@ 2020-02-25 14:07 ` Stephen Smalley
2020-02-27 17:13 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2020-02-25 14:07 UTC (permalink / raw)
To: Richard Haines; +Cc: selinux, omosnace
On Fri, Feb 21, 2020 at 8:18 AM Richard Haines
<richard_c_haines@btinternet.com> wrote:
>
> Whenever a failure, close NFS cleanly.
>
> Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
I'm not much of a shell programmer but this looks good to me.
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
> ---
> V2 Changes:
> Revamp error handling to cover all cases
>
> tools/nfs.sh | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/tools/nfs.sh b/tools/nfs.sh
> index 314f898..7ba4cfc 100755
> --- a/tools/nfs.sh
> +++ b/tools/nfs.sh
> @@ -1,14 +1,33 @@
> #!/bin/sh -e
> MOUNT=`stat --print %m .`
> TESTDIR=`pwd`
> -systemctl start nfs-server
> +MAKE_TEST=0
> +
> +function err_exit() {
> + if [ $MAKE_TEST -eq 1 ]; then
> + echo "Closing down NFS"
> + popd
> + else
> + echo "Error on line: $1 - Closing down NFS"
> + fi
> + umount /mnt/selinux-testsuite
> + exportfs -u localhost:$MOUNT
> + rmdir /mnt/selinux-testsuite
> + systemctl stop nfs-server
> + exit 1
> +}
> +
> +trap 'err_exit $LINENO' ERR
>
> +systemctl start nfs-server
> # Run the full testsuite on a labeled NFS mount.
> exportfs -orw,no_root_squash,security_label localhost:$MOUNT
> mkdir -p /mnt/selinux-testsuite
> mount -t nfs -o vers=4.2 localhost:$TESTDIR /mnt/selinux-testsuite
> pushd /mnt/selinux-testsuite
> +MAKE_TEST=1
> make test
> +MAKE_TEST=0
> popd
> umount /mnt/selinux-testsuite
>
> @@ -18,7 +37,7 @@ echo "Testing context mount of a security_label export."
> fctx=`secon -t -f /mnt/selinux-testsuite`
> if [ "$fctx" != "etc_t" ]; then
> echo "Context mount failed: got $fctx instead of etc_t."
> - exit 1
> + err_exit $LINENO
> fi
> umount /mnt/selinux-testsuite
> exportfs -u localhost:$MOUNT
> @@ -30,7 +49,7 @@ echo "Testing context mount of a non-security_label export."
> fctx=`secon -t -f /mnt/selinux-testsuite`
> if [ "$fctx" != "etc_t" ]; then
> echo "Context mount failed: got $fctx instead of etc_t."
> - exit 1
> + err_exit $LINENO
> fi
> umount /mnt/selinux-testsuite
>
> @@ -40,7 +59,7 @@ echo "Testing non-context mount of a non-security_label export."
> fctx=`secon -t -f /mnt/selinux-testsuite`
> if [ "$fctx" != "nfs_t" ]; then
> echo "Context mount failed: got $fctx instead of nfs_t."
> - exit 1
> + err_exit $LINENO
> fi
> umount /mnt/selinux-testsuite
>
> --
> 2.24.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] selinux-testsuite: Allow nfs test script to close cleanly
2020-02-25 14:07 ` Stephen Smalley
@ 2020-02-27 17:13 ` Stephen Smalley
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2020-02-27 17:13 UTC (permalink / raw)
To: Stephen Smalley; +Cc: Richard Haines, selinux, Ondrej Mosnacek
On Tue, Feb 25, 2020 at 9:06 AM Stephen Smalley
<stephen.smalley@gmail.com> wrote:
>
> On Fri, Feb 21, 2020 at 8:18 AM Richard Haines
> <richard_c_haines@btinternet.com> wrote:
> >
> > Whenever a failure, close NFS cleanly.
> >
> > Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
>
> I'm not much of a shell programmer but this looks good to me.
>
> Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-27 17:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 13:18 [PATCH V2] selinux-testsuite: Allow nfs test script to close cleanly Richard Haines
2020-02-25 14:07 ` Stephen Smalley
2020-02-27 17:13 ` Stephen Smalley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).