From owner-p4-projects@FreeBSD.ORG Thu Jun 15 00:21:17 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2621E16A4A0; Thu, 15 Jun 2006 00:21:17 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE7D116A494 for ; Thu, 15 Jun 2006 00:21:16 +0000 (UTC) (envelope-from wsalamon@computer.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A384443D58 for ; Thu, 15 Jun 2006 00:21:16 +0000 (GMT) (envelope-from wsalamon@computer.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5F0LG3w061095 for ; Thu, 15 Jun 2006 00:21:16 GMT (envelope-from wsalamon@computer.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5F0LGMO061092 for perforce@freebsd.org; Thu, 15 Jun 2006 00:21:16 GMT (envelope-from wsalamon@computer.org) Date: Thu, 15 Jun 2006 00:21:16 GMT Message-Id: <200606150021.k5F0LGMO061092@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to wsalamon@computer.org using -f From: Wayne Salamon To: Perforce Change Reviews Cc: Subject: PERFORCE change 99268 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2006 00:21:17 -0000 http://perforce.freebsd.org/chv.cgi?CH=99268 Change 99268 by wsalamon@gretsch on 2006/06/15 00:20:22 Use "ufs" for file system type. Also add tests for the nmount(2) system call. Affected files ... .. //depot/projects/trustedbsd/audit3/tools/regression/audit/test/filesystem/tfilesys.c#3 edit Differences ... ==== //depot/projects/trustedbsd/audit3/tools/regression/audit/test/filesystem/tfilesys.c#3 (text+ko) ==== @@ -32,6 +32,7 @@ #include #include #include +#include /* * Test the auditing of some of the filesystem-related system calls. @@ -45,12 +46,13 @@ int ret; int temp_fd; char tempname[32]; - struct statfs stat; + struct statfs sb; u_long count; u_long basep; u_long newstate; u_long nmatches; char buf[128]; + struct iovec iov[16]; AUT_INIT(); @@ -61,39 +63,92 @@ exit (-1); } /* Generate a success AUE_GETFSSTAT audit record */ - if (getfsstat(&stat, 1, MNT_NOWAIT)) + if (getfsstat(&sb, 1, MNT_NOWAIT) != 0) AUT_PERROR("getfsstat()"); aut_assert(AUE_GETFSSTAT); /* Generate a success AUE_STATFS audit record */ - if (statfs(tempname, &stat)) + if (statfs(tempname, &sb) != 0) AUT_PERROR("statfs()"); aut_assert(AUE_STATFS); /* Generate a success AUE_FSTATFS audit record */ - if (fstatfs(temp_fd, &stat)) + if (fstatfs(temp_fd, &sb) != 0) AUT_PERROR("fstatfs()"); aut_assert(AUE_FSTATFS); /* Generate a failure AUE_STATFS audit record */ - if (statfs("ANonExiSteNtFileName", &stat)) + if (statfs("ANonExiSteNtFileName", &sb) != 0) AUT_PERROR("statfs()"); /* Generate a failure AUE_FSTATFS audit record */ - if (fstatfs(1027309, &stat)) + if (fstatfs(1027309, &sb) != 0) AUT_PERROR("fstatfs()"); close(temp_fd); unlink(tempname); /* Generate an AUE_MOUNT audit record (but fail) */ - if (mount("hfs", "/tmp", MNT_UPDATE, NULL)) - AUT_PERROR("mount()"); + if (mount("ufs", "/", MNT_RDONLY, &sb) != 0) + AUT_PERROR("mount(/)"); + aut_assert(AUE_MOUNT); + + /* Generate an AUE_MOUNT audit record (but fail) */ + if (mount("cd9660", "/cdrom", MNT_RDONLY, NULL) != 0) + AUT_PERROR("mount(/cdrom)"); aut_assert(AUE_MOUNT); /* Generate an AUE_UMOUNT audit record (but fail) */ - if (unmount("/tmp", 0)) - AUT_PERROR("unmount()"); + if (unmount("/cdrom", 0) != 0) + AUT_PERROR("unmount(/cdrom)"); + aut_assert(AUE_UMOUNT); + + /* Generate an AUE_NMOUNT audit record (but fail) */ +#define FSTYPE "fstype" +#define CD "cd9660" +#define FSPATH "fspath" +#define PATH "/cdrom" +#define FSJUNK "fsjunk" +#define JUNK "/junk" + iov[0].iov_base = malloc(strlen(FSTYPE)); + iov[0].iov_base = FSTYPE; + iov[0].iov_len = strlen(FSTYPE); + iov[1].iov_base = malloc(strlen(CD)); + iov[1].iov_base = CD; + iov[1].iov_len = strlen(CD); + iov[2].iov_base = malloc(strlen(FSPATH)); + iov[2].iov_base = FSPATH; + iov[2].iov_len = strlen(FSPATH); + iov[3].iov_base = malloc(strlen(PATH)); + iov[3].iov_base = PATH; + iov[3].iov_len = strlen(PATH); + iov[4].iov_base = malloc(strlen(FSJUNK)); + iov[4].iov_base = FSJUNK; + iov[4].iov_len = strlen(FSJUNK); + iov[5].iov_base = malloc(strlen(JUNK)); + iov[5].iov_base = JUNK; + iov[5].iov_len = strlen(JUNK); + iov[4].iov_base = malloc(sizeof(sb)); + iov[4].iov_base = &sb; + iov[4].iov_len = sizeof(&sb); + iov[5].iov_base = malloc(sizeof(nmatches)); + iov[5].iov_base = &nmatches; + iov[5].iov_len = sizeof(nmatches); + iov[6].iov_base = malloc(strlen(FSJUNK)); + iov[6].iov_base = FSJUNK; + iov[6].iov_len = strlen(FSJUNK); + iov[7].iov_base = malloc(strlen(JUNK)); + iov[7].iov_base = JUNK; + iov[7].iov_len = strlen(JUNK); + if (nmount(&iov[0], 8, MNT_RDONLY) != 0) + AUT_PERROR("nmount()"); + aut_assert(AUE_NMOUNT); + + /* Generate another failure AUE_UMOUNT record; unmounting root fails * + * differently. + */ + if (unmount("/", 0)) + AUT_PERROR("unmount(/)"); aut_assert(AUE_UMOUNT); temp_fd = open("/", O_RDONLY, 0);