[Pkg-libvirt-commits] [libguestfs] 77/179: handle: Process empty LIBGUESTFS_* environment variables correctly (RHBZ#1153515).
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 31 19:08:26 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit 249aae0c2ffa685008c03f5d06e05c2989b1ec99
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Oct 16 08:36:33 2014 +0200
handle: Process empty LIBGUESTFS_* environment variables correctly (RHBZ#1153515).
Ignore an environment variable:
- if an environment variable is an empty string, AND
- if an empty string would have no meaning for that environment
variable (eg. LIBGUESTFS_BACKEND can only take on certain values,
and an empty string is not one of them).
Note that LIBGUESTFS_BACKEND_SETTINGS is meaningful as an empty
string, and for this case I have removed the STRNEQ (str, "") test.
Previously:
$ LIBGUESTFS_BACKEND="" guestfish -a /dev/null run
libguestfs: error: invalid backend:
After this commit:
$ LIBGUESTFS_BACKEND="" guestfish -a /dev/null run
(no error message is printed)
---
src/handle.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/handle.c b/src/handle.c
index 0200528..141ba7d 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -192,13 +192,13 @@ parse_environment (guestfs_h *g,
guestfs_set_verbose (g, 1);
str = do_getenv (data, "LIBGUESTFS_TMPDIR");
- if (str) {
+ if (str && STRNEQ (str, "")) {
if (guestfs_set_tmpdir (g, str) == -1)
return -1;
}
str = do_getenv (data, "LIBGUESTFS_CACHEDIR");
- if (str) {
+ if (str && STRNEQ (str, "")) {
if (guestfs_set_cachedir (g, str) == -1)
return -1;
}
@@ -208,15 +208,15 @@ parse_environment (guestfs_h *g,
return -1;
str = do_getenv (data, "LIBGUESTFS_PATH");
- if (str)
+ if (str && STRNEQ (str, ""))
guestfs_set_path (g, str);
str = do_getenv (data, "LIBGUESTFS_HV");
- if (str)
+ if (str && STRNEQ (str, ""))
guestfs_set_hv (g, str);
else {
str = do_getenv (data, "LIBGUESTFS_QEMU");
- if (str)
+ if (str && STRNEQ (str, ""))
guestfs_set_hv (g, str);
}
@@ -225,7 +225,7 @@ parse_environment (guestfs_h *g,
guestfs_set_append (g, str);
str = do_getenv (data, "LIBGUESTFS_MEMSIZE");
- if (str) {
+ if (str && STRNEQ (str, "")) {
if (sscanf (str, "%d", &memsize) != 1) {
error (g, _("non-numeric value for LIBGUESTFS_MEMSIZE"));
return -1;
@@ -237,20 +237,20 @@ parse_environment (guestfs_h *g,
}
str = do_getenv (data, "LIBGUESTFS_BACKEND");
- if (str) {
+ if (str && STRNEQ (str, "")) {
if (guestfs_set_backend (g, str) == -1)
return -1;
}
else {
str = do_getenv (data, "LIBGUESTFS_ATTACH_METHOD");
- if (str) {
+ if (str && STRNEQ (str, "")) {
if (guestfs_set_backend (g, str) == -1)
return -1;
}
}
str = do_getenv (data, "LIBGUESTFS_BACKEND_SETTINGS");
- if (str && STRNEQ (str, "")) {
+ if (str) {
CLEANUP_FREE_STRING_LIST char **settings = guestfs___split_string (':', str);
if (settings == NULL) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list