diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-05-22 13:50:19 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-05-22 13:50:19 +0100 |
commit | 87d604f88c44f891a338349e2b012b6deadf7896 (patch) | |
tree | 95aa1791c0b02fd2cdcbbce032868b2ad95500cb /daemon | |
parent | f774f8fd8d107e6d820ce414f9765745ea75dad7 (diff) | |
download | libguestfs-87d604f88c44f891a338349e2b012b6deadf7896.tar.gz libguestfs-87d604f88c44f891a338349e2b012b6deadf7896.tar.xz libguestfs-87d604f88c44f891a338349e2b012b6deadf7896.zip |
debug: Add setenv debugging command.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/debug.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/daemon/debug.c b/daemon/debug.c index 96c0ad84..97d21f03 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -61,6 +61,7 @@ static char *debug_ll (const char *subcmd, size_t argc, char *const *const argv) static char *debug_progress (const char *subcmd, size_t argc, char *const *const argv); static char *debug_qtrace (const char *subcmd, size_t argc, char *const *const argv); static char *debug_segv (const char *subcmd, size_t argc, char *const *const argv); +static char *debug_setenv (const char *subcmd, size_t argc, char *const *const argv); static char *debug_sh (const char *subcmd, size_t argc, char *const *const argv); static struct cmd cmds[] = { @@ -75,6 +76,7 @@ static struct cmd cmds[] = { { "progress", debug_progress }, { "qtrace", debug_qtrace }, { "segv", debug_segv }, + { "setenv", debug_setenv }, { "sh", debug_sh }, { NULL, NULL } }; @@ -286,6 +288,28 @@ debug_env (const char *subcmd, size_t argc, char *const *const argv) return out; } +/* Set an environment variable in the daemon and future subprocesses. */ +static char * +debug_setenv (const char *subcmd, size_t argc, char *const *const argv) +{ + char *ret; + + if (argc != 2) { + reply_with_error ("setenv: two arguments expected"); + return NULL; + } + + setenv (argv[0], argv[1], 1); + + ret = strdup ("ok"); + if (NULL == ret) { + reply_with_perror ("strdup"); + return NULL; + } + + return ret; +} + /* Return binaries in the appliance. * See tests/regressions/rhbz727178.sh */ |