Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/vfs Add another testcase that check setting file ti...



details:   https://anonhg.NetBSD.org/src/rev/0dcf1258c1a3
branches:  trunk
changeset: 778076:0dcf1258c1a3
user:      njoly <njoly%NetBSD.org@localhost>
date:      Thu Mar 15 12:57:27 2012 +0000

description:
Add another testcase that check setting file times with unprivileged
credentials.

diffstat:

 tests/fs/vfs/t_unpriv.c |  35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diffs (64 lines):

diff -r 330fd0bc85b5 -r 0dcf1258c1a3 tests/fs/vfs/t_unpriv.c
--- a/tests/fs/vfs/t_unpriv.c   Thu Mar 15 12:49:36 2012 +0000
+++ b/tests/fs/vfs/t_unpriv.c   Thu Mar 15 12:57:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_unpriv.c,v 1.5 2012/02/09 18:31:03 njoly Exp $       */
+/*     $NetBSD: t_unpriv.c,v 1.6 2012/03/15 12:57:27 njoly Exp $       */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -26,6 +26,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/time.h>
+
 #include <atf-c.h>
 #include <libgen.h>
 #include <unistd.h>
@@ -115,14 +117,45 @@
        FSTEST_EXIT();
 }
 
+static void
+times(const atf_tc_t *tc, const char *mp)
+{
+       const char *name = "file.test";
+       int fd;
+
+       FSTEST_ENTER();
+
+       if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1)
+               atf_tc_fail_errno("open");
+       if (rump_sys_close(fd) == -1)
+               atf_tc_fail_errno("close");
+
+       rump_pub_lwproc_rfork(RUMP_RFCFDG);
+       if (rump_sys_setuid(1) == -1)
+               atf_tc_fail_errno("setuid");
+       if (rump_sys_utimes(name, NULL) != -1 || errno != EACCES)
+               atf_tc_fail_errno("utimes");
+       rump_pub_lwproc_releaselwp();
+
+       if (rump_sys_utimes(name, NULL) == -1)
+               atf_tc_fail_errno("utimes");
+
+       if (rump_sys_unlink(name) == -1)
+               atf_tc_fail_errno("unlink");
+
+       FSTEST_EXIT();
+}
+
 ATF_TC_FSAPPLY(owner, "owner unprivileged checks");
 ATF_TC_FSAPPLY(dirperms, "directory permission checks");
+ATF_TC_FSAPPLY(times, "time set checks");
 
 ATF_TP_ADD_TCS(tp)
 {
 
        ATF_TP_FSAPPLY(owner);
        ATF_TP_FSAPPLY(dirperms);
+       ATF_TP_FSAPPLY(times);
 
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index