PERFORCE change 99268 for review
Wayne Salamon
wsalamon at FreeBSD.org
Thu Jun 15 00:21:19 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=99268
Change 99268 by wsalamon at 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 <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
+#include <sys/uio.h>
/*
* 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);
More information about the trustedbsd-cvs
mailing list