Replace verbose flag with debug flag.
This is more accurate since it actually uses the debug subsystem.
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
/*
|
/*
|
||||||
* Test program to exercise seccomp(2) and ptrace(2) intercept code.
|
* Test program to exercise seccomp(2) and ptrace(2) intercept code.
|
||||||
*
|
*
|
||||||
* Usage: test_ptrace [-v] [command]
|
* Usage: test_ptrace [-d 1-3] [command]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Ignore architecture restrictions and define this unilaterally. */
|
/* Ignore architecture restrictions and define this unilaterally. */
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
#include "exec_ptrace.c"
|
#include "exec_ptrace.c"
|
||||||
|
|
||||||
static sig_atomic_t got_sigchld;
|
static sig_atomic_t got_sigchld;
|
||||||
static int verbose;
|
static int debug;
|
||||||
int sudo_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
int sudo_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
||||||
|
|
||||||
sudo_dso_public int main(int argc, char *argv[]);
|
sudo_dso_public int main(int argc, char *argv[]);
|
||||||
@@ -78,7 +78,7 @@ init_debug_files(struct sudo_conf_debug_file_list *file_list,
|
|||||||
debug_decl(init_debug_files, SUDO_DEBUG_EXEC);
|
debug_decl(init_debug_files, SUDO_DEBUG_EXEC);
|
||||||
|
|
||||||
TAILQ_INIT(file_list);
|
TAILQ_INIT(file_list);
|
||||||
switch (verbose) {
|
switch (debug) {
|
||||||
case 0:
|
case 0:
|
||||||
debug_return;
|
debug_return;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -104,6 +104,7 @@ main(int argc, char *argv[])
|
|||||||
struct sudo_debug_file debug_file;
|
struct sudo_debug_file debug_file;
|
||||||
const char *base, *shell = _PATH_SUDO_BSHELL;
|
const char *base, *shell = _PATH_SUDO_BSHELL;
|
||||||
struct intercept_closure closure = { 0 };
|
struct intercept_closure closure = { 0 };
|
||||||
|
const char *errstr;
|
||||||
sigset_t blocked, empty;
|
sigset_t blocked, empty;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
pid_t child, pid;
|
pid_t child, pid;
|
||||||
@@ -115,13 +116,15 @@ main(int argc, char *argv[])
|
|||||||
if (!have_seccomp_action("trap"))
|
if (!have_seccomp_action("trap"))
|
||||||
sudo_fatalx("SECCOMP_MODE_FILTER not available in this kernel");
|
sudo_fatalx("SECCOMP_MODE_FILTER not available in this kernel");
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "v")) != -1) {
|
while ((ch = getopt(argc, argv, "d:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'v':
|
case 'd':
|
||||||
verbose++;
|
debug = sudo_strtonum(optarg, 1, INT_MAX, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
sudo_fatalx(U_("%s: %s"), optarg, U_(errstr));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "usage: %s [-v] [command]\n", getprogname());
|
fprintf(stderr, "usage: %s [-d 1-3] [command]\n", getprogname());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +136,7 @@ main(int argc, char *argv[])
|
|||||||
base = strrchr(shell, '/');
|
base = strrchr(shell, '/');
|
||||||
base = base ? base + 1 : shell;
|
base = base ? base + 1 : shell;
|
||||||
|
|
||||||
/* Set debug level based on the verbose flag. */
|
/* Set debug level based on the debug flag. */
|
||||||
init_debug_files(&debug_files, &debug_file);
|
init_debug_files(&debug_files, &debug_file);
|
||||||
sudo_debug_instance = sudo_debug_register(getprogname(),
|
sudo_debug_instance = sudo_debug_register(getprogname(),
|
||||||
NULL, NULL, &debug_files, -1);
|
NULL, NULL, &debug_files, -1);
|
||||||
@@ -207,7 +210,6 @@ main(int argc, char *argv[])
|
|||||||
if (pid == child)
|
if (pid == child)
|
||||||
return WTERMSIG(status) | 128;
|
return WTERMSIG(status) | 128;
|
||||||
} else if (WIFSTOPPED(status)) {
|
} else if (WIFSTOPPED(status)) {
|
||||||
/* XXX - verbose info to stderr, not just debug log */
|
|
||||||
exec_ptrace_handled(pid, status, &closure);
|
exec_ptrace_handled(pid, status, &closure);
|
||||||
} else {
|
} else {
|
||||||
sudo_fatalx("%d: unknown status 0x%x", pid, status);
|
sudo_fatalx("%d: unknown status 0x%x", pid, status);
|
||||||
|
Reference in New Issue
Block a user