summaryrefslogtreecommitdiffstats
path: root/daemon/debug.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-05-22 10:52:28 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-05-22 10:52:28 +0100
commit5f76f421d05041fc66fe0944ea3b85723f0d4cc4 (patch)
treef111bfda236f7cdbf53c47e6af09ccf299db4622 /daemon/debug.c
parent31aaa279b51a5a16dbbd40879696eb850abfb224 (diff)
downloadlibguestfs-5f76f421d05041fc66fe0944ea3b85723f0d4cc4.tar.gz
libguestfs-5f76f421d05041fc66fe0944ea3b85723f0d4cc4.tar.xz
libguestfs-5f76f421d05041fc66fe0944ea3b85723f0d4cc4.zip
Add 'debug env' command to print environment.
Diffstat (limited to 'daemon/debug.c')
-rw-r--r--daemon/debug.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/daemon/debug.c b/daemon/debug.c
index 6d6d2b59..6e9e3730 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;