From: Richard Jones Date: Fri, 22 May 2009 09:52:28 +0000 (+0100) Subject: Add 'debug env' command to print environment. X-Git-Tag: 1.0.32~6 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=5f76f421d05041fc66fe0944ea3b85723f0d4cc4;p=libguestfs.git Add 'debug env' command to print environment. --- diff --git a/daemon/debug.c b/daemon/debug.c index 6d6d2b5..6e9e373 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -45,12 +45,14 @@ struct cmd { }; static char *debug_help (const char *subcmd, int argc, char *const *const argv); +static char *debug_env (const char *subcmd, int argc, char *const *const argv); static char *debug_fds (const char *subcmd, int argc, char *const *const argv); static char *debug_segv (const char *subcmd, int argc, char *const *const argv); static char *debug_sh (const char *subcmd, int argc, char *const *const argv); static struct cmd cmds[] = { { "help", debug_help }, + { "env", debug_env }, { "fds", debug_fds }, { "segv", debug_segv }, { "sh", debug_sh }, @@ -196,7 +198,27 @@ debug_sh (const char *subcmd, int argc, char *const *const argv) r = commandv (&out, &err, argv); if (r == -1) { - reply_with_error ("ps: %s", err); + reply_with_error ("sh: %s", err); + free (out); + free (err); + return NULL; + } + + free (err); + + return out; +} + +/* Print the environment that commands get (by running external printenv). */ +static char * +debug_env (const char *subcmd, int argc, char *const *const argv) +{ + int r; + char *out, *err; + + r = command (&out, &err, "printenv", NULL); + if (r == -1) { + reply_with_error ("printenv: %s", err); free (out); free (err); return NULL;