Skip to contentSkip to conversation

Remove tomoyo testing suite

RFC PATCH In review Andrea Cervesato via ltp 3 participants 5 messages Mar 2, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Remove tomoyo testing suite

The tomoyo testing suite is built and installed inside the LTP testcases folder, but it's not used by any runtest file. It seems an old and unmaintained testing suite that uses old LTP API and ltp_clone_quick that is going to be deprecated.

We suppose to update it using new LTP API, cleaning up the code and removing deprecated functions, but nowadays the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor and not maintained anymore in years of development.

For this reason, this patch is going to remove it from LTP installation.

---
 testcases/kernel/security/tomoyo/.gitignore   |   9 -
 testcases/kernel/security/tomoyo/Makefile     |  29 -
 testcases/kernel/security/tomoyo/README       |  58 --
 testcases/kernel/security/tomoyo/include.h    | 379 ----------
 testcases/kernel/security/tomoyo/newns.c      |  49 --
 testcases/kernel/security/tomoyo/testall.sh   |  46 --
 .../security/tomoyo/tomoyo_accept_test.c      | 146 ----
 .../kernel/security/tomoyo/tomoyo_file_test.c | 304 --------
 .../security/tomoyo/tomoyo_filesystem_test.c  | 633 -----------------
 .../security/tomoyo/tomoyo_new_file_test.c    | 627 -----------------
 .../kernel/security/tomoyo/tomoyo_new_test.c  | 652 ------------------
 .../security/tomoyo/tomoyo_policy_io_test.c   | 195 ------
 .../tomoyo/tomoyo_policy_memory_test.c        | 358 ----------
 .../security/tomoyo/tomoyo_rewrite_test.c     | 169 -----
 14 files changed, 3654 deletions(-)
 delete mode 100644 testcases/kernel/security/tomoyo/.gitignore
 delete mode 100644 testcases/kernel/security/tomoyo/Makefile
 delete mode 100644 testcases/kernel/security/tomoyo/README
 delete mode 100644 testcases/kernel/security/tomoyo/include.h
 delete mode 100644 testcases/kernel/security/tomoyo/newns.c
 delete mode 100644 testcases/kernel/security/tomoyo/testall.sh
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_accept_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_file_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_file_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c
testcases/kernel/security/tomoyo/.gitignore deleted +0 -9
deleted file mode 100644
index 698646d93..000000000
@@ -1,9 +0,0 @@
-/newns
-/tomoyo_accept_test
-/tomoyo_file_test
-/tomoyo_filesystem_test
-/tomoyo_new_file_test
-/tomoyo_new_test
-/tomoyo_policy_io_test
-/tomoyo_policy_memory_test
-/tomoyo_rewrite_test
testcases/kernel/security/tomoyo/Makefile deleted +0 -29
deleted file mode 100644
index 00e4cc3ed..000000000
@@ -1,29 +0,0 @@
-#
-#    kernel/security/smack testcase Makefile
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License along
-#    with this program; if not, write to the Free Software Foundation, Inc.,
-#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS		:= testall.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/security/tomoyo/README deleted +0 -58

58 lines not on this page · raw message

testcases/kernel/security/tomoyo/include.h deleted +0 -379

379 lines not on this page · raw message

testcases/kernel/security/tomoyo/newns.c deleted +0 -49

49 lines not on this page · raw message

testcases/kernel/security/tomoyo/testall.sh deleted +0 -46

46 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_accept_test.c deleted +0 -146

146 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_file_test.c deleted +0 -304

304 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c deleted +0 -633

633 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_new_file_test.c deleted +0 -627

627 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_new_test.c deleted +0 -652

652 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c deleted +0 -195

68 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c deleted +0 -358

358 lines not on this page · raw message

testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c deleted +0 -169

169 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

Part of the diff is not shown here. View the raw message.

#1 lore raw

Hi,

