003 File Manager
Current Path:
/usr/src/contrib/capsicum-test
usr
/
src
/
contrib
/
capsicum-test
/
📁
..
📄
.gitignore
(235 B)
📄
CONTRIBUTING.md
(880 B)
📄
GNUmakefile
(2.22 KB)
📄
LICENSE
(1.4 KB)
📄
README.md
(2.7 KB)
📄
capability-fd-pair.cc
(5.52 KB)
📄
capability-fd.cc
(42.15 KB)
📄
capmode.cc
(19.24 KB)
📄
capsicum-freebsd.h
(1.97 KB)
📄
capsicum-linux.h
(1.17 KB)
📄
capsicum-rights.h
(2.86 KB)
📄
capsicum-test-main.cc
(4.23 KB)
📄
capsicum-test.cc
(2.63 KB)
📄
capsicum-test.h
(9.9 KB)
📄
capsicum.h
(4.49 KB)
📄
fcntl.cc
(14.48 KB)
📄
fexecve.cc
(6.08 KB)
📄
ioctl.cc
(6.93 KB)
📄
linux.cc
(48.75 KB)
📄
makefile
(1.59 KB)
📄
mini-me.c
(1.04 KB)
📄
mqueue.cc
(3.24 KB)
📄
openat.cc
(14.52 KB)
📄
overhead.cc
(1.28 KB)
📄
procdesc.cc
(26.95 KB)
📄
rename.cc
(1.59 KB)
📄
sctp.cc
(7.14 KB)
📄
select.cc
(4 KB)
📄
showrights
(4.81 KB)
📄
smoketest.c
(4.86 KB)
📄
socket.cc
(10.56 KB)
📄
syscalls.h
(8.36 KB)
📄
sysctl.cc
(403 B)
📄
waittest.c
(1 KB)
Editing: capsicum-test.cc
#include "capsicum-test.h" #include <stdio.h> #include <string.h> #include <signal.h> #include <map> #include <vector> #include <string> bool verbose = false; bool tmpdir_on_tmpfs = false; bool force_mt = false; bool force_nofork = false; uid_t other_uid = 0; namespace { std::map<std::string, std::string> tmp_paths; } const char *TmpFile(const char *p) { std::string pathname(p); if (tmp_paths.find(pathname) == tmp_paths.end()) { std::string fullname = tmpdir + "/" + pathname; tmp_paths[pathname] = fullname; } return tmp_paths[pathname].c_str(); } char ProcessState(int pid) { #ifdef __linux__ // Open the process status file. char s[1024]; snprintf(s, sizeof(s), "/proc/%d/status", pid); FILE *f = fopen(s, "r"); if (f == NULL) return '\0'; // Read the file line by line looking for the state line. const char *prompt = "State:\t"; while (!feof(f)) { fgets(s, sizeof(s), f); if (!strncmp(s, prompt, strlen(prompt))) { fclose(f); return s[strlen(prompt)]; } } fclose(f); return '?'; #endif #ifdef __FreeBSD__ char buffer[1024]; snprintf(buffer, sizeof(buffer), "ps -p %d -o state | grep -v STAT", pid); sig_t original = signal(SIGCHLD, SIG_IGN); FILE* cmd = popen(buffer, "r"); usleep(50000); // allow any pending SIGCHLD signals to arrive signal(SIGCHLD, original); int result = fgetc(cmd); fclose(cmd); // Map FreeBSD codes to Linux codes. switch (result) { case EOF: return '\0'; case 'D': // disk wait case 'R': // runnable case 'S': // sleeping case 'T': // stopped case 'Z': // zombie return result; case 'W': // idle interrupt thread return 'S'; case 'I': // idle return 'S'; case 'L': // waiting to acquire lock default: return '?'; } #endif } typedef std::vector<std::string> TestList; typedef std::map<std::string, TestList*> SkippedTestMap; static SkippedTestMap skipped_tests; void TestSkipped(const char *testcase, const char *test, const std::string& reason) { if (skipped_tests.find(reason) == skipped_tests.end()) { skipped_tests[reason] = new TestList; } std::string testname(testcase); testname += "."; testname += test; skipped_tests[reason]->push_back(testname); } void ShowSkippedTests(std::ostream& os) { for (SkippedTestMap::iterator skiplist = skipped_tests.begin(); skiplist != skipped_tests.end(); ++skiplist) { os << "Following tests were skipped because: " << skiplist->first << std::endl; for (size_t ii = 0; ii < skiplist->second->size(); ++ii) { const std::string& testname((*skiplist->second)[ii]); os << " " << testname << std::endl; } } }
Upload File
Create Folder