diff options
Diffstat (limited to 'daemon/debug.c')
-rw-r--r-- | daemon/debug.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/daemon/debug.c b/daemon/debug.c index 97d21f03..41bae38b 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -32,6 +32,15 @@ #include "daemon.h" #include "actions.h" +GUESTFSD_EXT_CMD(str_printenv, printenv); +GUESTFSD_EXT_CMD(str_ldd, ldd); +GUESTFSD_EXT_CMD(str_ls, ls); +GUESTFSD_EXT_CMD(str_find, find); +GUESTFSD_EXT_CMD(str_xargs, xargs); +GUESTFSD_EXT_CMD(str_file, file); +GUESTFSD_EXT_CMD(str_grep, grep); +GUESTFSD_EXT_CMD(str_gawk, gawk); + /* This command exposes debugging information, internals and * status. There is no comprehensive documentation for this * command. You have to look at the source code in this file @@ -275,7 +284,7 @@ debug_env (const char *subcmd, size_t argc, char *const *const argv) int r; char *out, *err; - r = command (&out, &err, "printenv", NULL); + r = command (&out, &err, str_printenv, NULL); if (r == -1) { reply_with_error ("printenv: %s", err); free (out); @@ -318,12 +327,14 @@ debug_binaries (const char *subcmd, size_t argc, char *const *const argv) { int r; char *out, *err; + char cmd[256]; - const char cmd[] = - "find / -xdev -type f -executable " - "| xargs file -i " - "| grep application/x-executable " - "| gawk -F: '{print $1}'"; + snprintf (cmd, sizeof (cmd), + "%s / -xdev -type f -executable " + "| %s %s -i " + "| %s application/x-executable " + "| %s -F: '{print $1}'", + str_find, str_xargs, str_file, str_grep, str_gawk); r = command (&out, &err, "sh", "-c", cmd, NULL); if (r == -1) { @@ -358,7 +369,7 @@ debug_ldd (const char *subcmd, size_t argc, char *const *const argv) * Also 'ldd' randomly sends messages to stderr and errors to stdout * depending on the phase of the moon. */ - r = command (&out, &err, "ldd", "-r", argv[0], NULL); + r = command (&out, &err, str_ldd, "-r", argv[0], NULL); if (r == -1) { reply_with_error ("ldd: %s: %s", argv[0], err); free (out); @@ -389,7 +400,7 @@ debug_ls (const char *subcmd, size_t argc, char *const *const argv) const char *cargv[len+3]; size_t i; - cargv[0] = "ls"; + cargv[0] = str_ls; cargv[1] = "-a"; for (i = 0; i < len; ++i) cargv[2+i] = argv[i]; @@ -419,7 +430,7 @@ debug_ll (const char *subcmd, size_t argc, char *const *const argv) const char *cargv[len+3]; size_t i; - cargv[0] = "ls"; + cargv[0] = str_ls; cargv[1] = "-la"; for (i = 0; i < len; ++i) cargv[2+i] = argv[i]; |