an update: tomoyo linux is still maintained in Kernel Linux (https://github.com/torvalds/linux/commits/master/security/tomoyo), but we ask if LTP is still used to test it or we can remove the testing suite due to API deprecation.

If not, we should find someone who wants/needs to maintain it, because some API that the testing suite is using are going to be deprecated/removed in the next future.

Regards,
Andrea

Quoted 3,782 lines · Andrea Cervesato

The tomoyo testing suite is built and installed inside the LTP testcases folder, but it's not used by any runtest file. It seems an old and unmaintained testing suite that uses old LTP API and ltp_clone_quick that is going to be deprecated.

We suppose to update it using new LTP API, cleaning up the code and removing deprecated functions, but nowadays the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor and not maintained anymore in years of development.

For this reason, this patch is going to remove it from LTP installation.

---
  testcases/kernel/security/tomoyo/.gitignore   |   9 -
  testcases/kernel/security/tomoyo/Makefile     |  29 -
  testcases/kernel/security/tomoyo/README       |  58 --
  testcases/kernel/security/tomoyo/include.h    | 379 ----------
  testcases/kernel/security/tomoyo/newns.c      |  49 --
  testcases/kernel/security/tomoyo/testall.sh   |  46 --
  .../security/tomoyo/tomoyo_accept_test.c      | 146 ----
  .../kernel/security/tomoyo/tomoyo_file_test.c | 304 --------
  .../security/tomoyo/tomoyo_filesystem_test.c  | 633 -----------------
  .../security/tomoyo/tomoyo_new_file_test.c    | 627 -----------------
  .../kernel/security/tomoyo/tomoyo_new_test.c  | 652 ------------------
  .../security/tomoyo/tomoyo_policy_io_test.c   | 195 ------
  .../tomoyo/tomoyo_policy_memory_test.c        | 358 ----------
  .../security/tomoyo/tomoyo_rewrite_test.c     | 169 -----
  14 files changed, 3654 deletions(-)

delete mode 100644 testcases/kernel/security/tomoyo/.gitignore delete mode 100644 testcases/kernel/security/tomoyo/Makefile delete mode 100644 testcases/kernel/security/tomoyo/README
delete mode 100644 testcases/kernel/security/tomoyo/include.h delete mode 100644 testcases/kernel/security/tomoyo/newns.c
delete mode 100644 testcases/kernel/security/tomoyo/testall.sh delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_accept_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_file_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_file_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c

testcases/kernel/security/tomoyo/.gitignore deleted +0 -9
deleted file mode 100644
index 698646d93..000000000
@@ -1,9 +0,0 @@
-/newns
-/tomoyo_accept_test
-/tomoyo_file_test
-/tomoyo_filesystem_test
-/tomoyo_new_file_test
-/tomoyo_new_test
-/tomoyo_policy_io_test
-/tomoyo_policy_memory_test
-/tomoyo_rewrite_test
testcases/kernel/security/tomoyo/Makefile deleted +0 -29
deleted file mode 100644
index 00e4cc3ed..000000000
@@ -1,29 +0,0 @@
-#
-#    kernel/security/smack testcase Makefile
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License along
-#    with this program; if not, write to the Free Software Foundation, Inc.,
-#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS		:= testall.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/security/tomoyo/README deleted +0 -58
deleted file mode 100644
index 0cb538868..000000000
@@ -1,58 +0,0 @@
-Always look here for latest version of these tests:
-http://sourceforge.jp/projects/tomoyo/svn/view/trunk/2.3.x/tomoyo-tools/kernel_test/?root=tomoyo
-
-These testcases test the TOMOYO Security Module. And they are not part of
-default LTP build/install/run.
-
-A kernel with TOMOYO configured is required to run the TOMOYO testsuite.
-The securityfs filesystem must be mounted at /sys/kernel/security .
-
-Preparation steps are:
-
-1) Download tomoyo-tools package and extract and build and install.
-
-  # wget -O tomoyo-tools.tar.gz 'http://sourceforge.jp/projects/tomoyo/svn/view/trunk/2.3.x/tomoyo-tools.tar.gz?root=tomoyo&view=tar'
-  # tar -zxf tomoyo-tools.tar.gz
-  # make -C tomoyo-tools/ install
-
-  Programs are installed in /usr/sbin/ with prefix "tomoyo-" and
-  /usr/lib/tomoyo/ directory without prefix "tomoyo-".
-
-  You can make a RPM package by "rpmbuild -bb tomoyo-tools/tomoyo-tools.spec" and
-  a DEB package by "alien -k" after "rpmbuild -bb".
-
-2) Run /usr/lib/tomoyo/init_policy .
-
-   This will take several minutes.
-
-   Hiding kernel source directory by "mount -t tmpfs none /usr/src/linux/"
-   would save some time.
-
-   Configuration files are saved in /etc/tomoyo/ directory.
-   You can do "rm -fR /etc/tomoyo/" if you want to uninstall.
-
-3) Reboot the system with TOMOYO enabled kernel.
-
-   To make sure TOMOYO is selected, you can add security=tomoyo to kernel's
-   command line.
-
-4) Build the tests.
-
-   # (extract the tar ball containing the tests.)
-   # make autotools
-   # ./configure
-   # cd testcases/kernel/security/tomoyo/
-   # make
-   # find `/bin/pwd` -type f -perm +100 >> /etc/tomoyo/manager.conf
-   # /usr/sbin/tomoyo-loadpolicy m
-
-Test steps are:
-
-1) Run the tests from the directory you ran "make".
-
-   # ./testall.sh
-
-   Please don't run the tests inside /tmp/ directory, for /tmp/ directory is
-   hidden by "newns" (a wrapper program to run the test in a new namespace).
-
-   You can use "| grep -vF OK" to pick up only failed tests as testall.sh does.
testcases/kernel/security/tomoyo/include.h deleted +0 -379
deleted file mode 100644
index edaf1170f..000000000
@@ -1,379 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Tetsuo Handa <[email protected]>, 2009      */
-/*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * include.h
- *
- * Common functions for testing TOMOYO Linux's kernel.
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/kdev_t.h>
-#include <linux/unistd.h>
-#include <pty.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <sys/timex.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <unistd.h>
-#include <utime.h>
-#include <sched.h>
-#include <stdarg.h>
-#include <sys/mount.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <linux/ip.h>
-#include <err.h>
-#include "test.h"
-
-/*
- * Some architectures like mips n32 don't have __NR_uselib defined in the
- * system headers.
- */
-#ifdef __NR_uselib
-static inline int uselib(const char *library)
-{
-	return syscall(__NR_uselib, library);
-}
-#else
-static inline int uselib(const char *library)
-{
-	errno = ENOSYS;
-	return -1;
-}
-#endif
-
-/* Is there an architecture without __NR_pivot_root defined? */
-#ifdef __NR_pivot_root
-static inline int pivot_root(const char *new_root, const char *put_old)
-{
-	return syscall(__NR_pivot_root, new_root, put_old);
-}
-#else
-static inline int pivot_root(const char *new_root, const char *put_old)
-{
-	errno = ENOSYS;
-	return -1;
-}
-#endif
-
-/* The sysctl() wrapper is dead and newer arches omit it now. */
-static inline int write_sysctl(const char *path, const char *value)
-{
-	FILE *fp = fopen(path, "w");
-	if (!fp)
-		return 1;
-	fputs(value, fp);
-	fclose(fp);
-	return 0;
-}
-
-static inline int read_sysctl(const char *path, char *value, int len)
-{
-	char scratch[100];
-	FILE *fp = fopen(path, "r");
-	if (!fp)
-		return 1;
-	if (!value) {
-		value = scratch;
-		len = sizeof(scratch);
-	}
-	if (fgets(value, len, fp))
-		/* ignore */;
-	fclose(fp);
-	return 0;
-}
-
-/* Should be a fairly benign path to bang on. */
-#define TEST_SYSCTL_PATH "/proc/sys/net/ipv4/ip_local_port_range"
-
-#define proc_policy_dir              "/sys/kernel/security/tomoyo/"
-#define proc_policy_domain_policy    "/sys/kernel/security/tomoyo/domain_policy"
-#define proc_policy_exception_policy "/sys/kernel/security/tomoyo/exception_policy"
-#define proc_policy_profile          "/sys/kernel/security/tomoyo/profile"
-#define proc_policy_manager          "/sys/kernel/security/tomoyo/manager"
-#define proc_policy_query            "/sys/kernel/security/tomoyo/query"
-#define proc_policy_grant_log        "/sys/kernel/security/tomoyo/grant_log"
-#define proc_policy_reject_log       "/sys/kernel/security/tomoyo/reject_log"
-#define proc_policy_domain_status    "/sys/kernel/security/tomoyo/.domain_status"
-#define proc_policy_process_status   "/sys/kernel/security/tomoyo/.process_status"
-#define proc_policy_self_domain      "/sys/kernel/security/tomoyo/self_domain"
-
-static FILE *profile_fp = NULL;
-static FILE *domain_fp = NULL;
-static FILE *exception_fp = NULL;
-static char self_domain[4096] = "";
-static pid_t pid = 0;
-
-static void clear_status(void)
-{
-	static const char *keywords[] = {
-		"file::execute",
-		"file::open",
-		"file::create",
-		"file::unlink",
-		"file::mkdir",
-		"file::rmdir",
-		"file::mkfifo",
-		"file::mksock",
-		"file::truncate",
-		"file::symlink",
-		"file::rewrite",
-		"file::mkblock",
-		"file::mkchar",
-		"file::link",
-		"file::rename",
-		"file::chmod",
-		"file::chown",
-		"file::chgrp",
-		"file::ioctl",
-		"file::chroot",
-		"file::mount",
-		"file::umount",
-		"file::pivot_root",
-		NULL
-	};
-	int i;
-	FILE *fp = fopen(proc_policy_profile, "r");
-	static char buffer[4096];
-	if (!fp) {
-		fprintf(stderr, "Can't open %s\n", proc_policy_profile);
-		exit(1);
-	}
-	for (i = 0; keywords[i]; i++)
-		fprintf(profile_fp,
-			"255-CONFIG::%s={ mode=disabled }\n",
-			keywords[i]);
-	while (memset(buffer, 0, sizeof(buffer)),
-	       fgets(buffer, sizeof(buffer) - 10, fp)) {
-		const char *mode;
-		char *cp = strchr(buffer, '=');
-		if (!cp)
-			continue;
-		*cp = '\0';
-		mode = cp + 1;
-		cp = strchr(buffer, '-');
-		if (!cp)
-			continue;
-		*cp++ = '\0';
-		if (strcmp(buffer, "0"))
-			continue;
-		fprintf(profile_fp, "255-%s", cp);
-		if (!strcmp(cp, "COMMENT"))
-			mode = "Profile for kernel test\n";
-		else
-			mode = "{ mode=disabled verbose=no }\n";
-		fprintf(profile_fp, "255-%s=%s", cp, mode);
-	}
-	fprintf(profile_fp, "255-PREFERENCE::learning= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::enforcing= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::permissive= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::disabled= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::learning= max_entry=2048\n");
-	fflush(profile_fp);
-	fclose(fp);
-}
-
-static void tomoyo_test_init(void)
-{
-	pid = getpid();
-	if (access(proc_policy_dir, F_OK)) {
-		fprintf(stderr, "You can't use this program for this kernel."
-			"\n");
-		exit(1);
-	}
-	profile_fp = fopen(proc_policy_profile, "w");
-	if (!profile_fp) {
-		fprintf(stderr, "Can't open %s .\n", proc_policy_profile);
-		exit(1);
-	}
-	setlinebuf(profile_fp);
-	domain_fp = fopen(proc_policy_domain_policy, "w");
-	if (!domain_fp) {
-		fprintf(stderr, "Can't open %s .\n",
-			proc_policy_domain_policy);
-		exit(1);
-	}
-	setlinebuf(domain_fp);
-	exception_fp = fopen(proc_policy_exception_policy, "w");
-	if (!exception_fp) {
-		fprintf(stderr, "Can't open %s .\n",
-			proc_policy_exception_policy);
-		exit(1);
-	}
-	setlinebuf(exception_fp);
-	if (fputc('\n', profile_fp) != '\n' || fflush(profile_fp)) {
-		fprintf(stderr, "You need to register this program to %s to "
-			"run this program.\n", proc_policy_manager);
-		exit(1);
-	}
-	clear_status();
-	{
-		FILE *fp = fopen(proc_policy_self_domain, "r");
-		memset(self_domain, 0, sizeof(self_domain));
-		if (!fp || !fgets(self_domain, sizeof(self_domain) - 1, fp) ||
-		    fclose(fp)) {
-			fprintf(stderr, "Can't open %s .\n",
-				proc_policy_self_domain);
-			exit(1);
-		}
-	}
-	fprintf(domain_fp, "select pid=%u\n", pid);
-	fprintf(domain_fp, "use_profile 255\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/domain_policy\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/domain_policy\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/exception_policy\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/exception_policy\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/profile\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/profile\n");
-}
-
-static void BUG(const char *fmt, ...)
-	__attribute__ ((format(printf, 1, 2)));
-
-static void BUG(const char *fmt, ...)
-{
-	va_list args;
-	printf("BUG: ");
-	va_start(args, fmt);
-	vprintf(fmt, args);
-	va_end(args);
-	putchar('\n');
-	fflush(stdout);
-	while (1)
-		sleep(100);
-}
-
-int write_domain_policy(const char *policy, int is_delete)
-{
-	FILE *fp = fopen(proc_policy_domain_policy, "r");
-	char buffer[8192];
-	int domain_found = 0;
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_domain_policy);
-		return 0;
-	}
-	if (is_delete)
-		fprintf(domain_fp, "delete ");
-	fprintf(domain_fp, "%s\n", policy);
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (!strncmp(buffer, "<kernel>", 8))
-			domain_found = !strcmp(self_domain, buffer);
-		if (!domain_found)
-			continue;
-		/* printf("<%s>\n", buffer); */
-		if (strcmp(buffer, policy))
-			continue;
-		policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (policy_found == is_delete) {
-		BUG("Can't %s %s", is_delete ? "delete" : "append",
-		    policy);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-
-}
-
-int write_exception_policy(const char *policy, int is_delete)
-{
-	FILE *fp = fopen(proc_policy_exception_policy, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_exception_policy);
-		return 0;
-	}
-	if (is_delete)
-		fprintf(exception_fp, "delete ");
-	fprintf(exception_fp, "%s\n", policy);
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (strcmp(buffer, policy))
-			continue;
-		policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (policy_found == is_delete) {
-		BUG("Can't %s %s", is_delete ? "delete" : "append",
-		    policy);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-
-}
-
-int set_profile(const int mode, const char *name)
-{
-	static const char *modes[4] = { "disabled", "learning", "permissive",
-					"enforcing" };
-	FILE *fp = fopen(proc_policy_profile, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	const int len = strlen(name);
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_profile);
-		return 0;
-	}
-	fprintf(profile_fp, "255-CONFIG::%s=%s\n", name, modes[mode]);
-	while (memset(buffer, 0, sizeof(buffer)),
-	       fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (strncmp(buffer, "255-CONFIG::", 12) ||
-		    strncmp(buffer + 12, name, len) ||
-		    buffer[12 + len] != '=')
-			continue;
-		if (strstr(buffer + 13 + len, modes[mode]))
-			policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (!policy_found) {
-		BUG("Can't change profile to 255-CONFIG::%s=%s",
-		    name, modes[mode]);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-}
testcases/kernel/security/tomoyo/newns.c deleted +0 -49
deleted file mode 100644
index f888ca31f..000000000
@@ -1,49 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Tetsuo Handa <[email protected]>, 2009      */
-/*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/mount.h>
-#include <unistd.h>
-#include <sched.h>
-#include <errno.h>
-#include <stdlib.h>
-#include "test.h"
-
-static int child(void *arg)
-{
-	char **argv = (char **)arg;
-	argv++;
-	mount("/tmp/", "/tmp/", "tmpfs", 0, NULL);
-	execvp(argv[0], argv);
-	_exit(1);
-}
-
-int main(int argc, char *argv[])
-{
-	char c = 0;
-	const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child, (void *)argv);
-	while (waitpid(pid, NULL, __WALL) == EOF && errno == EINTR)
-		c++;		/* Dummy. */
-	return 0;
-}
testcases/kernel/security/tomoyo/testall.sh deleted +0 -46
deleted file mode 100644
index b103be6c6..000000000
@@ -1,46 +0,0 @@
-#! /bin/sh
-################################################################################
-##                                                                            ##
-## Copyright (c) Tetsuo Handa <[email protected]>, 2009      ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-################################################################################
-
-cd ${0%/*}
-export PATH=$PWD:${PATH}
-
-echo "Testing all. (All results are reported)"
-newns tomoyo_accept_test
-newns tomoyo_filesystem_test
-newns tomoyo_file_test
-newns tomoyo_rewrite_test
-newns tomoyo_new_file_test
-newns tomoyo_new_test
-echo
-echo
-echo
-echo "Testing all. (Only ERRORS are reported)"
-newns tomoyo_accept_test | grep -vF Done
-newns tomoyo_filesystem_test | grep -vF OK | grep -F '('
-newns tomoyo_file_test | grep -vF OK | grep -F '('
-newns tomoyo_rewrite_test | grep -vF OK | grep -F '('
-newns tomoyo_new_test | grep -vF OK
-echo
-echo
-echo
-echo "Testing policy I/O.  (Only ERRORS are reported)"
-newns tomoyo_policy_io_test | grep -vF OK
-newns tomoyo_new_file_test | grep -vF OK
testcases/kernel/security/tomoyo/tomoyo_accept_test.c deleted +0 -146
deleted file mode 100644
index 335818a25..000000000
@@ -1,146 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_accept_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static void set_level(const int i)
-{
-	set_profile(i, "file::execute");
-	set_profile(i, "file::open");
-	set_profile(i, "file::create");
-	set_profile(i, "file::unlink");
-	set_profile(i, "file::mkdir");
-	set_profile(i, "file::rmdir");
-	set_profile(i, "file::mkfifo");
-	set_profile(i, "file::mksock");
-	set_profile(i, "file::truncate");
-	set_profile(i, "file::symlink");
-	set_profile(i, "file::rewrite");
-	set_profile(i, "file::mkblock");
-	set_profile(i, "file::mkchar");
-	set_profile(i, "file::link");
-	set_profile(i, "file::rename");
-	set_profile(i, "file::chmod");
-	set_profile(i, "file::chown");
-	set_profile(i, "file::chgrp");
-	set_profile(i, "file::ioctl");
-	set_profile(i, "file::chroot");
-	set_profile(i, "file::mount");
-	set_profile(i, "file::umount");
-	set_profile(i, "file::pivot_root");
-}
-
-static void test(int rw_loop, int truncate_loop, int append_loop,
-		 int create_loop)
-{
-	static const int rw_flags[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
-	static const int create_flags[3] = { 0, O_CREAT /* nonexistent */ ,
-		O_CREAT /* existent */
-	};
-	static const int truncate_flags[2] = { 0, O_TRUNC };
-	static const int append_flags[2] = { 0, O_APPEND };
-	int level;
-	int flags;
-	int i;
-	int fd;
-	static char buffer[1024];
-	memset(buffer, 0, sizeof(buffer));
-	snprintf(buffer, sizeof(buffer) - 1, "/tmp/file:a=%d:t=%d:c=%d:m=%d",
-		 append_loop, truncate_loop, create_loop, rw_loop);
-	fprintf(exception_fp, "deny_rewrite %s\n", buffer);
-	flags = rw_flags[rw_loop] | truncate_flags[truncate_loop] |
-	    append_flags[append_loop] | create_flags[create_loop];
-	for (i = 1; i < 8; i++)
-		fprintf(domain_fp, "delete %d %s\n", i, buffer);
-	for (level = 0; level < 4; level++) {
-		set_level(0);
-		if (create_loop == 1)
-			unlink(buffer);
-		else
-			close(open(buffer, O_CREAT, 0644));
-		set_level(level);
-		fd = open(buffer, flags, 0644);
-		if (fd != EOF)
-			close(fd);
-		else
-			fprintf(stderr, "%d: open(%04o) failed\n", level,
-				flags);
-		/*
-		   fd = open(buffer, flags, 0644)
-		   if (fd != EOF)
-		   close(fd);
-		   else
-		   fprintf(stderr, "%d: open(%04o) failed\n", level, flags);
-		 */
-		/*
-		   fd = open(buffer, flags, 0644);
-		   if (fd != EOF)
-		   close(fd);
-		   else
-		   fprintf(stderr, "%d: open(%04o) failed\n", level, flags);
-		 */
-	}
-	for (i = 1; i < 8; i++)
-		fprintf(domain_fp, "delete %d %s\n", i, buffer);
-	fprintf(domain_fp, "delete allow_truncate %s\n", buffer);
-	fprintf(domain_fp, "delete allow_create %s 0644\n", buffer);
-	fprintf(domain_fp, "delete allow_rewrite %s\n", buffer);
-	fd = open(buffer, flags, 0644);
-	if (fd != EOF) {
-		close(fd);
-		fprintf(stderr, "%d: open(%04o) didn't fail\n", 3, flags);
-	}
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-	fprintf(profile_fp, "255-PREFERENCE::learning={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::enforcing={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::permissive={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::disabled={ verbose=no }\n");
-	set_profile(0, "file");
-	fprintf(profile_fp, "255-PREFERENCE::learning={ max_entry=2048 }\n");
-	{
-		int append_loop;
-		for (append_loop = 0; append_loop < 2; append_loop++) {
-			int truncate_loop;
-			for (truncate_loop = 0; truncate_loop < 2;
-			     truncate_loop++) {
-				int create_loop;
-				for (create_loop = 0; create_loop < 3;
-				     create_loop++) {
-					int rw_loop;
-					for (rw_loop = 0; rw_loop < 4;
-					     rw_loop++)
-						test(rw_loop, truncate_loop,
-						     append_loop, create_loop);
-				}
-			}
-		}
-	}
-	fprintf(profile_fp, "255-CONFIG::file=disabled\n");
-	printf("Done\n");
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_file_test.c deleted +0 -304
deleted file mode 100644
index 003f47720..000000000
@@ -1,304 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_file_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static int should_fail = 0;
-
-static void show_prompt(const char *str)
-{
-	printf("Testing %35s: (%s) ", str,
-	       should_fail ? "must fail" : "should success");
-	errno = 0;
-}
-
-static void show_result(int result)
-{
-	if (should_fail) {
-		if (result == EOF) {
-			if (errno == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-		} else {
-			printf("BUG!\n");
-		}
-	} else {
-		if (result != EOF)
-			printf("OK\n");
-		else
-			printf("%s\n", strerror(errno));
-	}
-}
-
-static const char *dev_null_path = "/dev/null";
-static const char *truncate_path = "/tmp/truncate_test";
-static const char *ftruncate_path = "/tmp/ftruncate_test";
-static const char *open_creat_path = "/tmp/open_test";
-static const char *mknod_reg_path = "/tmp/mknod_reg_test";
-static const char *mknod_chr_path = "/tmp/mknod_chr_test";
-static const char *mknod_blk_path = "/tmp/mknod_blk_test";
-static const char *mknod_fifo_path = "/tmp/mknod_fifo_test";
-static const char *mknod_sock_path = "/tmp/mknod_sock_test";
-static const char *unlink_path = "/tmp/unlink_test";
-static const char *mkdir_path = "/tmp/mkdir_test";
-static const char *rmdir_path = "/tmp/rmdir_test";
-static const char *link_source_path = "/tmp/link_source_test";
-static const char *link_dest_path = "/tmp/link_dest_test";
-static const char *symlink_source_path = "/tmp/symlink_source_test";
-static const char *symlink_dest_path = "/tmp/symlink_dest_test";
-static const char *rename_source_path = "/tmp/rename_source_test";
-static const char *rename_dest_path = "/tmp/rename_dest_test";
-static const char *socket_path = "/tmp/socket_test";
-
-static int ftruncate_fd = EOF;
-
-static void stage_file_test(void)
-{
-	int fd;
-	{
-		const char buffer[] = "32768 61000";
-		show_prompt("sysctl(READ)");
-		show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0));
-		show_prompt("sysctl(WRITE)");
-		show_result(write_sysctl(TEST_SYSCTL_PATH, buffer));
-	}
-
-	/* QUESTION: Is there a file which can be passed to uselib()? */
-	show_prompt("uselib()");
-	show_result(uselib("/bin/true"));
-
-	{
-		int pipe_fd[2] = { EOF, EOF };
-		int error = 0;
-		fflush(stdout);
-		fflush(stderr);
-		if (pipe(pipe_fd) == -1)
-			err(1, "pipe");
-		if (fork() == 0) {
-			execl("/bin/true", "/bin/true", NULL);
-			if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-				err(1, "write");
-			_exit(0);
-		}
-		close(pipe_fd[1]);
-		(void)read(pipe_fd[0], &error, sizeof(error));
-		show_prompt("execve()");
-		errno = error;
-		show_result(error ? EOF : 0);
-	}
-
-	show_prompt("open(O_RDONLY)");
-	fd = open(dev_null_path, O_RDONLY);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_WRONLY)");
-	fd = open(dev_null_path, O_WRONLY);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_RDWR)");
-	fd = open(dev_null_path, O_RDWR);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_CREAT | O_EXCL)");
-	fd = open(open_creat_path, O_CREAT | O_EXCL, 0666);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_TRUNC)");
-	fd = open(truncate_path, O_TRUNC);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("truncate()");
-	show_result(truncate(truncate_path, 0));
-
-	show_prompt("ftruncate()");
-	show_result(ftruncate(ftruncate_fd, 0));
-
-	show_prompt("mknod(S_IFREG)");
-	show_result(mknod(mknod_reg_path, S_IFREG, 0));
-
-	show_prompt("mknod(S_IFCHR)");
-	show_result(mknod(mknod_chr_path, S_IFCHR, MKDEV(1, 3)));
-
-	show_prompt("mknod(S_IFBLK)");
-	show_result(mknod(mknod_blk_path, S_IFBLK, MKDEV(1, 0)));
-
-	show_prompt("mknod(S_IFIFO)");
-	show_result(mknod(mknod_fifo_path, S_IFIFO, 0));
-
-	show_prompt("mknod(S_IFSOCK)");
-	show_result(mknod(mknod_sock_path, S_IFSOCK, 0));
-
-	show_prompt("mkdir()");
-	show_result(mkdir(mkdir_path, 0600));
-
-	show_prompt("rmdir()");
-	show_result(rmdir(rmdir_path));
-
-	show_prompt("unlink()");
-	show_result(unlink(unlink_path));
-
-	show_prompt("symlink()");
-	show_result(symlink(symlink_dest_path, symlink_source_path));
-
-	show_prompt("link()");
-	show_result(link(link_source_path, link_dest_path));
-
-	show_prompt("rename()");
-	show_result(rename(rename_source_path, rename_dest_path));
-
-	{
-		struct sockaddr_un addr;
-		int fd;
-		memset(&addr, 0, sizeof(addr));
-		addr.sun_family = AF_UNIX;
-		strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-		fd = socket(AF_UNIX, SOCK_STREAM, 0);
-		show_prompt("unix_bind()");
-		show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)));
-		if (fd != EOF)
-			close(fd);
-	}
-
-	printf("\n\n");
-}
-
-static void create_files(void)
-{
-	mkdir(rmdir_path, 0700);
-	close(creat(link_source_path, 0600));
-	close(creat(rename_source_path, 0600));
-	close(creat(truncate_path, 0600));
-	close(creat(unlink_path, 0600));
-	ftruncate_fd = open(ftruncate_path, O_WRONLY | O_CREAT, 0600);
-}
-
-static void creanup_files(void)
-{
-	if (ftruncate_fd != EOF)
-		close(ftruncate_fd);
-	ftruncate_fd = EOF;
-	unlink(open_creat_path);
-	unlink(mknod_reg_path);
-	unlink(mknod_chr_path);
-	unlink(mknod_blk_path);
-	unlink(mknod_fifo_path);
-	unlink(mknod_sock_path);
-	rmdir(mkdir_path);
-	unlink(symlink_source_path);
-	unlink(symlink_dest_path);
-	unlink(link_source_path);
-	unlink(link_dest_path);
-	unlink(rename_source_path);
-	unlink(rename_dest_path);
-	unlink(truncate_path);
-	unlink(ftruncate_path);
-	unlink(socket_path);
-}
-
-static void set_file_enforce(int enforce)
-{
-	if (enforce) {
-		set_profile(3, "file::execute");
-		set_profile(3, "file::open");
-		set_profile(3, "file::create");
-		set_profile(3, "file::unlink");
-		set_profile(3, "file::mkdir");
-		set_profile(3, "file::rmdir");
-		set_profile(3, "file::mkfifo");
-		set_profile(3, "file::mksock");
-		set_profile(3, "file::truncate");
-		set_profile(3, "file::symlink");
-		set_profile(3, "file::rewrite");
-		set_profile(3, "file::mkblock");
-		set_profile(3, "file::mkchar");
-		set_profile(3, "file::link");
-		set_profile(3, "file::rename");
-		set_profile(3, "file::chmod");
-		set_profile(3, "file::chown");
-		set_profile(3, "file::chgrp");
-		set_profile(3, "file::ioctl");
-		set_profile(3, "file::chroot");
-		set_profile(3, "file::mount");
-		set_profile(3, "file::umount");
-		set_profile(3, "file::pivot_root");
-	} else {
-		set_profile(0, "file::execute");
-		set_profile(0, "file::open");
-		set_profile(0, "file::create");
-		set_profile(0, "file::unlink");
-		set_profile(0, "file::mkdir");
-		set_profile(0, "file::rmdir");
-		set_profile(0, "file::mkfifo");
-		set_profile(0, "file::mksock");
-		set_profile(0, "file::truncate");
-		set_profile(0, "file::symlink");
-		set_profile(0, "file::rewrite");
-		set_profile(0, "file::mkblock");
-		set_profile(0, "file::mkchar");
-		set_profile(0, "file::link");
-		set_profile(0, "file::rename");
-		set_profile(0, "file::chmod");
-		set_profile(0, "file::chown");
-		set_profile(0, "file::chgrp");
-		set_profile(0, "file::ioctl");
-		set_profile(0, "file::chroot");
-		set_profile(0, "file::mount");
-		set_profile(0, "file::umount");
-		set_profile(0, "file::pivot_root");
-	}
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-
-	printf("***** Testing file hooks in enforce mode. *****\n");
-	create_files();
-	should_fail = 1;
-	set_file_enforce(1);
-	stage_file_test();
-	set_file_enforce(0);
-	clear_status();
-	creanup_files();
-
-	printf("***** Testing file hooks in permissive mode. *****\n");
-	should_fail = 0;
-	create_files();
-	set_file_enforce(0);
-	stage_file_test();
-	creanup_files();
-
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c deleted +0 -633
deleted file mode 100644
index e6e3bb087..000000000
@@ -1,633 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_filesystem_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#define _GNU_SOURCE
-#include "include.h"
-
-static void show_prompt(const char *str, const int should_fail)
-{
-	printf("Testing %60s: (%s) ", str,
-	       should_fail ? "must fail" : "should success");
-	errno = 0;
-}
-
-#ifndef MS_MOVE
-#define MS_MOVE         8192
-#endif
-
-static const char *pivot_root_dir = "/sys/kernel/security/";
-
-static int child(void *arg)
-{
-	errno = 0;
-	pivot_root(pivot_root_dir, proc_policy_dir);
-	return errno;
-}
-
-static void mount2(const char *source, const char *target,
-		   const char *filesystemtype)
-{
-	if (mount(source, target, filesystemtype, 0, NULL)) {
-		printf("BUG: mount() failed\n");
-		fflush(stdout);
-	}
-}
-
-static const unsigned char compressed_ext2_image_sample[1350] = {
-	0x1F, 0x8B, 0x08, 0x00, 0xA8, 0xF2, 0x96, 0x4B, 0x02, 0x03, 0xED, 0xDC,
-	0x3D, 0x4B, 0x5B, 0x51, 0x18, 0x07, 0xF0, 0xE7, 0xDE, 0xAB, 0x14, 0x8C,
-	0xAB, 0xD5, 0x9A, 0xF8, 0x36, 0x0B, 0xA1, 0xE0, 0xE0, 0xDC, 0xD0, 0xAD,
-	0xD0, 0xC5, 0xAF, 0x50, 0x9C, 0x42, 0x1D, 0x6A, 0xE6, 0xA6, 0x9B, 0x9B,
-	0x8B, 0xD8, 0xA5, 0x5B, 0x97, 0x2E, 0xF9, 0x0E, 0x85, 0x4C, 0xF6, 0x23,
-	0x74, 0x70, 0x55, 0x28, 0x52, 0xA8, 0xDD, 0xED, 0xB9, 0xB9, 0xB1, 0xA6,
-	0xEA, 0x24, 0xA5, 0x81, 0xDE, 0xDF, 0x0F, 0x9E, 0xDC, 0xB7, 0x13, 0x2E,
-	0xF7, 0xC0, 0xFF, 0x70, 0xCE, 0x85, 0x24, 0x02, 0xA8, 0xAB, 0x7E, 0xF9,
-	0x31, 0x13, 0xB1, 0x95, 0x36, 0xA7, 0x45, 0x44, 0x2F, 0x6D, 0xB3, 0xC9,
-	0x06, 0xEB, 0x55, 0xF5, 0xC7, 0x87, 0x9F, 0x7E, 0x1C, 0xBF, 0x88, 0x68,
-	0xC5, 0xCE, 0xF7, 0x6C, 0xD4, 0x6E, 0x74, 0xFC, 0xF2, 0x62, 0x74, 0xED,
-	0xFA, 0x7B, 0x8D, 0xB8, 0x69, 0x9F, 0x8F, 0xCF, 0x9F, 0x1D, 0x7E, 0x78,
-	0xF7, 0x6D, 0xD8, 0x79, 0xFF, 0x71, 0xD0, 0xED, 0xBC, 0xCD, 0x9A, 0xBD,
-	0x69, 0x3C, 0xEB, 0xE0, 0xCB, 0xF0, 0xA4, 0xF9, 0xF5, 0xF9, 0xCA, 0xE0,
-	0xE0, 0x72, 0xBB, 0x7B, 0xD4, 0x1A, 0xE6, 0x13, 0xD7, 0xAA, 0xE7, 0x82,
-	0x7A, 0x29, 0xAA, 0xF8, 0xC7, 0xEC, 0x28, 0xFF, 0xBD, 0xC8, 0x75, 0x09,
-	0xD4, 0xC6, 0x55, 0x92, 0x4D, 0x71, 0xFA, 0x71, 0x05, 0x4C, 0xCF, 0xA3,
-	0xBB, 0xE3, 0x01, 0x50, 0x0F, 0x93, 0xEB, 0xDF, 0xEB, 0xFA, 0x97, 0x13,
-	0x80, 0x8B, 0x67, 0xD5, 0x02, 0xE4, 0xEE, 0xFD, 0x8B, 0x3F, 0xD6, 0x22,
-	0x0B, 0xA6, 0x6A, 0xC0, 0x5F, 0xF6, 0xB9, 0x1C, 0x7F, 0x9E, 0xDE, 0x37,
-	0xFE, 0xE4, 0xB1, 0x34, 0xD1, 0xEE, 0x71, 0xAA, 0xC5, 0x54, 0xE5, 0xB9,
-	0x27, 0xA9, 0x96, 0x53, 0x35, 0xA3, 0x7C, 0x13, 0x1A, 0xB1, 0x92, 0x6A,
-	0x35, 0xD5, 0xDA, 0xF8, 0x75, 0xE9, 0x86, 0x6E, 0x05, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x81,
-	0xCA, 0xDF, 0xD8, 0xCF, 0x47, 0x96, 0xB7, 0x7F, 0xEF, 0xE7, 0x79, 0xBB,
-	0x5D, 0xFD, 0x87, 0xDF, 0x79, 0x31, 0x97, 0x77, 0xF7, 0xDE, 0xEC, 0x6F,
-	0xEE, 0xEE, 0xF5, 0x5E, 0xBF, 0xD2, 0x57, 0xF0, 0xBF, 0x69, 0xDC, 0xCA,
-	0xFF, 0xCF, 0xA2, 0xCA, 0x3F, 0x50, 0x13, 0x33, 0xBA, 0x00, 0xE4, 0x1F,
-	0x90, 0x7F, 0x40, 0xFE, 0x01, 0xF9, 0x07, 0xE4, 0x1F, 0x90, 0x7F, 0x40,
-	0xFE, 0x01, 0xF9, 0x07, 0xE4, 0x1F, 0x90, 0x7F, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFA, 0xF9, 0x05, 0x34, 0xF2,
-	0x14, 0x08, 0x00, 0x00, 0x10, 0x00
-};
-
-int main(void)
-{
-	char c = 0;
-	tomoyo_test_init();
-
-	/* Test mount(). */
-	{
-		set_profile(3, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 1);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(1, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 0);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == ENOMEM)
-			printf("OK: Out of memory.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(3, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 0);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == ENOMEM)
-			printf("OK: Out of memory.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount dev\\011name / "
-			"fs\\011name 0\n");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 1);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(1, "file::mount");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		set_profile(3, "file::mount");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		show_prompt("mount('anydev', '/', 'tmpfs') ", 0);
-		if (mount("anydev", "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		fprintf(domain_fp, "delete allow_mount <NULL> / tmpfs 0\n");
-		fprintf(domain_fp, "allow_mount anydev / tmpfs 0\n");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		fprintf(domain_fp, "delete allow_mount anydev / tmpfs 0\n");
-		set_profile(2, "file::mount");
-		show_prompt("mount(NULL, NULL, 'tmpfs') ", 1);
-		if (mount(NULL, NULL, "tmpfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount(NULL, NULL, NULL) ", 1);
-		if (mount(NULL, NULL, NULL, 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', NULL, NULL) ", 1);
-		if (mount("/", NULL, NULL, 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', NULL, 'tmpfs') ", 1);
-		if (mount("/", NULL, "tmpfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', '/', 'nonexistentfs') ", 1);
-		if (mount("/", "/", "nonexistentfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		set_profile(0, "file::mount");
-	}
-
-	mkdir("/tmp/mount/", 0755);
-	mkdir("/tmp/mount_bind/", 0755);
-	mkdir("/tmp/mount_move/", 0755);
-
-	/* Test mount(). */
-	{
-		static char buf[4096];
-		char *dev_ram_path = realpath("/dev/ram0", NULL);
-		if (!dev_ram_path)
-			dev_ram_path = realpath("/dev/ram", NULL);
-		if (!dev_ram_path) {
-			dev_ram_path = "/dev/ram0";
-			mknod(dev_ram_path, S_IFBLK, MKDEV(1, 0));
-		}
-		memset(buf, 0, sizeof(buf));
-		{
-			struct stat sbuf;
-			FILE *fp = NULL;
-			snprintf(buf, sizeof(buf) - 1, "zcat - > %s",
-				 dev_ram_path);
-			if (lstat(dev_ram_path, &sbuf) == 0 &&
-			    S_ISBLK(sbuf.st_mode) && MAJOR(sbuf.st_rdev) == 1)
-				fp = popen(buf, "w");
-			if (fp) {
-				if (fwrite(compressed_ext2_image_sample, 1,
-					   sizeof(compressed_ext2_image_sample),
-					   fp) !=
-				    sizeof(compressed_ext2_image_sample))
-					err(1, "fwrite");
-				pclose(fp);
-			} else
-				fprintf(stderr, "Can't write to %s .\n",
-					dev_ram_path);
-		}
-		set_profile(3, "file::mount");
-
-		/* Test standard case */
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/mount/'", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test device_name with pattern */
-		snprintf(buf, sizeof(buf) - 1, "mount('%s', '/tmp/mount/', "
-			 "'ext2') for '%s\\*'", dev_ram_path, dev_ram_path);
-		show_prompt(buf, 1);
-		if (mount(dev_ram_path, "/tmp/mount/", "ext2", MS_RDONLY, NULL)
-		    == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test dir_name with pattern */
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test standard case */
-		fprintf(domain_fp, "allow_mount none /tmp/mount/ tmpfs 0\n");
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/mount/'", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp,
-			"delete allow_mount none /tmp/mount/ tmpfs 0\n");
-
-		/* Test device_name with pattern */
-		fprintf(domain_fp, "allow_mount %s\\* /tmp/mount/ ext2 1\n",
-			dev_ram_path);
-		snprintf(buf, sizeof(buf) - 1, "mount('%s', '/tmp/mount/', "
-			 "'ext2') for '%s\\*'", dev_ram_path, dev_ram_path);
-		show_prompt(buf, 0);
-		if (mount(dev_ram_path, "/tmp/mount/", "ext2", MS_RDONLY, NULL)
-		    == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount %s\\* "
-			"/tmp/mount/ ext2 1\n", dev_ram_path);
-
-		/* Test dir_name with pattern */
-		fprintf(domain_fp,
-			"allow_mount none /tmp/\\?\\?\\?\\?\\?/ tmpfs 0\n");
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount none "
-			"/tmp/\\?\\?\\?\\?\\?/ tmpfs 0\n");
-
-		set_profile(0, "file::mount");
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test mount(). */
-	{
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::mount");
-
-		/* Test remount case */
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", MS_REMOUNT, NULL)
-		    == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 1);
-		if (mount(NULL, "/tmp/mount/", NULL, MS_REMOUNT, NULL) == EOF
-		    && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "allow_mount something /tmp/mount/ "
-			"--remount 0\n");
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 0);
-		if (mount(NULL, "/tmp/mount/", NULL, MS_REMOUNT, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success.\n");
-		fprintf(domain_fp, "delete allow_mount something /tmp/mount/ "
-			"--remount 0\n");
-
-		/* Test bind case */
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_bind/', "
-			    "MS_BIND)", 1);
-		if (mount("/tmp/mount/", "/tmp/mount_bind/", NULL, MS_BIND,
-			  NULL) == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test move case */
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_move/', "
-			    "MS_MOVE)", 1);
-		if (mount("/tmp/mount/", "/tmp/mount_move/", NULL, MS_MOVE,
-			  NULL) == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test remount case */
-		fprintf(domain_fp, "allow_mount any /tmp/mount/ --remount 0\n");
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", MS_REMOUNT, NULL)
-		    == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount any /tmp/mount/ "
-			"--remount 0\n");
-
-		/* Test bind case */
-		fprintf(domain_fp,
-			"allow_mount /tmp/mount/ /tmp/mount_bind/ --bind 0\n");
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_bind', MS_BIND)",
-			    0);
-		if (mount("/tmp/mount/", "/tmp/mount_bind/", NULL, MS_BIND,
-			  NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		set_profile(0, "file::mount");
-		umount("/tmp/mount_bind/");
-		fprintf(domain_fp, "delete allow_mount /tmp/mount/ "
-			"/tmp/mount_bind/ --bind 0\n");
-
-		/* Test move case */
-		set_profile(3, "file::mount");
-		fprintf(domain_fp, "allow_unmount /tmp/mount/\n");
-		fprintf(domain_fp, "allow_mount /tmp/mount/ /tmp/mount_move/ "
-			"--move 0\n");
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_move/', "
-			    "MS_MOVE)", 0);
-		if (mount("/tmp/mount/", "/tmp/mount_move/", NULL, MS_MOVE,
-			  NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		set_profile(0, "file::mount");
-		umount("/tmp/mount_move/");
-		fprintf(domain_fp, "delete allow_unmount /tmp/mount/\n");
-		fprintf(domain_fp, "delete allow_mount /tmp/mount/ "
-			"/tmp/mount_move/ --move 0\n");
-
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test umount(). */
-	{
-		/* Test standard case */
-		fprintf(domain_fp, "allow_unmount /tmp/mount/\n");
-
-		set_profile(0, "file::umount");
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for '/tmp/mount/'", 0);
-		if (umount("/tmp/mount/") == 0)
-			printf("OK\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_unmount /tmp/mount/\n");
-
-		set_profile(0, "file::umount");
-
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for '/tmp/mount/'", 1);
-		if (umount("/tmp/mount/") == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		/* Test pattern */
-		fprintf(domain_fp, "allow_unmount /tmp/\\?\\?\\?\\?\\?/\n");
-		set_profile(0, "file::umount");
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 1);
-		if (umount("/tmp/mount/") == 0)
-			printf("OK\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp,
-			"delete allow_unmount /tmp/\\?\\?\\?\\?\\?/\n");
-
-		set_profile(0, "file::umount");
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test chroot(). */
-	{
-		set_profile(3, "file::chroot");
-
-		/* Test standard case */
-		fprintf(domain_fp, "allow_chroot /tmp/mount/\n");
-		show_prompt("chroot('/tmp/mount/') for '/tmp/mount/'", 0);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == 0)
-				printf("OK\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-		fprintf(domain_fp, "delete allow_chroot /tmp/mount/\n");
-
-		show_prompt("chroot('/tmp/mount/') for '/tmp/mount/'", 1);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == EOF && errno == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("BUG: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-
-		/* Test pattern */
-		fprintf(domain_fp, "allow_chroot /tmp/\\?\\?\\?\\?\\?/\n");
-		show_prompt("chroot('/tmp/mount/') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 0);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == 0)
-				printf("OK\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-		fprintf(domain_fp,
-			"delete allow_chroot /tmp/\\?\\?\\?\\?\\?/\n");
-
-		set_profile(0, "file::chroot");
-	}
-
-	/* Test pivot_root(). */
-	{
-		int error;
-		static char stack[8192];
-		set_profile(3, "file::pivot_root");
-		fprintf(domain_fp, "allow_pivot_root %s %s\n",
-			pivot_root_dir, proc_policy_dir);
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 0);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		fprintf(domain_fp, "delete allow_pivot_root %s %s\n",
-			pivot_root_dir, proc_policy_dir);
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 1);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		set_profile(2, "file::pivot_root");
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 0);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		set_profile(0, "file::pivot_root");
-
-	}
-
-	rmdir("/tmp/mount_move/");
-	rmdir("/tmp/mount_bind/");
-	rmdir("/tmp/mount/");
-
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_new_file_test.c deleted +0 -627
deleted file mode 100644
index eb912d726..000000000
@@ -1,627 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_new_file_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static const char *policy = "";
-
-static void show_result(int result, char should_success)
-{
-	int error = errno;
-	printf("%s : ", policy);
-	if (should_success) {
-		if (result != EOF)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(error));
-	} else {
-		if (result == EOF) {
-			if (error == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("FAILED: %s\n", strerror(error));
-		} else {
-			printf("BUG: didn't fail.\n");
-		}
-	}
-}
-
-static void create2(const char *pathname)
-{
-	set_profile(0, "file::create");
-	set_profile(0, "file::open");
-	close(creat(pathname, 0600));
-	set_profile(3, "file::create");
-	set_profile(3, "file::open");
-	errno = 0;
-}
-
-static void mkdir2(const char *pathname)
-{
-	set_profile(0, "file::mkdir");
-	mkdir(pathname, 0600);
-	set_profile(3, "file::mkdir");
-	errno = 0;
-}
-
-static void unlink2(const char *pathname)
-{
-	set_profile(0, "file::unlink");
-	unlink(pathname);
-	set_profile(3, "file::unlink");
-	errno = 0;
-}
-
-static void rmdir2(const char *pathname)
-{
-	set_profile(0, "file::rmdir");
-	rmdir(pathname);
-	set_profile(3, "file::rmdir");
-	errno = 0;
-}
-
-static void mkfifo2(const char *pathname)
-{
-	set_profile(0, "file::mkfifo");
-	mkfifo(pathname, 0600);
-	set_profile(3, "file::mkfifo");
-	errno = 0;
-}
-
-static void stage_file_test(void)
-{
-	const char buffer[] = "32768 61000";
-	int pipe_fd[2] = { EOF, EOF };
-	int error = 0;
-	int fd;
-	char pbuffer[1024];
-	struct stat sbuf;
-	struct sockaddr_un addr;
-	struct ifreq ifreq;
-	char *filename = "";
-	set_profile(3, "file::execute");
-	set_profile(3, "file::open");
-	set_profile(3, "file::create");
-	set_profile(3, "file::unlink");
-	set_profile(3, "file::mkdir");
-	set_profile(3, "file::rmdir");
-	set_profile(3, "file::mkfifo");
-	set_profile(3, "file::mksock");
-	set_profile(3, "file::truncate");
-	set_profile(3, "file::symlink");
-	set_profile(3, "file::rewrite");
-	set_profile(3, "file::mkblock");
-	set_profile(3, "file::mkchar");
-	set_profile(3, "file::link");
-	set_profile(3, "file::rename");
-	set_profile(3, "file::chmod");
-	set_profile(3, "file::chown");
-	set_profile(3, "file::chgrp");
-	set_profile(3, "file::ioctl");
-	set_profile(3, "file::chroot");
-	set_profile(3, "file::mount");
-	set_profile(3, "file::umount");
-	set_profile(3, "file::pivot_root");
-
-	policy = "allow_read /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 0);
-
-	policy = "allow_write /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 1);
-	write_domain_policy(policy, 1);
-	show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 0);
-
-	policy = "allow_read/write /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) &&
-	            write_sysctl(TEST_SYSCTL_PATH, buffer), 1);
-	write_domain_policy(policy, 1);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) &&
-	            write_sysctl(TEST_SYSCTL_PATH, buffer), 0);
-
-	policy = "allow_read /bin/true";
-	write_domain_policy(policy, 0);
-	show_result(uselib("/bin/true"), 1);
-	write_domain_policy(policy, 1);
-	show_result(uselib("/bin/true"), 0);
-
-	policy = "allow_execute /bin/true";
-	write_domain_policy(policy, 0);
-	fflush(stdout);
-	fflush(stderr);
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	if (fork() == 0) {
-		execl("/bin/true", "/bin/true", NULL);
-		if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-			err(1, "write");
-		exit(0);
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	wait(NULL);
-	errno = error;
-	show_result(error ? EOF : 0, 1);
-	write_domain_policy(policy, 1);
-	fflush(stdout);
-	fflush(stderr);
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	if (fork() == 0) {
-		execl("/bin/true", "/bin/true", NULL);
-		if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-			err(1, "write");
-		_exit(0);
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	wait(NULL);
-	errno = error;
-	show_result(errno ? EOF : 0, 0);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	set_profile(3, "file::mkfifo");
-	policy = "allow_mkfifo /tmp/mknod_fifo_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_fifo_test";
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 0);
-
-	memset(pbuffer, 0, sizeof(pbuffer));
-	memset(&sbuf, 0, sizeof(sbuf));
-	filename = "/dev/null";
-	stat(filename, &sbuf);
-	snprintf(pbuffer, sizeof(pbuffer) - 1, "allow_write %s", filename);
-	policy = pbuffer;
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read/write /tmp/fifo";
-	mkfifo2("/tmp/fifo");
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/fifo", O_RDWR);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/fifo", O_RDWR);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_write /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_WRONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read/write /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDWR);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDWR);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 0);
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 1);
-
-	filename = "/tmp/truncate_test";
-	create2(filename);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	show_result(truncate(filename, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(truncate(filename, 0), 0);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	set_profile(0, "file::open");
-	fd = open(filename, O_WRONLY);
-	set_profile(3, "file::open");
-	show_result(ftruncate(fd, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(ftruncate(fd, 0), 0);
-	if (fd != EOF)
-		close(fd);
-
-	unlink2(filename);
-
-	policy = "allow_create /tmp/mknod_reg_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_reg_test";
-	show_result(mknod(filename, S_IFREG | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFREG | 0644, 0), 0);
-
-	policy = "allow_mkchar /tmp/mknod_chr_test 0644 1 3";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_chr_test";
-	show_result(mknod(filename, S_IFCHR | 0644, MKDEV(1, 3)), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFCHR | 0644, MKDEV(1, 3)), 0);
-
-	policy = "allow_mkblock /tmp/mknod_blk_test 0644 1 0";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_blk_test";
-	show_result(mknod(filename, S_IFBLK | 0644, MKDEV(1, 0)), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFBLK | 0644, MKDEV(1, 0)), 0);
-
-	policy = "allow_mkfifo /tmp/mknod_fifo_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_fifo_test";
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 0);
-
-	policy = "allow_mksock /tmp/mknod_sock_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_sock_test";
-	show_result(mknod(filename, S_IFSOCK | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFSOCK | 0644, 0), 0);
-
-	policy = "allow_mkdir /tmp/mkdir_test/ 0600";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mkdir_test";
-	show_result(mkdir(filename, 0600), 1);
-	write_domain_policy(policy, 1);
-	rmdir2(filename);
-	show_result(mkdir(filename, 0600), 0);
-
-	policy = "allow_rmdir /tmp/rmdir_test/";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/rmdir_test";
-	mkdir2(filename);
-	show_result(rmdir(filename), 1);
-	write_domain_policy(policy, 1);
-	mkdir2(filename);
-	show_result(rmdir(filename), 0);
-	rmdir2(filename);
-
-	policy = "allow_unlink /tmp/unlink_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/unlink_test";
-	create2(filename);
-	show_result(unlink(filename), 1);
-	write_domain_policy(policy, 1);
-	create2(filename);
-	show_result(unlink(filename), 0);
-	unlink2(filename);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_link /tmp/link_source_test /tmp/link_dest_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/link_source_test";
-	create2(filename);
-	show_result(link(filename, "/tmp/link_dest_test"), 1);
-	write_domain_policy(policy, 1);
-	unlink2("/tmp/link_dest_test");
-	show_result(link(filename, "/tmp/link_dest_test"), 0);
-	unlink2(filename);
-
-	policy = "allow_rename /tmp/rename_source_test /tmp/rename_dest_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/rename_source_test";
-	create2(filename);
-	show_result(rename(filename, "/tmp/rename_dest_test"), 1);
-	write_domain_policy(policy, 1);
-	unlink2("/tmp/rename_dest_test");
-	create2(filename);
-	show_result(rename(filename, "/tmp/rename_dest_test"), 0);
-	unlink2(filename);
-
-	policy = "allow_mksock /tmp/socket_test 0755";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/socket_test";
-	memset(&addr, 0, sizeof(addr));
-	addr.sun_family = AF_UNIX;
-	strncpy(addr.sun_path, filename, sizeof(addr.sun_path) - 1);
-	fd = socket(AF_UNIX, SOCK_STREAM, 0);
-	show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)), 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	fd = socket(AF_UNIX, SOCK_STREAM, 0);
-	show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)), 0);
-	if (fd != EOF)
-		close(fd);
-
-	filename = "/tmp/rewrite_test";
-	create2(filename);
-	policy = "allow_read/write /tmp/rewrite_test";
-	write_domain_policy(policy, 0);
-	write_exception_policy("deny_rewrite /tmp/rewrite_test", 0);
-	policy = "allow_truncate /tmp/rewrite_test";
-	write_domain_policy(policy, 0);
-
-	fd = open(filename, O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_APPEND);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_TRUNC | O_APPEND);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	show_result(truncate(filename, 0), 0);
-
-	set_profile(0, "file::open");
-	fd = open(filename, O_WRONLY | O_APPEND);
-	set_profile(3, "file::open");
-	show_result(ftruncate(fd, 0), 0);
-
-	show_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_APPEND), 0);
-	if (fd != EOF)
-		close(fd);
-
-	write_domain_policy(policy, 1);
-
-	policy = "allow_read/write /tmp/rewrite_test";
-	write_domain_policy(policy, 1);
-	write_exception_policy("deny_rewrite /tmp/rewrite_test", 1);
-
-	unlink2(filename);
-
-	policy = "allow_ioctl socket:[family=2:type=2:protocol=17] "
-	    "35122-35124";
-	write_domain_policy(policy, 0);
-	fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
-	memset(&ifreq, 0, sizeof(ifreq));
-	snprintf(ifreq.ifr_name, sizeof(ifreq.ifr_name) - 1, "lo");
-	show_result(ioctl(fd, 35123, &ifreq), 1);
-	write_domain_policy(policy, 1);
-	policy = "allow_ioctl " "socket:[family=2:type=2:protocol=17] 0-35122";
-	write_domain_policy(policy, 0);
-	show_result(ioctl(fd, 35123, &ifreq), 0);
-	write_domain_policy(policy, 1);
-	if (fd != EOF)
-		close(fd);
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-	fprintf(domain_fp, "%s /bin/true\n", self_domain);
-	fprintf(domain_fp, "use_profile 255\n");
-	fprintf(domain_fp, "select pid=%u\n", pid);
-	fprintf(profile_fp, "255-PREFERENCE::audit={ max_reject_log=1024 }\n");
-	stage_file_test();
-	fprintf(domain_fp, "use_profile 0\n");
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_new_test.c deleted +0 -652
deleted file mode 100644
index a1ab259e5..000000000
@@ -1,652 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_new_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static int result;
-static int error;
-
-static void show_result(const char *test, int should_success)
-{
-	error = errno;
-	printf("%s : ", test);
-	if (should_success) {
-		if (error == 0)
-			printf("OK (%d)\n", result);
-		else
-			printf("FAILED: %s\n", strerror(error));
-	} else {
-		if (error == 0)
-			printf("BUG: Didn't fail (%d)\n", result);
-		else if (error == EPERM)
-			printf("OK: permission denied\n");
-		else
-			printf("FAILED: %s\n", strerror(error));
-	}
-}
-
-static void test_read_etc_fstab(void)
-{
-	result = open("/etc/fstab", O_RDONLY);
-}
-
-static void test_write_dev_null(void)
-{
-	result = open("/dev/null", O_WRONLY);
-}
-
-static void cleanup_file_open(void)
-{
-	if (result != EOF)
-		close(result);
-}
-
-static void test_mkdir_testdir(void)
-{
-	result = mkdir("/tmp/testdir", 0755);
-}
-
-static void cleanup_mkdir_testdir(void)
-{
-	rmdir("/tmp/testdir");
-}
-
-static void setup_mkdir_testdir(void)
-{
-	mkdir("/tmp/testdir", 0755);
-}
-
-static void test_rmdir_testdir(void)
-{
-	result = rmdir("/tmp/testdir");
-}
-
-static void setup_execute_bin_true(void)
-{
-	fprintf(domain_fp, "%s /bin/true\n", self_domain);
-	fprintf(domain_fp, "use_profile 0\n");
-	fprintf(domain_fp, "select pid=%u\n", pid);
-}
-
-static void cleanup_execute_bin_true(void)
-{
-	wait(NULL);
-	fprintf(domain_fp, "delete %s /bin/true\n", self_domain);
-	fprintf(domain_fp, "select pid=%u\n", pid);
-}
-
-static void test_execute_bin_true(void)
-{
-	char *argv[] = { "/bin/true", NULL };
-	char *envp[] = { "HOME=/", NULL };
-	int pipe_fd[2] = { EOF, EOF };
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	switch (fork()) {
-	case 0:
-		execve("/bin/true", argv, envp);
-		error = errno;
-		if (write(pipe_fd[1], &error, sizeof(error)) == -1)
-			err(1, "write");
-		_exit(0);
-		break;
-	case -1:
-		error = ENOMEM;
-		break;
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	result = error ? EOF : 0;
-	errno = error;
-}
-
-static void test_chmod_dev_null(void)
-{
-	result = chmod("/dev/null", 0666);
-}
-
-static void test_chown_dev_null(void)
-{
-	result = chown("/dev/null", 0, -1);
-}
-
-static void test_chgrp_dev_null(void)
-{
-	result = chown("/dev/null", -1, 0);
-}
-
-static void test_ioctl_dev_null(void)
-{
-	int fd = open("/dev/null", O_RDWR);
-	errno = 0;
-	result = ioctl(fd, 0x5451, NULL);
-	error = errno;
-	close(fd);
-	errno = error;
-}
-
-static void setup_chmod_group(void)
-{
-	write_exception_policy("path_group CHMOD_TARGET /dev/null", 0);
-	write_exception_policy("number_group CHMOD_MODES 0666", 0);
-}
-
-static void cleanup_chmod_group(void)
-{
-	write_exception_policy("path_group CHMOD_TARGET /dev/null", 1);
-	write_exception_policy("number_group CHMOD_MODES 0666", 1);
-}
-
-static void setup_chown_group(void)
-{
-	write_exception_policy("path_group CHOWN_TARGET /dev/\\*", 0);
-	write_exception_policy("number_group CHOWN_IDS 0x0-0xFFFE", 0);
-}
-
-static void cleanup_chown_group(void)
-{
-	write_exception_policy("path_group CHOWN_TARGET /dev/\\*", 1);
-	write_exception_policy("number_group CHOWN_IDS 0x0-0xFFFE", 1);
-}
-
-static void setup_ioctl_group(void)
-{
-	write_exception_policy("path_group IOCTL_TARGET /dev/\\*", 0);
-	write_exception_policy("number_group IOCTL_NUMBERS 0x5450-0x5452", 0);
-}
-
-static void cleanup_ioctl_group(void)
-{
-	write_exception_policy("path_group IOCTL_TARGET /dev/\\*", 1);
-	write_exception_policy("number_group IOCTL_NUMBERS 0x5450-0x5452", 1);
-}
-
-static void setup_open_group(void)
-{
-	write_exception_policy("path_group READABLE /etc/\\*", 0);
-	write_exception_policy("number_group READABLE_IDS 0-0xFFF", 0);
-}
-
-static void cleanup_open_group(void)
-{
-	cleanup_file_open();
-	write_exception_policy("path_group READABLE /etc/\\*", 1);
-	write_exception_policy("number_group READABLE_IDS 0-0xFFF", 1);
-}
-
-static void test_file_open_0(void)
-{
-	result = open("/tmp/testfile0", O_RDONLY, 0600);
-}
-
-static void test_file_open_1(void)
-{
-	result = open("/tmp/testfile1", O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_2(void)
-{
-	result = open("/tmp/testfile2", O_TRUNC | O_RDONLY, 0600);
-}
-
-static void test_file_open_3(void)
-{
-	result = open("/tmp/testfile3", O_TRUNC | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_4(void)
-{
-	result = open("/tmp/testfile4", O_APPEND | O_RDONLY, 0600);
-}
-
-static void test_file_open_5(void)
-{
-	result = open("/tmp/testfile5", O_APPEND | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_6(void)
-{
-	result = open("/tmp/testfile6", O_APPEND | O_TRUNC | O_RDONLY, 0600);
-}
-
-static void test_file_open_7(void)
-{
-	result = open("/tmp/testfile7",
-		      O_APPEND | O_TRUNC | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_8(void)
-{
-	result = open("/tmp/testfile8", O_WRONLY, 0600);
-}
-
-static void test_file_open_9(void)
-{
-	result = open("/tmp/testfile9", O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_10(void)
-{
-	result = open("/tmp/testfile10", O_TRUNC | O_WRONLY, 0600);
-}
-
-static void test_file_open_11(void)
-{
-	result = open("/tmp/testfile11", O_TRUNC | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_12(void)
-{
-	result = open("/tmp/testfile12", O_APPEND | O_WRONLY, 0600);
-}
-
-static void test_file_open_13(void)
-{
-	result = open("/tmp/testfile13", O_APPEND | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_14(void)
-{
-	result = open("/tmp/testfile14", O_APPEND | O_TRUNC | O_WRONLY, 0600);
-}
-
-static void test_file_open_15(void)
-{
-	result = open("/tmp/testfile15",
-		      O_APPEND | O_TRUNC | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_16(void)
-{
-	result = open("/tmp/testfile16", O_RDWR, 0600);
-}
-
-static void test_file_open_17(void)
-{
-	result = open("/tmp/testfile17", O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_18(void)
-{
-	result = open("/tmp/testfile18", O_TRUNC | O_RDWR, 0600);
-}
-
-static void test_file_open_19(void)
-{
-	result = open("/tmp/testfile19", O_TRUNC | O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_20(void)
-{
-	result = open("/tmp/testfile20", O_APPEND | O_RDWR, 0600);
-}
-
-static void test_file_open_21(void)
-{
-	result = open("/tmp/testfile21", O_APPEND | O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_22(void)
-{
-	result = open("/tmp/testfile22", O_APPEND | O_TRUNC | O_RDWR, 0600);
-}
-
-static void test_file_open_23(void)
-{
-	result = open("/tmp/testfile23", O_APPEND | O_TRUNC | O_CREAT | O_RDWR,
-		      0600);
-}
-
-static void setup_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i += 2) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		close(open(buffer, O_WRONLY | O_CREAT, 0600));
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 0);
-}
-
-static void setup_test_file_truncate(void)
-{
-	setup_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 0);
-	set_profile(3, "file::truncate");
-}
-
-static void setup_all_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i++) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		close(open(buffer, O_WRONLY | O_CREAT, 0600));
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 0);
-}
-
-static void setup_all_test_file_truncate(void)
-{
-	setup_all_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 0);
-	set_profile(3, "file::truncate");
-}
-
-static void cleanup_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i++) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		unlink(buffer);
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 1);
-	cleanup_file_open();
-}
-
-static void cleanup_test_file_truncate(void)
-{
-	cleanup_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 1);
-	set_profile(0, "file::truncate");
-}
-
-static struct test_struct {
-	void (*do_setup) (void);
-	void (*do_test) (void);
-	void (*do_cleanup) (void);
-	const char *name;
-	const char *policy;
-} tests[] = {
-	{
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	setup_open_group, test_read_etc_fstab, cleanup_open_group,
-		    "file::open", "allow_read @READABLE"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	NULL, test_chmod_dev_null, NULL, "file::chmod",
-		    "allow_chmod /dev/null 0666"}, {
-	NULL, test_chown_dev_null, NULL, "file::chown",
-		    "allow_chown /dev/null 0"}, {
-	NULL, test_chgrp_dev_null, NULL, "file::chgrp",
-		    "allow_chgrp /dev/null 0"}, {
-	NULL, test_ioctl_dev_null, NULL, "file::ioctl",
-		    "allow_ioctl /dev/null 0x5451"}, {
-	setup_chmod_group, test_chmod_dev_null, cleanup_chmod_group,
-		    "file::chmod", "allow_chmod @CHMOD_TARGET @CHMOD_MODES"}, {
-	setup_chown_group, test_chown_dev_null, cleanup_chown_group,
-		    "file::chown", "allow_chown @CHOWN_TARGET @CHOWN_IDS"}, {
-	setup_chown_group, test_chgrp_dev_null, cleanup_chown_group,
-		    "file::chgrp", "allow_chgrp @CHOWN_TARGET @CHOWN_IDS"}, {
-	setup_ioctl_group, test_ioctl_dev_null, cleanup_ioctl_group,
-		    "file::ioctl", "allow_ioctl @IOCTL_TARGET @IOCTL_NUMBERS"},
-	{
-	setup_test_file, test_file_open_0, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile0"}, {
-	setup_test_file, test_file_open_1, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile1"}, {
-	setup_test_file, test_file_open_1, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile1 0600"}, {
-	setup_test_file, test_file_open_2, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile2"}, {
-	setup_test_file, test_file_open_2, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile2"}, {
-	setup_test_file_truncate, test_file_open_2,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile2"}, {
-	setup_test_file, test_file_open_3, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile3"}, {
-	setup_test_file, test_file_open_3, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile3 0600"}, {
-	setup_test_file, test_file_open_4, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile4"}, {
-	setup_test_file, test_file_open_5, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile5"}, {
-	setup_test_file, test_file_open_5, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile5 0600"}, {
-	setup_test_file, test_file_open_6, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile6"}, {
-	setup_test_file, test_file_open_6, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile6"}, {
-	setup_test_file_truncate, test_file_open_6,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile6"}, {
-	setup_test_file, test_file_open_7, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile7"}, {
-	setup_test_file, test_file_open_7, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile7 0600"}, {
-	setup_test_file, test_file_open_8, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile8"}, {
-	setup_test_file, test_file_open_8, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile8"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile9"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile9 0600"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile9"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile10"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile10"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile10"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile11"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile11 0600"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile11"}, {
-	setup_test_file, test_file_open_12, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile12"}, {
-	setup_test_file, test_file_open_13, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile13"}, {
-	setup_test_file, test_file_open_13, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile13 0600"}, {
-	setup_test_file, test_file_open_14, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile14"}, {
-	setup_test_file, test_file_open_14, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile14"}, {
-	setup_test_file_truncate, test_file_open_14,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile14"}, {
-	setup_test_file, test_file_open_15, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile15"}, {
-	setup_test_file, test_file_open_15, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile15 0600"}, {
-	setup_test_file, test_file_open_16, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile16"}, {
-	setup_test_file, test_file_open_16, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile16"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile17"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile17 0600"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile17"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile18"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile18"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile18"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile19"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile19 0600"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile19"}, {
-	setup_test_file, test_file_open_20, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile20"}, {
-	setup_test_file, test_file_open_21, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile21"}, {
-	setup_test_file, test_file_open_21, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile21 0600"}, {
-	setup_test_file, test_file_open_22, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile22"}, {
-	setup_test_file, test_file_open_22, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile22"}, {
-	setup_test_file_truncate, test_file_open_22,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile22"}, {
-	setup_test_file, test_file_open_23, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile23"}, {
-	setup_test_file, test_file_open_23, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile23 0600"}, {
-	setup_all_test_file, test_file_open_0, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile0"}, {
-	setup_all_test_file, test_file_open_2, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile2"}, {
-	setup_all_test_file, test_file_open_2, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile2"}, {
-	setup_all_test_file_truncate, test_file_open_2,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile2"}, {
-	setup_all_test_file, test_file_open_4, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile4"}, {
-	setup_all_test_file, test_file_open_6, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile6"}, {
-	setup_all_test_file, test_file_open_6, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile6"}, {
-	setup_all_test_file_truncate, test_file_open_6,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile6"}, {
-	setup_all_test_file, test_file_open_8, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile8"}, {
-	setup_all_test_file, test_file_open_8, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile8"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_12, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile12"}, {
-	setup_all_test_file, test_file_open_14, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile14"}, {
-	setup_all_test_file, test_file_open_14, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile14"}, {
-	setup_all_test_file_truncate, test_file_open_14,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile14"}, {
-	setup_all_test_file, test_file_open_16, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile16"}, {
-	setup_all_test_file, test_file_open_16, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile16"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_20, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile20"}, {
-	setup_all_test_file, test_file_open_22, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile22"}, {
-	setup_all_test_file, test_file_open_22, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile22"}, {
-	setup_all_test_file_truncate, test_file_open_22,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile22"}, {
-	NULL}
-};
-
-int main(void)
-{
-	int i;
-	tomoyo_test_init();
-	for (i = 0; tests[i].do_test; i++) {
-		int trial;
-		for (trial = 0; trial < 2; trial++) {
-			int should_fail;
-			for (should_fail = 0; should_fail < 2; should_fail++) {
-				if (tests[i].do_setup)
-					tests[i].do_setup();
-				if (!should_fail)
-					write_domain_policy(tests[i].policy, 0);
-				set_profile(3, tests[i].name);
-				tests[i].do_test();
-				show_result(tests[i].policy, !should_fail);
-				set_profile(0, tests[i].name);
-				if (tests[i].do_cleanup)
-					tests[i].do_cleanup();
-				if (!should_fail)
-					write_domain_policy(tests[i].policy, 1);
-			}
-		}
-	}
-	for (i = 0; tests[i].do_test; i++) {
-		int mode;
-		for (mode = 0; mode < 4; mode++) {
-			if (tests[i].do_setup)
-				tests[i].do_setup();
-			set_profile(mode, tests[i].name);
-			tests[i].do_test();
-			show_result(tests[i].name, 1);
-			set_profile(0, tests[i].name);
-			if (tests[i].do_cleanup)
-				tests[i].do_cleanup();
-		}
-	}
-	fprintf(domain_fp, "delete %s\n", self_domain);
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c deleted +0 -195
deleted file mode 100644
index b1897a0fc..000000000
@@ -1,195 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_policy_io_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static FILE *policy_fp = NULL;
-static const char *policy_file = "";
-
-static void try_io(const char *policy, const char should_success)
-{
-	FILE *fp = fopen(policy_file, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	printf("%s: ", policy);
-	fprintf(policy_fp, "%s\n", policy);
-	if (!fp) {
-		printf("BUG: policy read failed\n");
-		return;
-	}
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (!strcmp(buffer, policy)) {
-			policy_found = 1;
-			break;
-		}
-	}
-	fclose(fp);
-	if (should_success) {
-		if (policy_found)
-			printf("OK\n");
-		else
-			printf("BUG: policy write failed\n");
-	} else {
-		if (!policy_found)
-			printf("OK : write rejected.\n");
-		else
-			printf("BUG: policy write not rejected.\n");
-	}
-	fprintf(policy_fp, "delete %s\n", policy);
-}
-
-static void stage_policy_io_test(void)
-{
-	int i;
-	policy_file = proc_policy_domain_policy;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c deleted +0 -358
deleted file mode 100644
index a6620ba30..000000000

Lines of this file are not shown. View the raw message.

testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c deleted +0 -169
deleted file mode 100644
index 7bc22c39b..000000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp

Part of the diff is not shown here. View the raw message.

#2 lore raw
In reply to Andrea Cervesato via ltp

Hi!
CCing the contact on https://tomoyo.osdn.jp/support.html.en

If anyone wants to pick up the testsuite and maintain it please speak up.

Quoted 3,788 lines

The tomoyo testing suite is built and installed inside the LTP testcases folder, but it's not used by any runtest file. It seems an old and unmaintained testing suite that uses old LTP API and ltp_clone_quick that is going to be deprecated.

We suppose to update it using new LTP API, cleaning up the code and removing deprecated functions, but nowadays the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor and not maintained anymore in years of development.

For this reason, this patch is going to remove it from LTP installation.

---
 testcases/kernel/security/tomoyo/.gitignore   |   9 -
 testcases/kernel/security/tomoyo/Makefile     |  29 -
 testcases/kernel/security/tomoyo/README       |  58 --
 testcases/kernel/security/tomoyo/include.h    | 379 ----------
 testcases/kernel/security/tomoyo/newns.c      |  49 --
 testcases/kernel/security/tomoyo/testall.sh   |  46 --
 .../security/tomoyo/tomoyo_accept_test.c      | 146 ----
 .../kernel/security/tomoyo/tomoyo_file_test.c | 304 --------
 .../security/tomoyo/tomoyo_filesystem_test.c  | 633 -----------------
 .../security/tomoyo/tomoyo_new_file_test.c    | 627 -----------------
 .../kernel/security/tomoyo/tomoyo_new_test.c  | 652 ------------------
 .../security/tomoyo/tomoyo_policy_io_test.c   | 195 ------
 .../tomoyo/tomoyo_policy_memory_test.c        | 358 ----------
 .../security/tomoyo/tomoyo_rewrite_test.c     | 169 -----
 14 files changed, 3654 deletions(-)
 delete mode 100644 testcases/kernel/security/tomoyo/.gitignore
 delete mode 100644 testcases/kernel/security/tomoyo/Makefile
 delete mode 100644 testcases/kernel/security/tomoyo/README
 delete mode 100644 testcases/kernel/security/tomoyo/include.h
 delete mode 100644 testcases/kernel/security/tomoyo/newns.c
 delete mode 100644 testcases/kernel/security/tomoyo/testall.sh
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_accept_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_file_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_file_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_new_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c
 delete mode 100644 testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c
testcases/kernel/security/tomoyo/.gitignore deleted +0 -9
deleted file mode 100644
index 698646d93..000000000
@@ -1,9 +0,0 @@
-/newns
-/tomoyo_accept_test
-/tomoyo_file_test
-/tomoyo_filesystem_test
-/tomoyo_new_file_test
-/tomoyo_new_test
-/tomoyo_policy_io_test
-/tomoyo_policy_memory_test
-/tomoyo_rewrite_test
testcases/kernel/security/tomoyo/Makefile deleted +0 -29
deleted file mode 100644
index 00e4cc3ed..000000000
@@ -1,29 +0,0 @@
-#
-#    kernel/security/smack testcase Makefile
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
-#
-#    This program is free software; you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License along
-#    with this program; if not, write to the Free Software Foundation, Inc.,
-#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Ngie Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS		:= testall.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/security/tomoyo/README deleted +0 -58
deleted file mode 100644
index 0cb538868..000000000
@@ -1,58 +0,0 @@
-Always look here for latest version of these tests:
-http://sourceforge.jp/projects/tomoyo/svn/view/trunk/2.3.x/tomoyo-tools/kernel_test/?root=tomoyo
-
-These testcases test the TOMOYO Security Module. And they are not part of
-default LTP build/install/run.
-
-A kernel with TOMOYO configured is required to run the TOMOYO testsuite.
-The securityfs filesystem must be mounted at /sys/kernel/security .
-
-Preparation steps are:
-
-1) Download tomoyo-tools package and extract and build and install.
-
-  # wget -O tomoyo-tools.tar.gz 'http://sourceforge.jp/projects/tomoyo/svn/view/trunk/2.3.x/tomoyo-tools.tar.gz?root=tomoyo&view=tar'
-  # tar -zxf tomoyo-tools.tar.gz
-  # make -C tomoyo-tools/ install
-
-  Programs are installed in /usr/sbin/ with prefix "tomoyo-" and
-  /usr/lib/tomoyo/ directory without prefix "tomoyo-".
-
-  You can make a RPM package by "rpmbuild -bb tomoyo-tools/tomoyo-tools.spec" and
-  a DEB package by "alien -k" after "rpmbuild -bb".
-
-2) Run /usr/lib/tomoyo/init_policy .
-
-   This will take several minutes.
-
-   Hiding kernel source directory by "mount -t tmpfs none /usr/src/linux/"
-   would save some time.
-
-   Configuration files are saved in /etc/tomoyo/ directory.
-   You can do "rm -fR /etc/tomoyo/" if you want to uninstall.
-
-3) Reboot the system with TOMOYO enabled kernel.
-
-   To make sure TOMOYO is selected, you can add security=tomoyo to kernel's
-   command line.
-
-4) Build the tests.
-
-   # (extract the tar ball containing the tests.)
-   # make autotools
-   # ./configure
-   # cd testcases/kernel/security/tomoyo/
-   # make
-   # find `/bin/pwd` -type f -perm +100 >> /etc/tomoyo/manager.conf
-   # /usr/sbin/tomoyo-loadpolicy m
-
-Test steps are:
-
-1) Run the tests from the directory you ran "make".
-
-   # ./testall.sh
-
-   Please don't run the tests inside /tmp/ directory, for /tmp/ directory is
-   hidden by "newns" (a wrapper program to run the test in a new namespace).
-
-   You can use "| grep -vF OK" to pick up only failed tests as testall.sh does.
testcases/kernel/security/tomoyo/include.h deleted +0 -379
deleted file mode 100644
index edaf1170f..000000000
@@ -1,379 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Tetsuo Handa <[email protected]>, 2009      */
-/*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * include.h
- *
- * Common functions for testing TOMOYO Linux's kernel.
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/kdev_t.h>
-#include <linux/unistd.h>
-#include <pty.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <sys/timex.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <unistd.h>
-#include <utime.h>
-#include <sched.h>
-#include <stdarg.h>
-#include <sys/mount.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <linux/ip.h>
-#include <err.h>
-#include "test.h"
-
-/*
- * Some architectures like mips n32 don't have __NR_uselib defined in the
- * system headers.
- */
-#ifdef __NR_uselib
-static inline int uselib(const char *library)
-{
-	return syscall(__NR_uselib, library);
-}
-#else
-static inline int uselib(const char *library)
-{
-	errno = ENOSYS;
-	return -1;
-}
-#endif
-
-/* Is there an architecture without __NR_pivot_root defined? */
-#ifdef __NR_pivot_root
-static inline int pivot_root(const char *new_root, const char *put_old)
-{
-	return syscall(__NR_pivot_root, new_root, put_old);
-}
-#else
-static inline int pivot_root(const char *new_root, const char *put_old)
-{
-	errno = ENOSYS;
-	return -1;
-}
-#endif
-
-/* The sysctl() wrapper is dead and newer arches omit it now. */
-static inline int write_sysctl(const char *path, const char *value)
-{
-	FILE *fp = fopen(path, "w");
-	if (!fp)
-		return 1;
-	fputs(value, fp);
-	fclose(fp);
-	return 0;
-}
-
-static inline int read_sysctl(const char *path, char *value, int len)
-{
-	char scratch[100];
-	FILE *fp = fopen(path, "r");
-	if (!fp)
-		return 1;
-	if (!value) {
-		value = scratch;
-		len = sizeof(scratch);
-	}
-	if (fgets(value, len, fp))
-		/* ignore */;
-	fclose(fp);
-	return 0;
-}
-
-/* Should be a fairly benign path to bang on. */
-#define TEST_SYSCTL_PATH "/proc/sys/net/ipv4/ip_local_port_range"
-
-#define proc_policy_dir              "/sys/kernel/security/tomoyo/"
-#define proc_policy_domain_policy    "/sys/kernel/security/tomoyo/domain_policy"
-#define proc_policy_exception_policy "/sys/kernel/security/tomoyo/exception_policy"
-#define proc_policy_profile          "/sys/kernel/security/tomoyo/profile"
-#define proc_policy_manager          "/sys/kernel/security/tomoyo/manager"
-#define proc_policy_query            "/sys/kernel/security/tomoyo/query"
-#define proc_policy_grant_log        "/sys/kernel/security/tomoyo/grant_log"
-#define proc_policy_reject_log       "/sys/kernel/security/tomoyo/reject_log"
-#define proc_policy_domain_status    "/sys/kernel/security/tomoyo/.domain_status"
-#define proc_policy_process_status   "/sys/kernel/security/tomoyo/.process_status"
-#define proc_policy_self_domain      "/sys/kernel/security/tomoyo/self_domain"
-
-static FILE *profile_fp = NULL;
-static FILE *domain_fp = NULL;
-static FILE *exception_fp = NULL;
-static char self_domain[4096] = "";
-static pid_t pid = 0;
-
-static void clear_status(void)
-{
-	static const char *keywords[] = {
-		"file::execute",
-		"file::open",
-		"file::create",
-		"file::unlink",
-		"file::mkdir",
-		"file::rmdir",
-		"file::mkfifo",
-		"file::mksock",
-		"file::truncate",
-		"file::symlink",
-		"file::rewrite",
-		"file::mkblock",
-		"file::mkchar",
-		"file::link",
-		"file::rename",
-		"file::chmod",
-		"file::chown",
-		"file::chgrp",
-		"file::ioctl",
-		"file::chroot",
-		"file::mount",
-		"file::umount",
-		"file::pivot_root",
-		NULL
-	};
-	int i;
-	FILE *fp = fopen(proc_policy_profile, "r");
-	static char buffer[4096];
-	if (!fp) {
-		fprintf(stderr, "Can't open %s\n", proc_policy_profile);
-		exit(1);
-	}
-	for (i = 0; keywords[i]; i++)
-		fprintf(profile_fp,
-			"255-CONFIG::%s={ mode=disabled }\n",
-			keywords[i]);
-	while (memset(buffer, 0, sizeof(buffer)),
-	       fgets(buffer, sizeof(buffer) - 10, fp)) {
-		const char *mode;
-		char *cp = strchr(buffer, '=');
-		if (!cp)
-			continue;
-		*cp = '\0';
-		mode = cp + 1;
-		cp = strchr(buffer, '-');
-		if (!cp)
-			continue;
-		*cp++ = '\0';
-		if (strcmp(buffer, "0"))
-			continue;
-		fprintf(profile_fp, "255-%s", cp);
-		if (!strcmp(cp, "COMMENT"))
-			mode = "Profile for kernel test\n";
-		else
-			mode = "{ mode=disabled verbose=no }\n";
-		fprintf(profile_fp, "255-%s=%s", cp, mode);
-	}
-	fprintf(profile_fp, "255-PREFERENCE::learning= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::enforcing= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::permissive= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::disabled= verbose=no\n");
-	fprintf(profile_fp, "255-PREFERENCE::learning= max_entry=2048\n");
-	fflush(profile_fp);
-	fclose(fp);
-}
-
-static void tomoyo_test_init(void)
-{
-	pid = getpid();
-	if (access(proc_policy_dir, F_OK)) {
-		fprintf(stderr, "You can't use this program for this kernel."
-			"\n");
-		exit(1);
-	}
-	profile_fp = fopen(proc_policy_profile, "w");
-	if (!profile_fp) {
-		fprintf(stderr, "Can't open %s .\n", proc_policy_profile);
-		exit(1);
-	}
-	setlinebuf(profile_fp);
-	domain_fp = fopen(proc_policy_domain_policy, "w");
-	if (!domain_fp) {
-		fprintf(stderr, "Can't open %s .\n",
-			proc_policy_domain_policy);
-		exit(1);
-	}
-	setlinebuf(domain_fp);
-	exception_fp = fopen(proc_policy_exception_policy, "w");
-	if (!exception_fp) {
-		fprintf(stderr, "Can't open %s .\n",
-			proc_policy_exception_policy);
-		exit(1);
-	}
-	setlinebuf(exception_fp);
-	if (fputc('\n', profile_fp) != '\n' || fflush(profile_fp)) {
-		fprintf(stderr, "You need to register this program to %s to "
-			"run this program.\n", proc_policy_manager);
-		exit(1);
-	}
-	clear_status();
-	{
-		FILE *fp = fopen(proc_policy_self_domain, "r");
-		memset(self_domain, 0, sizeof(self_domain));
-		if (!fp || !fgets(self_domain, sizeof(self_domain) - 1, fp) ||
-		    fclose(fp)) {
-			fprintf(stderr, "Can't open %s .\n",
-				proc_policy_self_domain);
-			exit(1);
-		}
-	}
-	fprintf(domain_fp, "select pid=%u\n", pid);
-	fprintf(domain_fp, "use_profile 255\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/domain_policy\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/domain_policy\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/exception_policy\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/exception_policy\n");
-	fprintf(domain_fp, "allow_read/write /sys/kernel/security/tomoyo/profile\n");
-	fprintf(domain_fp, "allow_truncate /sys/kernel/security/tomoyo/profile\n");
-}
-
-static void BUG(const char *fmt, ...)
-	__attribute__ ((format(printf, 1, 2)));
-
-static void BUG(const char *fmt, ...)
-{
-	va_list args;
-	printf("BUG: ");
-	va_start(args, fmt);
-	vprintf(fmt, args);
-	va_end(args);
-	putchar('\n');
-	fflush(stdout);
-	while (1)
-		sleep(100);
-}
-
-int write_domain_policy(const char *policy, int is_delete)
-{
-	FILE *fp = fopen(proc_policy_domain_policy, "r");
-	char buffer[8192];
-	int domain_found = 0;
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_domain_policy);
-		return 0;
-	}
-	if (is_delete)
-		fprintf(domain_fp, "delete ");
-	fprintf(domain_fp, "%s\n", policy);
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (!strncmp(buffer, "<kernel>", 8))
-			domain_found = !strcmp(self_domain, buffer);
-		if (!domain_found)
-			continue;
-		/* printf("<%s>\n", buffer); */
-		if (strcmp(buffer, policy))
-			continue;
-		policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (policy_found == is_delete) {
-		BUG("Can't %s %s", is_delete ? "delete" : "append",
-		    policy);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-
-}
-
-int write_exception_policy(const char *policy, int is_delete)
-{
-	FILE *fp = fopen(proc_policy_exception_policy, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_exception_policy);
-		return 0;
-	}
-	if (is_delete)
-		fprintf(exception_fp, "delete ");
-	fprintf(exception_fp, "%s\n", policy);
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (strcmp(buffer, policy))
-			continue;
-		policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (policy_found == is_delete) {
-		BUG("Can't %s %s", is_delete ? "delete" : "append",
-		    policy);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-
-}
-
-int set_profile(const int mode, const char *name)
-{
-	static const char *modes[4] = { "disabled", "learning", "permissive",
-					"enforcing" };
-	FILE *fp = fopen(proc_policy_profile, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	const int len = strlen(name);
-	if (!fp) {
-		BUG("Can't read %s", proc_policy_profile);
-		return 0;
-	}
-	fprintf(profile_fp, "255-CONFIG::%s=%s\n", name, modes[mode]);
-	while (memset(buffer, 0, sizeof(buffer)),
-	       fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (strncmp(buffer, "255-CONFIG::", 12) ||
-		    strncmp(buffer + 12, name, len) ||
-		    buffer[12 + len] != '=')
-			continue;
-		if (strstr(buffer + 13 + len, modes[mode]))
-			policy_found = 1;
-		break;
-	}
-	fclose(fp);
-	if (!policy_found) {
-		BUG("Can't change profile to 255-CONFIG::%s=%s",
-		    name, modes[mode]);
-		return 0;
-	}
-	errno = 0;
-	return 1;
-}
testcases/kernel/security/tomoyo/newns.c deleted +0 -49
deleted file mode 100644
index f888ca31f..000000000
@@ -1,49 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Tetsuo Handa <[email protected]>, 2009      */
-/*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/mount.h>
-#include <unistd.h>
-#include <sched.h>
-#include <errno.h>
-#include <stdlib.h>
-#include "test.h"
-
-static int child(void *arg)
-{
-	char **argv = (char **)arg;
-	argv++;
-	mount("/tmp/", "/tmp/", "tmpfs", 0, NULL);
-	execvp(argv[0], argv);
-	_exit(1);
-}
-
-int main(int argc, char *argv[])
-{
-	char c = 0;
-	const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child, (void *)argv);
-	while (waitpid(pid, NULL, __WALL) == EOF && errno == EINTR)
-		c++;		/* Dummy. */
-	return 0;
-}
testcases/kernel/security/tomoyo/testall.sh deleted +0 -46
deleted file mode 100644
index b103be6c6..000000000
@@ -1,46 +0,0 @@
-#! /bin/sh
-################################################################################
-##                                                                            ##
-## Copyright (c) Tetsuo Handa <[email protected]>, 2009      ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
-##                                                                            ##
-################################################################################
-
-cd ${0%/*}
-export PATH=$PWD:${PATH}
-
-echo "Testing all. (All results are reported)"
-newns tomoyo_accept_test
-newns tomoyo_filesystem_test
-newns tomoyo_file_test
-newns tomoyo_rewrite_test
-newns tomoyo_new_file_test
-newns tomoyo_new_test
-echo
-echo
-echo
-echo "Testing all. (Only ERRORS are reported)"
-newns tomoyo_accept_test | grep -vF Done
-newns tomoyo_filesystem_test | grep -vF OK | grep -F '('
-newns tomoyo_file_test | grep -vF OK | grep -F '('
-newns tomoyo_rewrite_test | grep -vF OK | grep -F '('
-newns tomoyo_new_test | grep -vF OK
-echo
-echo
-echo
-echo "Testing policy I/O.  (Only ERRORS are reported)"
-newns tomoyo_policy_io_test | grep -vF OK
-newns tomoyo_new_file_test | grep -vF OK
testcases/kernel/security/tomoyo/tomoyo_accept_test.c deleted +0 -146
deleted file mode 100644
index 335818a25..000000000
@@ -1,146 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_accept_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static void set_level(const int i)
-{
-	set_profile(i, "file::execute");
-	set_profile(i, "file::open");
-	set_profile(i, "file::create");
-	set_profile(i, "file::unlink");
-	set_profile(i, "file::mkdir");
-	set_profile(i, "file::rmdir");
-	set_profile(i, "file::mkfifo");
-	set_profile(i, "file::mksock");
-	set_profile(i, "file::truncate");
-	set_profile(i, "file::symlink");
-	set_profile(i, "file::rewrite");
-	set_profile(i, "file::mkblock");
-	set_profile(i, "file::mkchar");
-	set_profile(i, "file::link");
-	set_profile(i, "file::rename");
-	set_profile(i, "file::chmod");
-	set_profile(i, "file::chown");
-	set_profile(i, "file::chgrp");
-	set_profile(i, "file::ioctl");
-	set_profile(i, "file::chroot");
-	set_profile(i, "file::mount");
-	set_profile(i, "file::umount");
-	set_profile(i, "file::pivot_root");
-}
-
-static void test(int rw_loop, int truncate_loop, int append_loop,
-		 int create_loop)
-{
-	static const int rw_flags[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
-	static const int create_flags[3] = { 0, O_CREAT /* nonexistent */ ,
-		O_CREAT /* existent */
-	};
-	static const int truncate_flags[2] = { 0, O_TRUNC };
-	static const int append_flags[2] = { 0, O_APPEND };
-	int level;
-	int flags;
-	int i;
-	int fd;
-	static char buffer[1024];
-	memset(buffer, 0, sizeof(buffer));
-	snprintf(buffer, sizeof(buffer) - 1, "/tmp/file:a=%d:t=%d:c=%d:m=%d",
-		 append_loop, truncate_loop, create_loop, rw_loop);
-	fprintf(exception_fp, "deny_rewrite %s\n", buffer);
-	flags = rw_flags[rw_loop] | truncate_flags[truncate_loop] |
-	    append_flags[append_loop] | create_flags[create_loop];
-	for (i = 1; i < 8; i++)
-		fprintf(domain_fp, "delete %d %s\n", i, buffer);
-	for (level = 0; level < 4; level++) {
-		set_level(0);
-		if (create_loop == 1)
-			unlink(buffer);
-		else
-			close(open(buffer, O_CREAT, 0644));
-		set_level(level);
-		fd = open(buffer, flags, 0644);
-		if (fd != EOF)
-			close(fd);
-		else
-			fprintf(stderr, "%d: open(%04o) failed\n", level,
-				flags);
-		/*
-		   fd = open(buffer, flags, 0644)
-		   if (fd != EOF)
-		   close(fd);
-		   else
-		   fprintf(stderr, "%d: open(%04o) failed\n", level, flags);
-		 */
-		/*
-		   fd = open(buffer, flags, 0644);
-		   if (fd != EOF)
-		   close(fd);
-		   else
-		   fprintf(stderr, "%d: open(%04o) failed\n", level, flags);
-		 */
-	}
-	for (i = 1; i < 8; i++)
-		fprintf(domain_fp, "delete %d %s\n", i, buffer);
-	fprintf(domain_fp, "delete allow_truncate %s\n", buffer);
-	fprintf(domain_fp, "delete allow_create %s 0644\n", buffer);
-	fprintf(domain_fp, "delete allow_rewrite %s\n", buffer);
-	fd = open(buffer, flags, 0644);
-	if (fd != EOF) {
-		close(fd);
-		fprintf(stderr, "%d: open(%04o) didn't fail\n", 3, flags);
-	}
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-	fprintf(profile_fp, "255-PREFERENCE::learning={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::enforcing={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::permissive={ verbose=no }\n");
-	fprintf(profile_fp, "255-PREFERENCE::disabled={ verbose=no }\n");
-	set_profile(0, "file");
-	fprintf(profile_fp, "255-PREFERENCE::learning={ max_entry=2048 }\n");
-	{
-		int append_loop;
-		for (append_loop = 0; append_loop < 2; append_loop++) {
-			int truncate_loop;
-			for (truncate_loop = 0; truncate_loop < 2;
-			     truncate_loop++) {
-				int create_loop;
-				for (create_loop = 0; create_loop < 3;
-				     create_loop++) {
-					int rw_loop;
-					for (rw_loop = 0; rw_loop < 4;
-					     rw_loop++)
-						test(rw_loop, truncate_loop,
-						     append_loop, create_loop);
-				}
-			}
-		}
-	}
-	fprintf(profile_fp, "255-CONFIG::file=disabled\n");
-	printf("Done\n");
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_file_test.c deleted +0 -304
deleted file mode 100644
index 003f47720..000000000
@@ -1,304 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_file_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static int should_fail = 0;
-
-static void show_prompt(const char *str)
-{
-	printf("Testing %35s: (%s) ", str,
-	       should_fail ? "must fail" : "should success");
-	errno = 0;
-}
-
-static void show_result(int result)
-{
-	if (should_fail) {
-		if (result == EOF) {
-			if (errno == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-		} else {
-			printf("BUG!\n");
-		}
-	} else {
-		if (result != EOF)
-			printf("OK\n");
-		else
-			printf("%s\n", strerror(errno));
-	}
-}
-
-static const char *dev_null_path = "/dev/null";
-static const char *truncate_path = "/tmp/truncate_test";
-static const char *ftruncate_path = "/tmp/ftruncate_test";
-static const char *open_creat_path = "/tmp/open_test";
-static const char *mknod_reg_path = "/tmp/mknod_reg_test";
-static const char *mknod_chr_path = "/tmp/mknod_chr_test";
-static const char *mknod_blk_path = "/tmp/mknod_blk_test";
-static const char *mknod_fifo_path = "/tmp/mknod_fifo_test";
-static const char *mknod_sock_path = "/tmp/mknod_sock_test";
-static const char *unlink_path = "/tmp/unlink_test";
-static const char *mkdir_path = "/tmp/mkdir_test";
-static const char *rmdir_path = "/tmp/rmdir_test";
-static const char *link_source_path = "/tmp/link_source_test";
-static const char *link_dest_path = "/tmp/link_dest_test";
-static const char *symlink_source_path = "/tmp/symlink_source_test";
-static const char *symlink_dest_path = "/tmp/symlink_dest_test";
-static const char *rename_source_path = "/tmp/rename_source_test";
-static const char *rename_dest_path = "/tmp/rename_dest_test";
-static const char *socket_path = "/tmp/socket_test";
-
-static int ftruncate_fd = EOF;
-
-static void stage_file_test(void)
-{
-	int fd;
-	{
-		const char buffer[] = "32768 61000";
-		show_prompt("sysctl(READ)");
-		show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0));
-		show_prompt("sysctl(WRITE)");
-		show_result(write_sysctl(TEST_SYSCTL_PATH, buffer));
-	}
-
-	/* QUESTION: Is there a file which can be passed to uselib()? */
-	show_prompt("uselib()");
-	show_result(uselib("/bin/true"));
-
-	{
-		int pipe_fd[2] = { EOF, EOF };
-		int error = 0;
-		fflush(stdout);
-		fflush(stderr);
-		if (pipe(pipe_fd) == -1)
-			err(1, "pipe");
-		if (fork() == 0) {
-			execl("/bin/true", "/bin/true", NULL);
-			if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-				err(1, "write");
-			_exit(0);
-		}
-		close(pipe_fd[1]);
-		(void)read(pipe_fd[0], &error, sizeof(error));
-		show_prompt("execve()");
-		errno = error;
-		show_result(error ? EOF : 0);
-	}
-
-	show_prompt("open(O_RDONLY)");
-	fd = open(dev_null_path, O_RDONLY);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_WRONLY)");
-	fd = open(dev_null_path, O_WRONLY);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_RDWR)");
-	fd = open(dev_null_path, O_RDWR);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_CREAT | O_EXCL)");
-	fd = open(open_creat_path, O_CREAT | O_EXCL, 0666);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("open(O_TRUNC)");
-	fd = open(truncate_path, O_TRUNC);
-	show_result(fd);
-	if (fd != EOF)
-		close(fd);
-
-	show_prompt("truncate()");
-	show_result(truncate(truncate_path, 0));
-
-	show_prompt("ftruncate()");
-	show_result(ftruncate(ftruncate_fd, 0));
-
-	show_prompt("mknod(S_IFREG)");
-	show_result(mknod(mknod_reg_path, S_IFREG, 0));
-
-	show_prompt("mknod(S_IFCHR)");
-	show_result(mknod(mknod_chr_path, S_IFCHR, MKDEV(1, 3)));
-
-	show_prompt("mknod(S_IFBLK)");
-	show_result(mknod(mknod_blk_path, S_IFBLK, MKDEV(1, 0)));
-
-	show_prompt("mknod(S_IFIFO)");
-	show_result(mknod(mknod_fifo_path, S_IFIFO, 0));
-
-	show_prompt("mknod(S_IFSOCK)");
-	show_result(mknod(mknod_sock_path, S_IFSOCK, 0));
-
-	show_prompt("mkdir()");
-	show_result(mkdir(mkdir_path, 0600));
-
-	show_prompt("rmdir()");
-	show_result(rmdir(rmdir_path));
-
-	show_prompt("unlink()");
-	show_result(unlink(unlink_path));
-
-	show_prompt("symlink()");
-	show_result(symlink(symlink_dest_path, symlink_source_path));
-
-	show_prompt("link()");
-	show_result(link(link_source_path, link_dest_path));
-
-	show_prompt("rename()");
-	show_result(rename(rename_source_path, rename_dest_path));
-
-	{
-		struct sockaddr_un addr;
-		int fd;
-		memset(&addr, 0, sizeof(addr));
-		addr.sun_family = AF_UNIX;
-		strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-		fd = socket(AF_UNIX, SOCK_STREAM, 0);
-		show_prompt("unix_bind()");
-		show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)));
-		if (fd != EOF)
-			close(fd);
-	}
-
-	printf("\n\n");
-}
-
-static void create_files(void)
-{
-	mkdir(rmdir_path, 0700);
-	close(creat(link_source_path, 0600));
-	close(creat(rename_source_path, 0600));
-	close(creat(truncate_path, 0600));
-	close(creat(unlink_path, 0600));
-	ftruncate_fd = open(ftruncate_path, O_WRONLY | O_CREAT, 0600);
-}
-
-static void creanup_files(void)
-{
-	if (ftruncate_fd != EOF)
-		close(ftruncate_fd);
-	ftruncate_fd = EOF;
-	unlink(open_creat_path);
-	unlink(mknod_reg_path);
-	unlink(mknod_chr_path);
-	unlink(mknod_blk_path);
-	unlink(mknod_fifo_path);
-	unlink(mknod_sock_path);
-	rmdir(mkdir_path);
-	unlink(symlink_source_path);
-	unlink(symlink_dest_path);
-	unlink(link_source_path);
-	unlink(link_dest_path);
-	unlink(rename_source_path);
-	unlink(rename_dest_path);
-	unlink(truncate_path);
-	unlink(ftruncate_path);
-	unlink(socket_path);
-}
-
-static void set_file_enforce(int enforce)
-{
-	if (enforce) {
-		set_profile(3, "file::execute");
-		set_profile(3, "file::open");
-		set_profile(3, "file::create");
-		set_profile(3, "file::unlink");
-		set_profile(3, "file::mkdir");
-		set_profile(3, "file::rmdir");
-		set_profile(3, "file::mkfifo");
-		set_profile(3, "file::mksock");
-		set_profile(3, "file::truncate");
-		set_profile(3, "file::symlink");
-		set_profile(3, "file::rewrite");
-		set_profile(3, "file::mkblock");
-		set_profile(3, "file::mkchar");
-		set_profile(3, "file::link");
-		set_profile(3, "file::rename");
-		set_profile(3, "file::chmod");
-		set_profile(3, "file::chown");
-		set_profile(3, "file::chgrp");
-		set_profile(3, "file::ioctl");
-		set_profile(3, "file::chroot");
-		set_profile(3, "file::mount");
-		set_profile(3, "file::umount");
-		set_profile(3, "file::pivot_root");
-	} else {
-		set_profile(0, "file::execute");
-		set_profile(0, "file::open");
-		set_profile(0, "file::create");
-		set_profile(0, "file::unlink");
-		set_profile(0, "file::mkdir");
-		set_profile(0, "file::rmdir");
-		set_profile(0, "file::mkfifo");
-		set_profile(0, "file::mksock");
-		set_profile(0, "file::truncate");
-		set_profile(0, "file::symlink");
-		set_profile(0, "file::rewrite");
-		set_profile(0, "file::mkblock");
-		set_profile(0, "file::mkchar");
-		set_profile(0, "file::link");
-		set_profile(0, "file::rename");
-		set_profile(0, "file::chmod");
-		set_profile(0, "file::chown");
-		set_profile(0, "file::chgrp");
-		set_profile(0, "file::ioctl");
-		set_profile(0, "file::chroot");
-		set_profile(0, "file::mount");
-		set_profile(0, "file::umount");
-		set_profile(0, "file::pivot_root");
-	}
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-
-	printf("***** Testing file hooks in enforce mode. *****\n");
-	create_files();
-	should_fail = 1;
-	set_file_enforce(1);
-	stage_file_test();
-	set_file_enforce(0);
-	clear_status();
-	creanup_files();
-
-	printf("***** Testing file hooks in permissive mode. *****\n");
-	should_fail = 0;
-	create_files();
-	set_file_enforce(0);
-	stage_file_test();
-	creanup_files();
-
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c deleted +0 -633
deleted file mode 100644
index e6e3bb087..000000000
@@ -1,633 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_filesystem_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#define _GNU_SOURCE
-#include "include.h"
-
-static void show_prompt(const char *str, const int should_fail)
-{
-	printf("Testing %60s: (%s) ", str,
-	       should_fail ? "must fail" : "should success");
-	errno = 0;
-}
-
-#ifndef MS_MOVE
-#define MS_MOVE         8192
-#endif
-
-static const char *pivot_root_dir = "/sys/kernel/security/";
-
-static int child(void *arg)
-{
-	errno = 0;
-	pivot_root(pivot_root_dir, proc_policy_dir);
-	return errno;
-}
-
-static void mount2(const char *source, const char *target,
-		   const char *filesystemtype)
-{
-	if (mount(source, target, filesystemtype, 0, NULL)) {
-		printf("BUG: mount() failed\n");
-		fflush(stdout);
-	}
-}
-
-static const unsigned char compressed_ext2_image_sample[1350] = {
-	0x1F, 0x8B, 0x08, 0x00, 0xA8, 0xF2, 0x96, 0x4B, 0x02, 0x03, 0xED, 0xDC,
-	0x3D, 0x4B, 0x5B, 0x51, 0x18, 0x07, 0xF0, 0xE7, 0xDE, 0xAB, 0x14, 0x8C,
-	0xAB, 0xD5, 0x9A, 0xF8, 0x36, 0x0B, 0xA1, 0xE0, 0xE0, 0xDC, 0xD0, 0xAD,
-	0xD0, 0xC5, 0xAF, 0x50, 0x9C, 0x42, 0x1D, 0x6A, 0xE6, 0xA6, 0x9B, 0x9B,
-	0x8B, 0xD8, 0xA5, 0x5B, 0x97, 0x2E, 0xF9, 0x0E, 0x85, 0x4C, 0xF6, 0x23,
-	0x74, 0x70, 0x55, 0x28, 0x52, 0xA8, 0xDD, 0xED, 0xB9, 0xB9, 0xB1, 0xA6,
-	0xEA, 0x24, 0xA5, 0x81, 0xDE, 0xDF, 0x0F, 0x9E, 0xDC, 0xB7, 0x13, 0x2E,
-	0xF7, 0xC0, 0xFF, 0x70, 0xCE, 0x85, 0x24, 0x02, 0xA8, 0xAB, 0x7E, 0xF9,
-	0x31, 0x13, 0xB1, 0x95, 0x36, 0xA7, 0x45, 0x44, 0x2F, 0x6D, 0xB3, 0xC9,
-	0x06, 0xEB, 0x55, 0xF5, 0xC7, 0x87, 0x9F, 0x7E, 0x1C, 0xBF, 0x88, 0x68,
-	0xC5, 0xCE, 0xF7, 0x6C, 0xD4, 0x6E, 0x74, 0xFC, 0xF2, 0x62, 0x74, 0xED,
-	0xFA, 0x7B, 0x8D, 0xB8, 0x69, 0x9F, 0x8F, 0xCF, 0x9F, 0x1D, 0x7E, 0x78,
-	0xF7, 0x6D, 0xD8, 0x79, 0xFF, 0x71, 0xD0, 0xED, 0xBC, 0xCD, 0x9A, 0xBD,
-	0x69, 0x3C, 0xEB, 0xE0, 0xCB, 0xF0, 0xA4, 0xF9, 0xF5, 0xF9, 0xCA, 0xE0,
-	0xE0, 0x72, 0xBB, 0x7B, 0xD4, 0x1A, 0xE6, 0x13, 0xD7, 0xAA, 0xE7, 0x82,
-	0x7A, 0x29, 0xAA, 0xF8, 0xC7, 0xEC, 0x28, 0xFF, 0xBD, 0xC8, 0x75, 0x09,
-	0xD4, 0xC6, 0x55, 0x92, 0x4D, 0x71, 0xFA, 0x71, 0x05, 0x4C, 0xCF, 0xA3,
-	0xBB, 0xE3, 0x01, 0x50, 0x0F, 0x93, 0xEB, 0xDF, 0xEB, 0xFA, 0x97, 0x13,
-	0x80, 0x8B, 0x67, 0xD5, 0x02, 0xE4, 0xEE, 0xFD, 0x8B, 0x3F, 0xD6, 0x22,
-	0x0B, 0xA6, 0x6A, 0xC0, 0x5F, 0xF6, 0xB9, 0x1C, 0x7F, 0x9E, 0xDE, 0x37,
-	0xFE, 0xE4, 0xB1, 0x34, 0xD1, 0xEE, 0x71, 0xAA, 0xC5, 0x54, 0xE5, 0xB9,
-	0x27, 0xA9, 0x96, 0x53, 0x35, 0xA3, 0x7C, 0x13, 0x1A, 0xB1, 0x92, 0x6A,
-	0x35, 0xD5, 0xDA, 0xF8, 0x75, 0xE9, 0x86, 0x6E, 0x05, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x81,
-	0xCA, 0xDF, 0xD8, 0xCF, 0x47, 0x96, 0xB7, 0x7F, 0xEF, 0xE7, 0x79, 0xBB,
-	0x5D, 0xFD, 0x87, 0xDF, 0x79, 0x31, 0x97, 0x77, 0xF7, 0xDE, 0xEC, 0x6F,
-	0xEE, 0xEE, 0xF5, 0x5E, 0xBF, 0xD2, 0x57, 0xF0, 0xBF, 0x69, 0xDC, 0xCA,
-	0xFF, 0xCF, 0xA2, 0xCA, 0x3F, 0x50, 0x13, 0x33, 0xBA, 0x00, 0xE4, 0x1F,
-	0x90, 0x7F, 0x40, 0xFE, 0x01, 0xF9, 0x07, 0xE4, 0x1F, 0x90, 0x7F, 0x40,
-	0xFE, 0x01, 0xF9, 0x07, 0xE4, 0x1F, 0x90, 0x7F, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFA, 0xF9, 0x05, 0x34, 0xF2,
-	0x14, 0x08, 0x00, 0x00, 0x10, 0x00
-};
-
-int main(void)
-{
-	char c = 0;
-	tomoyo_test_init();
-
-	/* Test mount(). */
-	{
-		set_profile(3, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 1);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(1, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 0);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == ENOMEM)
-			printf("OK: Out of memory.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(3, "file::mount");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 0);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == ENOMEM)
-			printf("OK: Out of memory.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount dev\\011name / "
-			"fs\\011name 0\n");
-		show_prompt("mount('dev\\011name', '/', 'fs\\011name') ", 1);
-		if (mount("dev\tname", "/", "fs\tname", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else if (errno == ENODEV)
-			printf("OK: No such device.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		set_profile(1, "file::mount");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		set_profile(3, "file::mount");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		show_prompt("mount('anydev', '/', 'tmpfs') ", 0);
-		if (mount("anydev", "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		fprintf(domain_fp, "delete allow_mount <NULL> / tmpfs 0\n");
-		fprintf(domain_fp, "allow_mount anydev / tmpfs 0\n");
-		show_prompt("mount(NULL, '/', 'tmpfs') ", 0);
-		if (mount(NULL, "/", "tmpfs", 0, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success\n");
-		fprintf(domain_fp, "delete allow_mount anydev / tmpfs 0\n");
-		set_profile(2, "file::mount");
-		show_prompt("mount(NULL, NULL, 'tmpfs') ", 1);
-		if (mount(NULL, NULL, "tmpfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount(NULL, NULL, NULL) ", 1);
-		if (mount(NULL, NULL, NULL, 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', NULL, NULL) ", 1);
-		if (mount("/", NULL, NULL, 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', NULL, 'tmpfs') ", 1);
-		if (mount("/", NULL, "tmpfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		show_prompt("mount('/', '/', 'nonexistentfs') ", 1);
-		if (mount("/", "/", "nonexistentfs", 0, NULL))
-			printf("OK: %s\n", strerror(errno));
-		else
-			printf("BUG: Did not fail.\n");
-		set_profile(0, "file::mount");
-	}
-
-	mkdir("/tmp/mount/", 0755);
-	mkdir("/tmp/mount_bind/", 0755);
-	mkdir("/tmp/mount_move/", 0755);
-
-	/* Test mount(). */
-	{
-		static char buf[4096];
-		char *dev_ram_path = realpath("/dev/ram0", NULL);
-		if (!dev_ram_path)
-			dev_ram_path = realpath("/dev/ram", NULL);
-		if (!dev_ram_path) {
-			dev_ram_path = "/dev/ram0";
-			mknod(dev_ram_path, S_IFBLK, MKDEV(1, 0));
-		}
-		memset(buf, 0, sizeof(buf));
-		{
-			struct stat sbuf;
-			FILE *fp = NULL;
-			snprintf(buf, sizeof(buf) - 1, "zcat - > %s",
-				 dev_ram_path);
-			if (lstat(dev_ram_path, &sbuf) == 0 &&
-			    S_ISBLK(sbuf.st_mode) && MAJOR(sbuf.st_rdev) == 1)
-				fp = popen(buf, "w");
-			if (fp) {
-				if (fwrite(compressed_ext2_image_sample, 1,
-					   sizeof(compressed_ext2_image_sample),
-					   fp) !=
-				    sizeof(compressed_ext2_image_sample))
-					err(1, "fwrite");
-				pclose(fp);
-			} else
-				fprintf(stderr, "Can't write to %s .\n",
-					dev_ram_path);
-		}
-		set_profile(3, "file::mount");
-
-		/* Test standard case */
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/mount/'", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test device_name with pattern */
-		snprintf(buf, sizeof(buf) - 1, "mount('%s', '/tmp/mount/', "
-			 "'ext2') for '%s\\*'", dev_ram_path, dev_ram_path);
-		show_prompt(buf, 1);
-		if (mount(dev_ram_path, "/tmp/mount/", "ext2", MS_RDONLY, NULL)
-		    == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test dir_name with pattern */
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == EOF &&
-		    errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test standard case */
-		fprintf(domain_fp, "allow_mount none /tmp/mount/ tmpfs 0\n");
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/mount/'", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp,
-			"delete allow_mount none /tmp/mount/ tmpfs 0\n");
-
-		/* Test device_name with pattern */
-		fprintf(domain_fp, "allow_mount %s\\* /tmp/mount/ ext2 1\n",
-			dev_ram_path);
-		snprintf(buf, sizeof(buf) - 1, "mount('%s', '/tmp/mount/', "
-			 "'ext2') for '%s\\*'", dev_ram_path, dev_ram_path);
-		show_prompt(buf, 0);
-		if (mount(dev_ram_path, "/tmp/mount/", "ext2", MS_RDONLY, NULL)
-		    == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount %s\\* "
-			"/tmp/mount/ ext2 1\n", dev_ram_path);
-
-		/* Test dir_name with pattern */
-		fprintf(domain_fp,
-			"allow_mount none /tmp/\\?\\?\\?\\?\\?/ tmpfs 0\n");
-		show_prompt("mount('none', '/tmp/mount/', 'tmpfs') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", 0, NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount none "
-			"/tmp/\\?\\?\\?\\?\\?/ tmpfs 0\n");
-
-		set_profile(0, "file::mount");
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test mount(). */
-	{
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::mount");
-
-		/* Test remount case */
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 1);
-		if (mount("none", "/tmp/mount/", "tmpfs", MS_REMOUNT, NULL)
-		    == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 1);
-		if (mount(NULL, "/tmp/mount/", NULL, MS_REMOUNT, NULL) == EOF
-		    && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "allow_mount something /tmp/mount/ "
-			"--remount 0\n");
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 0);
-		if (mount(NULL, "/tmp/mount/", NULL, MS_REMOUNT, NULL))
-			printf("BUG: %s\n", strerror(errno));
-		else
-			printf("OK: Success.\n");
-		fprintf(domain_fp, "delete allow_mount something /tmp/mount/ "
-			"--remount 0\n");
-
-		/* Test bind case */
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_bind/', "
-			    "MS_BIND)", 1);
-		if (mount("/tmp/mount/", "/tmp/mount_bind/", NULL, MS_BIND,
-			  NULL) == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test move case */
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_move/', "
-			    "MS_MOVE)", 1);
-		if (mount("/tmp/mount/", "/tmp/mount_move/", NULL, MS_MOVE,
-			  NULL) == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		/* Test remount case */
-		fprintf(domain_fp, "allow_mount any /tmp/mount/ --remount 0\n");
-		show_prompt("mount('/tmp/mount/', MS_REMOUNT)", 0);
-		if (mount("none", "/tmp/mount/", "tmpfs", MS_REMOUNT, NULL)
-		    == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_mount any /tmp/mount/ "
-			"--remount 0\n");
-
-		/* Test bind case */
-		fprintf(domain_fp,
-			"allow_mount /tmp/mount/ /tmp/mount_bind/ --bind 0\n");
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_bind', MS_BIND)",
-			    0);
-		if (mount("/tmp/mount/", "/tmp/mount_bind/", NULL, MS_BIND,
-			  NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		set_profile(0, "file::mount");
-		umount("/tmp/mount_bind/");
-		fprintf(domain_fp, "delete allow_mount /tmp/mount/ "
-			"/tmp/mount_bind/ --bind 0\n");
-
-		/* Test move case */
-		set_profile(3, "file::mount");
-		fprintf(domain_fp, "allow_unmount /tmp/mount/\n");
-		fprintf(domain_fp, "allow_mount /tmp/mount/ /tmp/mount_move/ "
-			"--move 0\n");
-		show_prompt("mount('/tmp/mount/', '/tmp/mount_move/', "
-			    "MS_MOVE)", 0);
-		if (mount("/tmp/mount/", "/tmp/mount_move/", NULL, MS_MOVE,
-			  NULL) == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-		set_profile(0, "file::mount");
-		umount("/tmp/mount_move/");
-		fprintf(domain_fp, "delete allow_unmount /tmp/mount/\n");
-		fprintf(domain_fp, "delete allow_mount /tmp/mount/ "
-			"/tmp/mount_move/ --move 0\n");
-
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test umount(). */
-	{
-		/* Test standard case */
-		fprintf(domain_fp, "allow_unmount /tmp/mount/\n");
-
-		set_profile(0, "file::umount");
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for '/tmp/mount/'", 0);
-		if (umount("/tmp/mount/") == 0)
-			printf("OK\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp, "delete allow_unmount /tmp/mount/\n");
-
-		set_profile(0, "file::umount");
-
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for '/tmp/mount/'", 1);
-		if (umount("/tmp/mount/") == EOF && errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		/* Test pattern */
-		fprintf(domain_fp, "allow_unmount /tmp/\\?\\?\\?\\?\\?/\n");
-		set_profile(0, "file::umount");
-		mount2("none", "/tmp/mount/", "tmpfs");
-		set_profile(3, "file::umount");
-		show_prompt("umount('/tmp/mount/') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 1);
-		if (umount("/tmp/mount/") == 0)
-			printf("OK\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-		fprintf(domain_fp,
-			"delete allow_unmount /tmp/\\?\\?\\?\\?\\?/\n");
-
-		set_profile(0, "file::umount");
-		while (umount("/tmp/mount/") == 0)
-			c++;	/* Dummy. */
-	}
-
-	/* Test chroot(). */
-	{
-		set_profile(3, "file::chroot");
-
-		/* Test standard case */
-		fprintf(domain_fp, "allow_chroot /tmp/mount/\n");
-		show_prompt("chroot('/tmp/mount/') for '/tmp/mount/'", 0);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == 0)
-				printf("OK\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-		fprintf(domain_fp, "delete allow_chroot /tmp/mount/\n");
-
-		show_prompt("chroot('/tmp/mount/') for '/tmp/mount/'", 1);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == EOF && errno == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("BUG: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-
-		/* Test pattern */
-		fprintf(domain_fp, "allow_chroot /tmp/\\?\\?\\?\\?\\?/\n");
-		show_prompt("chroot('/tmp/mount/') for "
-			    "'/tmp/\\?\\?\\?\\?\\?/'", 0);
-		fflush(stdout);
-		if (fork() == 0) {
-			if (chroot("/tmp/mount/") == 0)
-				printf("OK\n");
-			else
-				printf("FAILED: %s\n", strerror(errno));
-			fflush(stdout);
-			_exit(0);
-		}
-		wait(NULL);
-		fprintf(domain_fp,
-			"delete allow_chroot /tmp/\\?\\?\\?\\?\\?/\n");
-
-		set_profile(0, "file::chroot");
-	}
-
-	/* Test pivot_root(). */
-	{
-		int error;
-		static char stack[8192];
-		set_profile(3, "file::pivot_root");
-		fprintf(domain_fp, "allow_pivot_root %s %s\n",
-			pivot_root_dir, proc_policy_dir);
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 0);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		fprintf(domain_fp, "delete allow_pivot_root %s %s\n",
-			pivot_root_dir, proc_policy_dir);
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 1);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == EPERM)
-			printf("OK: Permission denied.\n");
-		else
-			printf("BUG: %s\n", strerror(errno));
-
-		set_profile(2, "file::pivot_root");
-		snprintf(stack, 8191, "pivot_root('%s', '%s')", pivot_root_dir,
-			 proc_policy_dir);
-		show_prompt(stack, 0);
-		{
-			const pid_t pid = ltp_clone_quick(CLONE_NEWNS, child,
-							  NULL);
-			while (waitpid(pid, &error, __WALL) == EOF &&
-			       errno == EINTR)
-				c++;	/* Dummy. */
-		}
-		errno = WIFEXITED(error) ? WEXITSTATUS(error) : -1;
-		if (errno == 0)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(errno));
-
-		set_profile(0, "file::pivot_root");
-
-	}
-
-	rmdir("/tmp/mount_move/");
-	rmdir("/tmp/mount_bind/");
-	rmdir("/tmp/mount/");
-
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_new_file_test.c deleted +0 -627
deleted file mode 100644
index eb912d726..000000000
@@ -1,627 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_new_file_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static const char *policy = "";
-
-static void show_result(int result, char should_success)
-{
-	int error = errno;
-	printf("%s : ", policy);
-	if (should_success) {
-		if (result != EOF)
-			printf("OK\n");
-		else
-			printf("FAILED: %s\n", strerror(error));
-	} else {
-		if (result == EOF) {
-			if (error == EPERM)
-				printf("OK: Permission denied.\n");
-			else
-				printf("FAILED: %s\n", strerror(error));
-		} else {
-			printf("BUG: didn't fail.\n");
-		}
-	}
-}
-
-static void create2(const char *pathname)
-{
-	set_profile(0, "file::create");
-	set_profile(0, "file::open");
-	close(creat(pathname, 0600));
-	set_profile(3, "file::create");
-	set_profile(3, "file::open");
-	errno = 0;
-}
-
-static void mkdir2(const char *pathname)
-{
-	set_profile(0, "file::mkdir");
-	mkdir(pathname, 0600);
-	set_profile(3, "file::mkdir");
-	errno = 0;
-}
-
-static void unlink2(const char *pathname)
-{
-	set_profile(0, "file::unlink");
-	unlink(pathname);
-	set_profile(3, "file::unlink");
-	errno = 0;
-}
-
-static void rmdir2(const char *pathname)
-{
-	set_profile(0, "file::rmdir");
-	rmdir(pathname);
-	set_profile(3, "file::rmdir");
-	errno = 0;
-}
-
-static void mkfifo2(const char *pathname)
-{
-	set_profile(0, "file::mkfifo");
-	mkfifo(pathname, 0600);
-	set_profile(3, "file::mkfifo");
-	errno = 0;
-}
-
-static void stage_file_test(void)
-{
-	const char buffer[] = "32768 61000";
-	int pipe_fd[2] = { EOF, EOF };
-	int error = 0;
-	int fd;
-	char pbuffer[1024];
-	struct stat sbuf;
-	struct sockaddr_un addr;
-	struct ifreq ifreq;
-	char *filename = "";
-	set_profile(3, "file::execute");
-	set_profile(3, "file::open");
-	set_profile(3, "file::create");
-	set_profile(3, "file::unlink");
-	set_profile(3, "file::mkdir");
-	set_profile(3, "file::rmdir");
-	set_profile(3, "file::mkfifo");
-	set_profile(3, "file::mksock");
-	set_profile(3, "file::truncate");
-	set_profile(3, "file::symlink");
-	set_profile(3, "file::rewrite");
-	set_profile(3, "file::mkblock");
-	set_profile(3, "file::mkchar");
-	set_profile(3, "file::link");
-	set_profile(3, "file::rename");
-	set_profile(3, "file::chmod");
-	set_profile(3, "file::chown");
-	set_profile(3, "file::chgrp");
-	set_profile(3, "file::ioctl");
-	set_profile(3, "file::chroot");
-	set_profile(3, "file::mount");
-	set_profile(3, "file::umount");
-	set_profile(3, "file::pivot_root");
-
-	policy = "allow_read /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0), 0);
-
-	policy = "allow_write /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 1);
-	write_domain_policy(policy, 1);
-	show_result(write_sysctl(TEST_SYSCTL_PATH, buffer), 0);
-
-	policy = "allow_read/write /proc/sys/net/ipv4/ip_local_port_range";
-	write_domain_policy(policy, 0);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) &&
-	            write_sysctl(TEST_SYSCTL_PATH, buffer), 1);
-	write_domain_policy(policy, 1);
-	show_result(read_sysctl(TEST_SYSCTL_PATH, NULL, 0) &&
-	            write_sysctl(TEST_SYSCTL_PATH, buffer), 0);
-
-	policy = "allow_read /bin/true";
-	write_domain_policy(policy, 0);
-	show_result(uselib("/bin/true"), 1);
-	write_domain_policy(policy, 1);
-	show_result(uselib("/bin/true"), 0);
-
-	policy = "allow_execute /bin/true";
-	write_domain_policy(policy, 0);
-	fflush(stdout);
-	fflush(stderr);
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	if (fork() == 0) {
-		execl("/bin/true", "/bin/true", NULL);
-		if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-			err(1, "write");
-		exit(0);
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	wait(NULL);
-	errno = error;
-	show_result(error ? EOF : 0, 1);
-	write_domain_policy(policy, 1);
-	fflush(stdout);
-	fflush(stderr);
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	if (fork() == 0) {
-		execl("/bin/true", "/bin/true", NULL);
-		if (write(pipe_fd[1], &errno, sizeof(errno)) == -1)
-			err(1, "write");
-		_exit(0);
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	wait(NULL);
-	errno = error;
-	show_result(errno ? EOF : 0, 0);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	set_profile(3, "file::mkfifo");
-	policy = "allow_mkfifo /tmp/mknod_fifo_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_fifo_test";
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 0);
-
-	memset(pbuffer, 0, sizeof(pbuffer));
-	memset(&sbuf, 0, sizeof(sbuf));
-	filename = "/dev/null";
-	stat(filename, &sbuf);
-	snprintf(pbuffer, sizeof(pbuffer) - 1, "allow_write %s", filename);
-	policy = pbuffer;
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read/write /tmp/fifo";
-	mkfifo2("/tmp/fifo");
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/fifo", O_RDWR);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/fifo", O_RDWR);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_write /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_WRONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_read/write /dev/null";
-	write_domain_policy(policy, 0);
-	fd = open("/dev/null", O_RDWR);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open("/dev/null", O_RDWR);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 0);
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_create /tmp/open_test 0644";
-	write_domain_policy(policy, 0);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	write_domain_policy(policy, 1);
-	fd = open("/tmp/open_test", O_WRONLY | O_CREAT | O_EXCL, 0644);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	unlink2("/tmp/open_test");
-	policy = "allow_write /tmp/open_test";
-	write_domain_policy(policy, 1);
-
-	filename = "/tmp/truncate_test";
-	create2(filename);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-	policy = "allow_write /tmp/truncate_test";
-	write_domain_policy(policy, 1);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	show_result(truncate(filename, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(truncate(filename, 0), 0);
-
-	policy = "allow_truncate /tmp/truncate_test";
-	write_domain_policy(policy, 0);
-	set_profile(0, "file::open");
-	fd = open(filename, O_WRONLY);
-	set_profile(3, "file::open");
-	show_result(ftruncate(fd, 0), 1);
-	write_domain_policy(policy, 1);
-	show_result(ftruncate(fd, 0), 0);
-	if (fd != EOF)
-		close(fd);
-
-	unlink2(filename);
-
-	policy = "allow_create /tmp/mknod_reg_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_reg_test";
-	show_result(mknod(filename, S_IFREG | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFREG | 0644, 0), 0);
-
-	policy = "allow_mkchar /tmp/mknod_chr_test 0644 1 3";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_chr_test";
-	show_result(mknod(filename, S_IFCHR | 0644, MKDEV(1, 3)), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFCHR | 0644, MKDEV(1, 3)), 0);
-
-	policy = "allow_mkblock /tmp/mknod_blk_test 0644 1 0";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_blk_test";
-	show_result(mknod(filename, S_IFBLK | 0644, MKDEV(1, 0)), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFBLK | 0644, MKDEV(1, 0)), 0);
-
-	policy = "allow_mkfifo /tmp/mknod_fifo_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_fifo_test";
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFIFO | 0644, 0), 0);
-
-	policy = "allow_mksock /tmp/mknod_sock_test 0644";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mknod_sock_test";
-	show_result(mknod(filename, S_IFSOCK | 0644, 0), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(mknod(filename, S_IFSOCK | 0644, 0), 0);
-
-	policy = "allow_mkdir /tmp/mkdir_test/ 0600";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/mkdir_test";
-	show_result(mkdir(filename, 0600), 1);
-	write_domain_policy(policy, 1);
-	rmdir2(filename);
-	show_result(mkdir(filename, 0600), 0);
-
-	policy = "allow_rmdir /tmp/rmdir_test/";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/rmdir_test";
-	mkdir2(filename);
-	show_result(rmdir(filename), 1);
-	write_domain_policy(policy, 1);
-	mkdir2(filename);
-	show_result(rmdir(filename), 0);
-	rmdir2(filename);
-
-	policy = "allow_unlink /tmp/unlink_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/unlink_test";
-	create2(filename);
-	show_result(unlink(filename), 1);
-	write_domain_policy(policy, 1);
-	create2(filename);
-	show_result(unlink(filename), 0);
-	unlink2(filename);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_symlink /tmp/symlink_source_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/symlink_source_test";
-	show_result(symlink("/tmp/symlink_dest_test", filename), 1);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	show_result(symlink("/tmp/symlink_dest_test", filename), 0);
-
-	policy = "allow_link /tmp/link_source_test /tmp/link_dest_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/link_source_test";
-	create2(filename);
-	show_result(link(filename, "/tmp/link_dest_test"), 1);
-	write_domain_policy(policy, 1);
-	unlink2("/tmp/link_dest_test");
-	show_result(link(filename, "/tmp/link_dest_test"), 0);
-	unlink2(filename);
-
-	policy = "allow_rename /tmp/rename_source_test /tmp/rename_dest_test";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/rename_source_test";
-	create2(filename);
-	show_result(rename(filename, "/tmp/rename_dest_test"), 1);
-	write_domain_policy(policy, 1);
-	unlink2("/tmp/rename_dest_test");
-	create2(filename);
-	show_result(rename(filename, "/tmp/rename_dest_test"), 0);
-	unlink2(filename);
-
-	policy = "allow_mksock /tmp/socket_test 0755";
-	write_domain_policy(policy, 0);
-	filename = "/tmp/socket_test";
-	memset(&addr, 0, sizeof(addr));
-	addr.sun_family = AF_UNIX;
-	strncpy(addr.sun_path, filename, sizeof(addr.sun_path) - 1);
-	fd = socket(AF_UNIX, SOCK_STREAM, 0);
-	show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)), 1);
-	if (fd != EOF)
-		close(fd);
-	write_domain_policy(policy, 1);
-	unlink2(filename);
-	fd = socket(AF_UNIX, SOCK_STREAM, 0);
-	show_result(bind(fd, (struct sockaddr *)&addr, sizeof(addr)), 0);
-	if (fd != EOF)
-		close(fd);
-
-	filename = "/tmp/rewrite_test";
-	create2(filename);
-	policy = "allow_read/write /tmp/rewrite_test";
-	write_domain_policy(policy, 0);
-	write_exception_policy("deny_rewrite /tmp/rewrite_test", 0);
-	policy = "allow_truncate /tmp/rewrite_test";
-	write_domain_policy(policy, 0);
-
-	fd = open(filename, O_RDONLY);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_APPEND);
-	show_result(fd, 1);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_TRUNC);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	fd = open(filename, O_WRONLY | O_TRUNC | O_APPEND);
-	show_result(fd, 0);
-	if (fd != EOF)
-		close(fd);
-
-	show_result(truncate(filename, 0), 0);
-
-	set_profile(0, "file::open");
-	fd = open(filename, O_WRONLY | O_APPEND);
-	set_profile(3, "file::open");
-	show_result(ftruncate(fd, 0), 0);
-
-	show_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_APPEND), 0);
-	if (fd != EOF)
-		close(fd);
-
-	write_domain_policy(policy, 1);
-
-	policy = "allow_read/write /tmp/rewrite_test";
-	write_domain_policy(policy, 1);
-	write_exception_policy("deny_rewrite /tmp/rewrite_test", 1);
-
-	unlink2(filename);
-
-	policy = "allow_ioctl socket:[family=2:type=2:protocol=17] "
-	    "35122-35124";
-	write_domain_policy(policy, 0);
-	fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
-	memset(&ifreq, 0, sizeof(ifreq));
-	snprintf(ifreq.ifr_name, sizeof(ifreq.ifr_name) - 1, "lo");
-	show_result(ioctl(fd, 35123, &ifreq), 1);
-	write_domain_policy(policy, 1);
-	policy = "allow_ioctl " "socket:[family=2:type=2:protocol=17] 0-35122";
-	write_domain_policy(policy, 0);
-	show_result(ioctl(fd, 35123, &ifreq), 0);
-	write_domain_policy(policy, 1);
-	if (fd != EOF)
-		close(fd);
-}
-
-int main(void)
-{
-	tomoyo_test_init();
-	fprintf(domain_fp, "%s /bin/true\n", self_domain);
-	fprintf(domain_fp, "use_profile 255\n");
-	fprintf(domain_fp, "select pid=%u\n", pid);
-	fprintf(profile_fp, "255-PREFERENCE::audit={ max_reject_log=1024 }\n");
-	stage_file_test();
-	fprintf(domain_fp, "use_profile 0\n");
-	clear_status();
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_new_test.c deleted +0 -652
deleted file mode 100644
index a1ab259e5..000000000
@@ -1,652 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_new_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static int result;
-static int error;
-
-static void show_result(const char *test, int should_success)
-{
-	error = errno;
-	printf("%s : ", test);
-	if (should_success) {
-		if (error == 0)
-			printf("OK (%d)\n", result);
-		else
-			printf("FAILED: %s\n", strerror(error));
-	} else {
-		if (error == 0)
-			printf("BUG: Didn't fail (%d)\n", result);
-		else if (error == EPERM)
-			printf("OK: permission denied\n");
-		else
-			printf("FAILED: %s\n", strerror(error));
-	}
-}
-
-static void test_read_etc_fstab(void)
-{
-	result = open("/etc/fstab", O_RDONLY);
-}
-
-static void test_write_dev_null(void)
-{
-	result = open("/dev/null", O_WRONLY);
-}
-
-static void cleanup_file_open(void)
-{
-	if (result != EOF)
-		close(result);
-}
-
-static void test_mkdir_testdir(void)
-{
-	result = mkdir("/tmp/testdir", 0755);
-}
-
-static void cleanup_mkdir_testdir(void)
-{
-	rmdir("/tmp/testdir");
-}
-
-static void setup_mkdir_testdir(void)
-{
-	mkdir("/tmp/testdir", 0755);
-}
-
-static void test_rmdir_testdir(void)
-{
-	result = rmdir("/tmp/testdir");
-}
-
-static void setup_execute_bin_true(void)
-{
-	fprintf(domain_fp, "%s /bin/true\n", self_domain);
-	fprintf(domain_fp, "use_profile 0\n");
-	fprintf(domain_fp, "select pid=%u\n", pid);
-}
-
-static void cleanup_execute_bin_true(void)
-{
-	wait(NULL);
-	fprintf(domain_fp, "delete %s /bin/true\n", self_domain);
-	fprintf(domain_fp, "select pid=%u\n", pid);
-}
-
-static void test_execute_bin_true(void)
-{
-	char *argv[] = { "/bin/true", NULL };
-	char *envp[] = { "HOME=/", NULL };
-	int pipe_fd[2] = { EOF, EOF };
-	if (pipe(pipe_fd) == -1)
-		err(1, "pipe");
-	switch (fork()) {
-	case 0:
-		execve("/bin/true", argv, envp);
-		error = errno;
-		if (write(pipe_fd[1], &error, sizeof(error)) == -1)
-			err(1, "write");
-		_exit(0);
-		break;
-	case -1:
-		error = ENOMEM;
-		break;
-	}
-	close(pipe_fd[1]);
-	(void)read(pipe_fd[0], &error, sizeof(error));
-	close(pipe_fd[0]);
-	result = error ? EOF : 0;
-	errno = error;
-}
-
-static void test_chmod_dev_null(void)
-{
-	result = chmod("/dev/null", 0666);
-}
-
-static void test_chown_dev_null(void)
-{
-	result = chown("/dev/null", 0, -1);
-}
-
-static void test_chgrp_dev_null(void)
-{
-	result = chown("/dev/null", -1, 0);
-}
-
-static void test_ioctl_dev_null(void)
-{
-	int fd = open("/dev/null", O_RDWR);
-	errno = 0;
-	result = ioctl(fd, 0x5451, NULL);
-	error = errno;
-	close(fd);
-	errno = error;
-}
-
-static void setup_chmod_group(void)
-{
-	write_exception_policy("path_group CHMOD_TARGET /dev/null", 0);
-	write_exception_policy("number_group CHMOD_MODES 0666", 0);
-}
-
-static void cleanup_chmod_group(void)
-{
-	write_exception_policy("path_group CHMOD_TARGET /dev/null", 1);
-	write_exception_policy("number_group CHMOD_MODES 0666", 1);
-}
-
-static void setup_chown_group(void)
-{
-	write_exception_policy("path_group CHOWN_TARGET /dev/\\*", 0);
-	write_exception_policy("number_group CHOWN_IDS 0x0-0xFFFE", 0);
-}
-
-static void cleanup_chown_group(void)
-{
-	write_exception_policy("path_group CHOWN_TARGET /dev/\\*", 1);
-	write_exception_policy("number_group CHOWN_IDS 0x0-0xFFFE", 1);
-}
-
-static void setup_ioctl_group(void)
-{
-	write_exception_policy("path_group IOCTL_TARGET /dev/\\*", 0);
-	write_exception_policy("number_group IOCTL_NUMBERS 0x5450-0x5452", 0);
-}
-
-static void cleanup_ioctl_group(void)
-{
-	write_exception_policy("path_group IOCTL_TARGET /dev/\\*", 1);
-	write_exception_policy("number_group IOCTL_NUMBERS 0x5450-0x5452", 1);
-}
-
-static void setup_open_group(void)
-{
-	write_exception_policy("path_group READABLE /etc/\\*", 0);
-	write_exception_policy("number_group READABLE_IDS 0-0xFFF", 0);
-}
-
-static void cleanup_open_group(void)
-{
-	cleanup_file_open();
-	write_exception_policy("path_group READABLE /etc/\\*", 1);
-	write_exception_policy("number_group READABLE_IDS 0-0xFFF", 1);
-}
-
-static void test_file_open_0(void)
-{
-	result = open("/tmp/testfile0", O_RDONLY, 0600);
-}
-
-static void test_file_open_1(void)
-{
-	result = open("/tmp/testfile1", O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_2(void)
-{
-	result = open("/tmp/testfile2", O_TRUNC | O_RDONLY, 0600);
-}
-
-static void test_file_open_3(void)
-{
-	result = open("/tmp/testfile3", O_TRUNC | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_4(void)
-{
-	result = open("/tmp/testfile4", O_APPEND | O_RDONLY, 0600);
-}
-
-static void test_file_open_5(void)
-{
-	result = open("/tmp/testfile5", O_APPEND | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_6(void)
-{
-	result = open("/tmp/testfile6", O_APPEND | O_TRUNC | O_RDONLY, 0600);
-}
-
-static void test_file_open_7(void)
-{
-	result = open("/tmp/testfile7",
-		      O_APPEND | O_TRUNC | O_CREAT | O_RDONLY, 0600);
-}
-
-static void test_file_open_8(void)
-{
-	result = open("/tmp/testfile8", O_WRONLY, 0600);
-}
-
-static void test_file_open_9(void)
-{
-	result = open("/tmp/testfile9", O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_10(void)
-{
-	result = open("/tmp/testfile10", O_TRUNC | O_WRONLY, 0600);
-}
-
-static void test_file_open_11(void)
-{
-	result = open("/tmp/testfile11", O_TRUNC | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_12(void)
-{
-	result = open("/tmp/testfile12", O_APPEND | O_WRONLY, 0600);
-}
-
-static void test_file_open_13(void)
-{
-	result = open("/tmp/testfile13", O_APPEND | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_14(void)
-{
-	result = open("/tmp/testfile14", O_APPEND | O_TRUNC | O_WRONLY, 0600);
-}
-
-static void test_file_open_15(void)
-{
-	result = open("/tmp/testfile15",
-		      O_APPEND | O_TRUNC | O_CREAT | O_WRONLY, 0600);
-}
-
-static void test_file_open_16(void)
-{
-	result = open("/tmp/testfile16", O_RDWR, 0600);
-}
-
-static void test_file_open_17(void)
-{
-	result = open("/tmp/testfile17", O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_18(void)
-{
-	result = open("/tmp/testfile18", O_TRUNC | O_RDWR, 0600);
-}
-
-static void test_file_open_19(void)
-{
-	result = open("/tmp/testfile19", O_TRUNC | O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_20(void)
-{
-	result = open("/tmp/testfile20", O_APPEND | O_RDWR, 0600);
-}
-
-static void test_file_open_21(void)
-{
-	result = open("/tmp/testfile21", O_APPEND | O_CREAT | O_RDWR, 0600);
-}
-
-static void test_file_open_22(void)
-{
-	result = open("/tmp/testfile22", O_APPEND | O_TRUNC | O_RDWR, 0600);
-}
-
-static void test_file_open_23(void)
-{
-	result = open("/tmp/testfile23", O_APPEND | O_TRUNC | O_CREAT | O_RDWR,
-		      0600);
-}
-
-static void setup_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i += 2) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		close(open(buffer, O_WRONLY | O_CREAT, 0600));
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 0);
-}
-
-static void setup_test_file_truncate(void)
-{
-	setup_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 0);
-	set_profile(3, "file::truncate");
-}
-
-static void setup_all_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i++) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		close(open(buffer, O_WRONLY | O_CREAT, 0600));
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 0);
-}
-
-static void setup_all_test_file_truncate(void)
-{
-	setup_all_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 0);
-	set_profile(3, "file::truncate");
-}
-
-static void cleanup_test_file(void)
-{
-	int i;
-	char buffer[32];
-	buffer[31] = '\0';
-	for (i = 0; i < 24; i++) {
-		snprintf(buffer, sizeof(buffer) - 1, "/tmp/testfile%u", i);
-		unlink(buffer);
-	}
-	write_exception_policy("deny_rewrite /tmp/testfile\\$", 1);
-	cleanup_file_open();
-}
-
-static void cleanup_test_file_truncate(void)
-{
-	cleanup_test_file();
-	write_domain_policy("allow_truncate /tmp/testfile\\$", 1);
-	set_profile(0, "file::truncate");
-}
-
-static struct test_struct {
-	void (*do_setup) (void);
-	void (*do_test) (void);
-	void (*do_cleanup) (void);
-	const char *name;
-	const char *policy;
-} tests[] = {
-	{
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	NULL, test_read_etc_fstab, cleanup_file_open, "file::open",
-		    "allow_read /etc/fstab"}, {
-	setup_open_group, test_read_etc_fstab, cleanup_open_group,
-		    "file::open", "allow_read @READABLE"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	NULL, test_write_dev_null, cleanup_file_open, "file::open",
-		    "allow_write /dev/null"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	cleanup_mkdir_testdir, test_mkdir_testdir,
-		    cleanup_mkdir_testdir, "file::mkdir",
-		    "allow_mkdir /tmp/testdir/ 0755"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_mkdir_testdir, test_rmdir_testdir, cleanup_mkdir_testdir,
-		    "file::rmdir", "allow_rmdir /tmp/testdir/"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	setup_execute_bin_true, test_execute_bin_true,
-		    cleanup_execute_bin_true, "file::execute",
-		    "allow_execute /bin/true"}, {
-	NULL, test_chmod_dev_null, NULL, "file::chmod",
-		    "allow_chmod /dev/null 0666"}, {
-	NULL, test_chown_dev_null, NULL, "file::chown",
-		    "allow_chown /dev/null 0"}, {
-	NULL, test_chgrp_dev_null, NULL, "file::chgrp",
-		    "allow_chgrp /dev/null 0"}, {
-	NULL, test_ioctl_dev_null, NULL, "file::ioctl",
-		    "allow_ioctl /dev/null 0x5451"}, {
-	setup_chmod_group, test_chmod_dev_null, cleanup_chmod_group,
-		    "file::chmod", "allow_chmod @CHMOD_TARGET @CHMOD_MODES"}, {
-	setup_chown_group, test_chown_dev_null, cleanup_chown_group,
-		    "file::chown", "allow_chown @CHOWN_TARGET @CHOWN_IDS"}, {
-	setup_chown_group, test_chgrp_dev_null, cleanup_chown_group,
-		    "file::chgrp", "allow_chgrp @CHOWN_TARGET @CHOWN_IDS"}, {
-	setup_ioctl_group, test_ioctl_dev_null, cleanup_ioctl_group,
-		    "file::ioctl", "allow_ioctl @IOCTL_TARGET @IOCTL_NUMBERS"},
-	{
-	setup_test_file, test_file_open_0, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile0"}, {
-	setup_test_file, test_file_open_1, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile1"}, {
-	setup_test_file, test_file_open_1, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile1 0600"}, {
-	setup_test_file, test_file_open_2, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile2"}, {
-	setup_test_file, test_file_open_2, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile2"}, {
-	setup_test_file_truncate, test_file_open_2,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile2"}, {
-	setup_test_file, test_file_open_3, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile3"}, {
-	setup_test_file, test_file_open_3, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile3 0600"}, {
-	setup_test_file, test_file_open_4, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile4"}, {
-	setup_test_file, test_file_open_5, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile5"}, {
-	setup_test_file, test_file_open_5, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile5 0600"}, {
-	setup_test_file, test_file_open_6, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile6"}, {
-	setup_test_file, test_file_open_6, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile6"}, {
-	setup_test_file_truncate, test_file_open_6,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile6"}, {
-	setup_test_file, test_file_open_7, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile7"}, {
-	setup_test_file, test_file_open_7, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile7 0600"}, {
-	setup_test_file, test_file_open_8, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile8"}, {
-	setup_test_file, test_file_open_8, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile8"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile9"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile9 0600"}, {
-	setup_test_file, test_file_open_9, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile9"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile10"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile10"}, {
-	setup_test_file, test_file_open_10, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile10"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile11"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile11 0600"}, {
-	setup_test_file, test_file_open_11, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile11"}, {
-	setup_test_file, test_file_open_12, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile12"}, {
-	setup_test_file, test_file_open_13, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile13"}, {
-	setup_test_file, test_file_open_13, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile13 0600"}, {
-	setup_test_file, test_file_open_14, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile14"}, {
-	setup_test_file, test_file_open_14, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile14"}, {
-	setup_test_file_truncate, test_file_open_14,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile14"}, {
-	setup_test_file, test_file_open_15, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile15"}, {
-	setup_test_file, test_file_open_15, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile15 0600"}, {
-	setup_test_file, test_file_open_16, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile16"}, {
-	setup_test_file, test_file_open_16, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile16"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile17"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile17 0600"}, {
-	setup_test_file, test_file_open_17, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile17"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile18"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile18"}, {
-	setup_test_file, test_file_open_18, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile18"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile19"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile19 0600"}, {
-	setup_test_file, test_file_open_19, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile19"}, {
-	setup_test_file, test_file_open_20, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile20"}, {
-	setup_test_file, test_file_open_21, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile21"}, {
-	setup_test_file, test_file_open_21, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile21 0600"}, {
-	setup_test_file, test_file_open_22, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile22"}, {
-	setup_test_file, test_file_open_22, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile22"}, {
-	setup_test_file_truncate, test_file_open_22,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile22"}, {
-	setup_test_file, test_file_open_23, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile23"}, {
-	setup_test_file, test_file_open_23, cleanup_test_file,
-		    "file::create", "allow_create /tmp/testfile23 0600"}, {
-	setup_all_test_file, test_file_open_0, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile0"}, {
-	setup_all_test_file, test_file_open_2, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile2"}, {
-	setup_all_test_file, test_file_open_2, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile2"}, {
-	setup_all_test_file_truncate, test_file_open_2,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile2"}, {
-	setup_all_test_file, test_file_open_4, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile4"}, {
-	setup_all_test_file, test_file_open_6, cleanup_test_file,
-		    "file::open", "allow_read /tmp/testfile6"}, {
-	setup_all_test_file, test_file_open_6, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile6"}, {
-	setup_all_test_file_truncate, test_file_open_6,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile6"}, {
-	setup_all_test_file, test_file_open_8, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile8"}, {
-	setup_all_test_file, test_file_open_8, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile8"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_10, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile10"}, {
-	setup_all_test_file, test_file_open_12, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile12"}, {
-	setup_all_test_file, test_file_open_14, cleanup_test_file,
-		    "file::open", "allow_write /tmp/testfile14"}, {
-	setup_all_test_file, test_file_open_14, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile14"}, {
-	setup_all_test_file_truncate, test_file_open_14,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile14"}, {
-	setup_all_test_file, test_file_open_16, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile16"}, {
-	setup_all_test_file, test_file_open_16, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile16"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_18, cleanup_test_file,
-		    "file::rewrite", "allow_rewrite /tmp/testfile18"}, {
-	setup_all_test_file, test_file_open_20, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile20"}, {
-	setup_all_test_file, test_file_open_22, cleanup_test_file,
-		    "file::open", "allow_read/write /tmp/testfile22"}, {
-	setup_all_test_file, test_file_open_22, cleanup_test_file,
-		    "file::truncate", "allow_truncate /tmp/testfile22"}, {
-	setup_all_test_file_truncate, test_file_open_22,
-		    cleanup_test_file_truncate, "file::rewrite",
-		    "allow_rewrite /tmp/testfile22"}, {
-	NULL}
-};
-
-int main(void)
-{
-	int i;
-	tomoyo_test_init();
-	for (i = 0; tests[i].do_test; i++) {
-		int trial;
-		for (trial = 0; trial < 2; trial++) {
-			int should_fail;
-			for (should_fail = 0; should_fail < 2; should_fail++) {
-				if (tests[i].do_setup)
-					tests[i].do_setup();
-				if (!should_fail)
-					write_domain_policy(tests[i].policy, 0);
-				set_profile(3, tests[i].name);
-				tests[i].do_test();
-				show_result(tests[i].policy, !should_fail);
-				set_profile(0, tests[i].name);
-				if (tests[i].do_cleanup)
-					tests[i].do_cleanup();
-				if (!should_fail)
-					write_domain_policy(tests[i].policy, 1);
-			}
-		}
-	}
-	for (i = 0; tests[i].do_test; i++) {
-		int mode;
-		for (mode = 0; mode < 4; mode++) {
-			if (tests[i].do_setup)
-				tests[i].do_setup();
-			set_profile(mode, tests[i].name);
-			tests[i].do_test();
-			show_result(tests[i].name, 1);
-			set_profile(0, tests[i].name);
-			if (tests[i].do_cleanup)
-				tests[i].do_cleanup();
-		}
-	}
-	fprintf(domain_fp, "delete %s\n", self_domain);
-	return 0;
-}
testcases/kernel/security/tomoyo/tomoyo_policy_io_test.c deleted +0 -195
deleted file mode 100644
index b1897a0fc..000000000
@@ -1,195 +0,0 @@
-/******************************************************************************/
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
-/*                                                                            */
-/******************************************************************************/
-/*
- * tomoyo_policy_io_test.c
- *
- * Testing program for security/tomoyo/
- *
- * Copyright (C) 2005-2010  NTT DATA CORPORATION
- */
-#include "include.h"
-
-static FILE *policy_fp = NULL;
-static const char *policy_file = "";
-
-static void try_io(const char *policy, const char should_success)
-{
-	FILE *fp = fopen(policy_file, "r");
-	char buffer[8192];
-	int policy_found = 0;
-	memset(buffer, 0, sizeof(buffer));
-	printf("%s: ", policy);
-	fprintf(policy_fp, "%s\n", policy);
-	if (!fp) {
-		printf("BUG: policy read failed\n");
-		return;
-	}
-	while (fgets(buffer, sizeof(buffer) - 1, fp)) {
-		char *cp = strchr(buffer, '\n');
-		if (cp)
-			*cp = '\0';
-		if (!strcmp(buffer, policy)) {
-			policy_found = 1;
-			break;
-		}
-	}
-	fclose(fp);
-	if (should_success) {
-		if (policy_found)
-			printf("OK\n");
-		else
-			printf("BUG: policy write failed\n");
-	} else {
-		if (!policy_found)
-			printf("OK : write rejected.\n");
-		else
-			printf("BUG: policy write not rejected.\n");
-	}
-	fprintf(policy_fp, "delete %s\n", policy);
-}
-
-static void stage_policy_io_test(void)
-{
-	int i;
-	policy_file = proc_policy_domain_policy;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

testcases/kernel/security/tomoyo/tomoyo_policy_memory_test.c deleted +0 -358
deleted file mode 100644
index a6620ba30..000000000

Lines of this file are not shown. View the raw message.

testcases/kernel/security/tomoyo/tomoyo_rewrite_test.c deleted +0 -169
deleted file mode 100644
index 7bc22c39b..000000000

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

Part of the diff is not shown here. View the raw message.

#3 lore raw

Hello.

Thank you for heads-up.

Removing testing suite for tomoyo from the LTP testcases folder is fine, for the latest testing suite for tomoyo is maintained at
https://osdn.net/projects/tomoyo/scm/svn/tree/head/trunk/2.6.x/tomoyo-tools/kernel_test/
and tomoyo is tested by syzbot.

But the reasoning "the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor" is wrong; the functionality cannot be replaced by other LSM modules. ;-)

Quoted 19 lines · Cyril Hrubis

Hi!
CCing the contact on https://tomoyo.osdn.jp/support.html.en

If anyone wants to pick up the testsuite and maintain it please speak up.

Quoted 13 lines

The tomoyo testing suite is built and installed inside the LTP testcases folder, but it's not used by any runtest file. It seems an old and unmaintained testing suite that uses old LTP API and ltp_clone_quick that is going to be deprecated.

We suppose to update it using new LTP API, cleaning up the code and removing deprecated functions, but nowadays the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor and not maintained anymore in years of development.

For this reason, this patch is going to remove it from LTP installation.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hello Tomoyo devs,

thank you for your feedback, we will continue on our side then.

Regards,
Andrea

Quoted 34 lines · Tetsuo Handa

Hello.

Thank you for heads-up.

Removing testing suite for tomoyo from the LTP testcases folder is fine, for the latest testing suite for tomoyo is maintained at
https://osdn.net/projects/tomoyo/scm/svn/tree/head/trunk/2.6.x/tomoyo-tools/kernel_test/
and tomoyo is tested by syzbot.

But the reasoning "the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor" is wrong; the functionality cannot be replaced by other LSM modules. ;-)

Quoted 19 lines · Cyril Hrubis

Hi!
CCing the contact on https://tomoyo.osdn.jp/support.html.en

If anyone wants to pick up the testsuite and maintain it please speak up.

Quoted 13 lines

The tomoyo testing suite is built and installed inside the LTP testcases folder, but it's not used by any runtest file. It seems an old and unmaintained testing suite that uses old LTP API and ltp_clone_quick that is going to be deprecated.

We suppose to update it using new LTP API, cleaning up the code and removing deprecated functions, but nowadays the whole Tomoyo linux functionality seems replaced by SELinux or AppArmor and not maintained anymore in years of development.

For this reason, this patch is going to remove it from LTP installation.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp