Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys When unlinking a directory as unprivilege...



details:   https://anonhg.NetBSD.org/src/rev/3065d7b0668f
branches:  trunk
changeset: 795622:3065d7b0668f
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Apr 21 18:05:17 2014 +0000

description:
When unlinking a directory as unprivileged user allow both EPERM and EACCESS
failures.

diffstat:

 tests/lib/libc/sys/t_unlink.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r ac0fd9571d4c -r 3065d7b0668f tests/lib/libc/sys/t_unlink.c
--- a/tests/lib/libc/sys/t_unlink.c     Mon Apr 21 17:34:38 2014 +0000
+++ b/tests/lib/libc/sys/t_unlink.c     Mon Apr 21 18:05:17 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_unlink.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */
+/* $NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_unlink.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $");
+__RCSID("$NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $");
 
 #include <sys/stat.h>
 
@@ -129,9 +129,13 @@
 
 ATF_TC_BODY(unlink_perm, tc)
 {
+       int rv;
 
        errno = 0;
-       ATF_REQUIRE_ERRNO(EACCES, unlink("/etc") == -1);
+       rv = unlink("/etc");
+       ATF_REQUIRE_MSG(rv == -1 && (errno == EACCES || errno == EPERM),
+           "unlinking a directory did not fail with EPERM or EACCESS; "
+           "unlink() returned %d, errno %d", rv, errno);
 
        errno = 0;
        ATF_REQUIRE_ERRNO(EACCES, unlink("/root/.profile") == -1);



Home | Main Index | Thread Index | Old Index