On Sun, May 07, 2023 at 11:43:17AM +0100, Richard W.M. Jones wrote:
This is not secure so should not be used routinely. Also we do not
attempt to filter environment variables, so even ones containing
multiple lines or special characters are all sent to nbdkit_debug.
The reason for adding this is to allow for debugging the new
nbd_set_socket_activation_name(3) API added in libnbd 1.16.
---
+static void
+dump_environment (void)
+{
+ size_t i;
+
+ for (i = 0; environ[i]; ++i)
+ nbdkit_debug ("%s", environ[i]);
We have shell_quote in common/utils/quote.c; shouldn't we use it here
to avoid ambiguities when an env-var contains newline?
+}
+
+#endif /* !WIN32 */
+
int
main (int argc, char *argv[])
{
@@ -662,6 +682,14 @@ main (int argc, char *argv[])
/* Check all debug flags were used, and free them. */
free_debug_flags ();
+#ifndef WIN32
+ /* Dump the environment if asked. This is the earliest we can do it
+ * because it uses a debug flag.
+ */
+ if (nbdkit_debug_environ && verbose)
+ dump_environment ();
Why does this not work on WIN32?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org