|
|
43fe83 |
From 8af57380c9ea6f6ffec579804a409e54d323f39a Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <8af57380c9ea6f6ffec579804a409e54d323f39a.1383321465.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Wed, 30 Oct 2013 17:01:51 +0000
|
|
|
43fe83 |
Subject: [PATCH] Remove all direct use of getenv
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1015247
|
|
|
43fe83 |
|
|
|
43fe83 |
Unconditional use of getenv is not secure in setuid env.
|
|
|
43fe83 |
While not all libvirt code runs in a setuid env (since
|
|
|
43fe83 |
much of it only exists inside libvirtd) this is not always
|
|
|
43fe83 |
clear to developers. So make all the code paranoid, even
|
|
|
43fe83 |
if it only ever runs inside libvirtd.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 1e4a02bdfe6307f93763fa2c9681f280c564aee5)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
daemon/libvirtd.c | 2 +-
|
|
|
43fe83 |
src/driver.c | 3 ++-
|
|
|
43fe83 |
src/libvirt.c | 2 +-
|
|
|
43fe83 |
src/locking/lock_daemon.c | 4 ++--
|
|
|
43fe83 |
src/locking/lock_driver_lockd.c | 2 +-
|
|
|
43fe83 |
src/locking/lock_manager.c | 2 +-
|
|
|
43fe83 |
src/lxc/lxc_driver.c | 4 ++--
|
|
|
43fe83 |
src/remote/remote_driver.c | 4 ++--
|
|
|
43fe83 |
src/rpc/virnettlscontext.c | 4 ++--
|
|
|
43fe83 |
src/util/virauth.c | 2 +-
|
|
|
43fe83 |
src/util/virfile.c | 7 +++++--
|
|
|
43fe83 |
src/util/virlog.c | 8 ++++----
|
|
|
43fe83 |
src/util/virrandom.c | 2 +-
|
|
|
43fe83 |
src/util/virutil.c | 8 ++++----
|
|
|
43fe83 |
src/vbox/vbox_XPCOMCGlue.c | 2 +-
|
|
|
43fe83 |
src/vbox/vbox_tmpl.c | 4 ++--
|
|
|
43fe83 |
tools/virsh.c | 18 +++++++++---------
|
|
|
43fe83 |
17 files changed, 41 insertions(+), 37 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
|
|
|
43fe83 |
index c9cd1a1..808bd4b 100644
|
|
|
43fe83 |
--- a/daemon/libvirtd.c
|
|
|
43fe83 |
+++ b/daemon/libvirtd.c
|
|
|
43fe83 |
@@ -991,7 +991,7 @@ static int migrateProfile(void)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
- config_home = getenv("XDG_CONFIG_HOME");
|
|
|
43fe83 |
+ config_home = virGetEnvBlockSUID("XDG_CONFIG_HOME");
|
|
|
43fe83 |
if (config_home && config_home[0] != '\0') {
|
|
|
43fe83 |
if (VIR_STRDUP(xdg_dir, config_home) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
diff --git a/src/driver.c b/src/driver.c
|
|
|
43fe83 |
index a08dd34..ab2a253 100644
|
|
|
43fe83 |
--- a/src/driver.c
|
|
|
43fe83 |
+++ b/src/driver.c
|
|
|
43fe83 |
@@ -27,6 +27,7 @@
|
|
|
43fe83 |
#include "driver.h"
|
|
|
43fe83 |
#include "viralloc.h"
|
|
|
43fe83 |
#include "virlog.h"
|
|
|
43fe83 |
+#include "virutil.h"
|
|
|
43fe83 |
#include "configmake.h"
|
|
|
43fe83 |
#include "virstring.h"
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -43,7 +44,7 @@ static const char *moddir = NULL;
|
|
|
43fe83 |
void
|
|
|
43fe83 |
virDriverModuleInitialize(const char *defmoddir)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- const char *custommoddir = getenv("LIBVIRT_DRIVER_DIR");
|
|
|
43fe83 |
+ const char *custommoddir = virGetEnvBlockSUID("LIBVIRT_DRIVER_DIR");
|
|
|
43fe83 |
if (custommoddir)
|
|
|
43fe83 |
moddir = custommoddir;
|
|
|
43fe83 |
else if (defmoddir)
|
|
|
43fe83 |
diff --git a/src/libvirt.c b/src/libvirt.c
|
|
|
43fe83 |
index 4c1992c..0a024a9 100644
|
|
|
43fe83 |
--- a/src/libvirt.c
|
|
|
43fe83 |
+++ b/src/libvirt.c
|
|
|
43fe83 |
@@ -1094,7 +1094,7 @@ virConnectGetDefaultURI(virConfPtr conf,
|
|
|
43fe83 |
{
|
|
|
43fe83 |
int ret = -1;
|
|
|
43fe83 |
virConfValuePtr value = NULL;
|
|
|
43fe83 |
- char *defname = getenv("LIBVIRT_DEFAULT_URI");
|
|
|
43fe83 |
+ const char *defname = virGetEnvBlockSUID("LIBVIRT_DEFAULT_URI");
|
|
|
43fe83 |
if (defname && *defname) {
|
|
|
43fe83 |
VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname);
|
|
|
43fe83 |
*name = defname;
|
|
|
43fe83 |
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
|
|
|
43fe83 |
index 77d6e0d..0ac16c3 100644
|
|
|
43fe83 |
--- a/src/locking/lock_daemon.c
|
|
|
43fe83 |
+++ b/src/locking/lock_daemon.c
|
|
|
43fe83 |
@@ -605,7 +605,7 @@ virLockDaemonSetupNetworkingSystemD(virNetServerPtr srv)
|
|
|
43fe83 |
|
|
|
43fe83 |
VIR_DEBUG("Setting up networking from systemd");
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (!(pidstr = getenv("LISTEN_PID"))) {
|
|
|
43fe83 |
+ if (!(pidstr = virGetEnvAllowSUID("LISTEN_PID"))) {
|
|
|
43fe83 |
VIR_DEBUG("No LISTEN_FDS from systemd");
|
|
|
43fe83 |
return 0;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
@@ -621,7 +621,7 @@ virLockDaemonSetupNetworkingSystemD(virNetServerPtr srv)
|
|
|
43fe83 |
return 0;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (!(fdstr = getenv("LISTEN_FDS"))) {
|
|
|
43fe83 |
+ if (!(fdstr = virGetEnvAllowSUID("LISTEN_FDS"))) {
|
|
|
43fe83 |
VIR_DEBUG("No LISTEN_FDS from systemd");
|
|
|
43fe83 |
return 0;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
|
|
|
43fe83 |
index b115799..86ce2d8 100644
|
|
|
43fe83 |
--- a/src/locking/lock_driver_lockd.c
|
|
|
43fe83 |
+++ b/src/locking/lock_driver_lockd.c
|
|
|
43fe83 |
@@ -84,7 +84,7 @@ static virLockManagerLockDaemonDriverPtr driver = NULL;
|
|
|
43fe83 |
static const char *
|
|
|
43fe83 |
virLockManagerLockDaemonFindDaemon(void)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- const char *customDaemon = getenv("VIRTLOCKD_PATH");
|
|
|
43fe83 |
+ const char *customDaemon = virGetEnvBlockSUID("VIRTLOCKD_PATH");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (customDaemon)
|
|
|
43fe83 |
return customDaemon;
|
|
|
43fe83 |
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
|
|
|
43fe83 |
index aff54c0..f09c168 100644
|
|
|
43fe83 |
--- a/src/locking/lock_manager.c
|
|
|
43fe83 |
+++ b/src/locking/lock_manager.c
|
|
|
43fe83 |
@@ -135,7 +135,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
|
|
|
43fe83 |
void *handle = NULL;
|
|
|
43fe83 |
virLockDriverPtr driver;
|
|
|
43fe83 |
virLockManagerPluginPtr plugin = NULL;
|
|
|
43fe83 |
- const char *moddir = getenv("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
|
|
|
43fe83 |
+ const char *moddir = virGetEnvBlockSUID("LIBVIRT_LOCK_MANAGER_PLUGIN_DIR");
|
|
|
43fe83 |
char *modfile = NULL;
|
|
|
43fe83 |
char *configFile = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
|
|
|
43fe83 |
index 7999b8c..b746ffd 100644
|
|
|
43fe83 |
--- a/src/lxc/lxc_driver.c
|
|
|
43fe83 |
+++ b/src/lxc/lxc_driver.c
|
|
|
43fe83 |
@@ -1362,14 +1362,14 @@ static int lxcStateInitialize(bool privileged,
|
|
|
43fe83 |
void *opaque ATTRIBUTE_UNUSED)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virCapsPtr caps = NULL;
|
|
|
43fe83 |
- char *ld;
|
|
|
43fe83 |
+ const char *ld;
|
|
|
43fe83 |
virLXCDriverConfigPtr cfg = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
/* Valgrind gets very annoyed when we clone containers, so
|
|
|
43fe83 |
* disable LXC when under valgrind
|
|
|
43fe83 |
* XXX remove this when valgrind is fixed
|
|
|
43fe83 |
*/
|
|
|
43fe83 |
- ld = getenv("LD_PRELOAD");
|
|
|
43fe83 |
+ ld = virGetEnvBlockSUID("LD_PRELOAD");
|
|
|
43fe83 |
if (ld && strstr(ld, "vgpreload")) {
|
|
|
43fe83 |
VIR_INFO("Running under valgrind, disabling driver");
|
|
|
43fe83 |
return 0;
|
|
|
43fe83 |
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
|
|
|
43fe83 |
index dcd433b..67daf79 100644
|
|
|
43fe83 |
--- a/src/remote/remote_driver.c
|
|
|
43fe83 |
+++ b/src/remote/remote_driver.c
|
|
|
43fe83 |
@@ -187,7 +187,7 @@ remoteFindDaemonPath(void)
|
|
|
43fe83 |
NULL
|
|
|
43fe83 |
};
|
|
|
43fe83 |
size_t i;
|
|
|
43fe83 |
- const char *customDaemon = getenv("LIBVIRTD_PATH");
|
|
|
43fe83 |
+ const char *customDaemon = virGetEnvBlockSUID("LIBVIRTD_PATH");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (customDaemon)
|
|
|
43fe83 |
return customDaemon;
|
|
|
43fe83 |
@@ -955,7 +955,7 @@ remoteConnectOpen(virConnectPtr conn,
|
|
|
43fe83 |
{
|
|
|
43fe83 |
struct private_data *priv;
|
|
|
43fe83 |
int ret, rflags = 0;
|
|
|
43fe83 |
- const char *autostart = getenv("LIBVIRT_AUTOSTART");
|
|
|
43fe83 |
+ const char *autostart = virGetEnvBlockSUID("LIBVIRT_AUTOSTART");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (inside_daemon && (!conn->uri || (conn->uri && !conn->uri->server)))
|
|
|
43fe83 |
return VIR_DRV_OPEN_DECLINED;
|
|
|
43fe83 |
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
|
|
|
43fe83 |
index 7cee27c..cd69794 100644
|
|
|
43fe83 |
--- a/src/rpc/virnettlscontext.c
|
|
|
43fe83 |
+++ b/src/rpc/virnettlscontext.c
|
|
|
43fe83 |
@@ -710,7 +710,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|
|
43fe83 |
bool isServer)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virNetTLSContextPtr ctxt;
|
|
|
43fe83 |
- char *gnutlsdebug;
|
|
|
43fe83 |
+ const char *gnutlsdebug;
|
|
|
43fe83 |
int err;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (virNetTLSContextInitialize() < 0)
|
|
|
43fe83 |
@@ -719,7 +719,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert,
|
|
|
43fe83 |
if (!(ctxt = virObjectLockableNew(virNetTLSContextClass)))
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
- if ((gnutlsdebug = getenv("LIBVIRT_GNUTLS_DEBUG")) != NULL) {
|
|
|
43fe83 |
+ if ((gnutlsdebug = virGetEnvAllowSUID("LIBVIRT_GNUTLS_DEBUG")) != NULL) {
|
|
|
43fe83 |
int val;
|
|
|
43fe83 |
if (virStrToLong_i(gnutlsdebug, NULL, 10, &val) < 0)
|
|
|
43fe83 |
val = 10;
|
|
|
43fe83 |
diff --git a/src/util/virauth.c b/src/util/virauth.c
|
|
|
43fe83 |
index f58797c..e66cbf5 100644
|
|
|
43fe83 |
--- a/src/util/virauth.c
|
|
|
43fe83 |
+++ b/src/util/virauth.c
|
|
|
43fe83 |
@@ -42,7 +42,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri,
|
|
|
43fe83 |
{
|
|
|
43fe83 |
int ret = -1;
|
|
|
43fe83 |
size_t i;
|
|
|
43fe83 |
- const char *authenv = getenv("LIBVIRT_AUTH_FILE");
|
|
|
43fe83 |
+ const char *authenv = virGetEnvBlockSUID("LIBVIRT_AUTH_FILE");
|
|
|
43fe83 |
char *userdir = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
*path = NULL;
|
|
|
43fe83 |
diff --git a/src/util/virfile.c b/src/util/virfile.c
|
|
|
43fe83 |
index 7af0843..92a81a5 100644
|
|
|
43fe83 |
--- a/src/util/virfile.c
|
|
|
43fe83 |
+++ b/src/util/virfile.c
|
|
|
43fe83 |
@@ -1354,6 +1354,7 @@ virFileIsLink(const char *linkpath)
|
|
|
43fe83 |
char *
|
|
|
43fe83 |
virFindFileInPath(const char *file)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
+ const char *origpath = NULL;
|
|
|
43fe83 |
char *path = NULL;
|
|
|
43fe83 |
char *pathiter;
|
|
|
43fe83 |
char *pathseg;
|
|
|
43fe83 |
@@ -1382,9 +1383,11 @@ virFindFileInPath(const char *file)
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
/* copy PATH env so we can tweak it */
|
|
|
43fe83 |
- path = getenv("PATH");
|
|
|
43fe83 |
+ origpath = virGetEnvBlockSUID("PATH");
|
|
|
43fe83 |
+ if (!origpath)
|
|
|
43fe83 |
+ origpath = "/bin:/usr/bin";
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (VIR_STRDUP_QUIET(path, path) <= 0)
|
|
|
43fe83 |
+ if (VIR_STRDUP_QUIET(path, origpath) <= 0)
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
/* for each path segment, append the file to search for and test for
|
|
|
43fe83 |
diff --git a/src/util/virlog.c b/src/util/virlog.c
|
|
|
43fe83 |
index 694da89..f250679 100644
|
|
|
43fe83 |
--- a/src/util/virlog.c
|
|
|
43fe83 |
+++ b/src/util/virlog.c
|
|
|
43fe83 |
@@ -1637,18 +1637,18 @@ virLogParseDefaultPriority(const char *priority)
|
|
|
43fe83 |
void
|
|
|
43fe83 |
virLogSetFromEnv(void)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- char *debugEnv;
|
|
|
43fe83 |
+ const char *debugEnv;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (virLogInitialize() < 0)
|
|
|
43fe83 |
return;
|
|
|
43fe83 |
|
|
|
43fe83 |
- debugEnv = getenv("LIBVIRT_DEBUG");
|
|
|
43fe83 |
+ debugEnv = virGetEnvAllowSUID("LIBVIRT_DEBUG");
|
|
|
43fe83 |
if (debugEnv && *debugEnv)
|
|
|
43fe83 |
virLogParseDefaultPriority(debugEnv);
|
|
|
43fe83 |
- debugEnv = getenv("LIBVIRT_LOG_FILTERS");
|
|
|
43fe83 |
+ debugEnv = virGetEnvAllowSUID("LIBVIRT_LOG_FILTERS");
|
|
|
43fe83 |
if (debugEnv && *debugEnv)
|
|
|
43fe83 |
virLogParseFilters(debugEnv);
|
|
|
43fe83 |
- debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
|
|
|
43fe83 |
+ debugEnv = virGetEnvAllowSUID("LIBVIRT_LOG_OUTPUTS");
|
|
|
43fe83 |
if (debugEnv && *debugEnv)
|
|
|
43fe83 |
virLogParseOutputs(debugEnv);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
diff --git a/src/util/virrandom.c b/src/util/virrandom.c
|
|
|
43fe83 |
index c233732..6101aac 100644
|
|
|
43fe83 |
--- a/src/util/virrandom.c
|
|
|
43fe83 |
+++ b/src/util/virrandom.c
|
|
|
43fe83 |
@@ -50,7 +50,7 @@ virRandomOnceInit(void)
|
|
|
43fe83 |
/* Normally we want a decent seed. But if reproducible debugging
|
|
|
43fe83 |
* of a fixed pseudo-random sequence is ever required, uncomment
|
|
|
43fe83 |
* this block to let an environment variable force the seed. */
|
|
|
43fe83 |
- const char *debug = getenv("VIR_DEBUG_RANDOM_SEED");
|
|
|
43fe83 |
+ const char *debug = virGetEnvBlockSUID("VIR_DEBUG_RANDOM_SEED");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (debug && virStrToLong_ui(debug, NULL, 0, &seed) < 0)
|
|
|
43fe83 |
return -1;
|
|
|
43fe83 |
diff --git a/src/util/virutil.c b/src/util/virutil.c
|
|
|
43fe83 |
index a41117e..2b3cbeb 100644
|
|
|
43fe83 |
--- a/src/util/virutil.c
|
|
|
43fe83 |
+++ b/src/util/virutil.c
|
|
|
43fe83 |
@@ -770,7 +770,7 @@ virGetUserDirectoryByUID(uid_t uid)
|
|
|
43fe83 |
|
|
|
43fe83 |
static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- const char *path = getenv(xdgenvname);
|
|
|
43fe83 |
+ const char *path = virGetEnvBlockSUID(xdgenvname);
|
|
|
43fe83 |
char *ret = NULL;
|
|
|
43fe83 |
char *home = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -798,7 +798,7 @@ char *virGetUserCacheDirectory(void)
|
|
|
43fe83 |
|
|
|
43fe83 |
char *virGetUserRuntimeDirectory(void)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- const char *path = getenv("XDG_RUNTIME_DIR");
|
|
|
43fe83 |
+ const char *path = virGetEnvBlockSUID("XDG_RUNTIME_DIR");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (!path || !path[0]) {
|
|
|
43fe83 |
return virGetUserCacheDirectory();
|
|
|
43fe83 |
@@ -1111,7 +1111,7 @@ virGetUserDirectoryByUID(uid_t uid ATTRIBUTE_UNUSED)
|
|
|
43fe83 |
const char *dir;
|
|
|
43fe83 |
char *ret;
|
|
|
43fe83 |
|
|
|
43fe83 |
- dir = getenv("HOME");
|
|
|
43fe83 |
+ dir = virGetEnvBlockSUID("HOME");
|
|
|
43fe83 |
|
|
|
43fe83 |
/* Only believe HOME if it is an absolute path and exists */
|
|
|
43fe83 |
if (dir) {
|
|
|
43fe83 |
@@ -1131,7 +1131,7 @@ virGetUserDirectoryByUID(uid_t uid ATTRIBUTE_UNUSED)
|
|
|
43fe83 |
|
|
|
43fe83 |
if (!dir)
|
|
|
43fe83 |
/* USERPROFILE is probably the closest equivalent to $HOME? */
|
|
|
43fe83 |
- dir = getenv("USERPROFILE");
|
|
|
43fe83 |
+ dir = virGetEnvBlockSUID("USERPROFILE");
|
|
|
43fe83 |
|
|
|
43fe83 |
if (VIR_STRDUP(ret, dir) < 0)
|
|
|
43fe83 |
return NULL;
|
|
|
43fe83 |
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
|
|
|
43fe83 |
index 10ddcf8..8652e3a 100644
|
|
|
43fe83 |
--- a/src/vbox/vbox_XPCOMCGlue.c
|
|
|
43fe83 |
+++ b/src/vbox/vbox_XPCOMCGlue.c
|
|
|
43fe83 |
@@ -201,7 +201,7 @@ VBoxCGlueInit(unsigned int *version)
|
|
|
43fe83 |
"/usr/local/lib/VirtualBox",
|
|
|
43fe83 |
"/Applications/VirtualBox.app/Contents/MacOS"
|
|
|
43fe83 |
};
|
|
|
43fe83 |
- const char *home = getenv("VBOX_APP_HOME");
|
|
|
43fe83 |
+ const char *home = virGetEnvBlockSUID("VBOX_APP_HOME");
|
|
|
43fe83 |
|
|
|
43fe83 |
/* If the user specifies the location, try only that. */
|
|
|
43fe83 |
if (home != NULL) {
|
|
|
43fe83 |
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
|
|
|
43fe83 |
index 5e5ea85..2130590 100644
|
|
|
43fe83 |
--- a/src/vbox/vbox_tmpl.c
|
|
|
43fe83 |
+++ b/src/vbox/vbox_tmpl.c
|
|
|
43fe83 |
@@ -2237,7 +2237,6 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
|
|
|
43fe83 |
vboxIID iid = VBOX_IID_INITIALIZER;
|
|
|
43fe83 |
int gotAllABoutDef = -1;
|
|
|
43fe83 |
nsresult rc;
|
|
|
43fe83 |
- char *tmp;
|
|
|
43fe83 |
|
|
|
43fe83 |
/* Flags checked by virDomainDefFormat */
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -2509,8 +2508,9 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
|
|
|
43fe83 |
}
|
|
|
43fe83 |
} else if ((vrdpPresent != 1) && (totalPresent == 0) && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
|
|
|
43fe83 |
if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
|
|
|
43fe83 |
+ const char *tmp;
|
|
|
43fe83 |
def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
|
|
43fe83 |
- tmp = getenv("DISPLAY");
|
|
|
43fe83 |
+ tmp = virGetEnvBlockSUID("DISPLAY");
|
|
|
43fe83 |
if (VIR_STRDUP(def->graphics[def->ngraphics]->data.desktop.display, tmp) < 0) {
|
|
|
43fe83 |
/* just don't go to cleanup yet as it is ok to have
|
|
|
43fe83 |
* display as NULL
|
|
|
43fe83 |
diff --git a/tools/virsh.c b/tools/virsh.c
|
|
|
43fe83 |
index d1ae183..48bf077 100644
|
|
|
43fe83 |
--- a/tools/virsh.c
|
|
|
43fe83 |
+++ b/tools/virsh.c
|
|
|
43fe83 |
@@ -232,7 +232,7 @@ virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
virFreeError(last_error);
|
|
|
43fe83 |
last_error = virSaveLastError();
|
|
|
43fe83 |
- if (getenv("VIRSH_DEBUG") != NULL)
|
|
|
43fe83 |
+ if (virGetEnvAllowSUID("VIRSH_DEBUG") != NULL)
|
|
|
43fe83 |
virDefaultErrorFunc(error);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -670,7 +670,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
|
|
43fe83 |
int fd;
|
|
|
43fe83 |
char ebuf[1024];
|
|
|
43fe83 |
|
|
|
43fe83 |
- tmpdir = getenv("TMPDIR");
|
|
|
43fe83 |
+ tmpdir = virGetEnvBlockSUID("TMPDIR");
|
|
|
43fe83 |
if (!tmpdir) tmpdir = "/tmp";
|
|
|
43fe83 |
if (virAsprintf(&ret, "%s/virshXXXXXX.xml", tmpdir) < 0) {
|
|
|
43fe83 |
vshError(ctl, "%s", _("out of memory"));
|
|
|
43fe83 |
@@ -717,9 +717,9 @@ vshEditFile(vshControl *ctl, const char *filename)
|
|
|
43fe83 |
int outfd = STDOUT_FILENO;
|
|
|
43fe83 |
int errfd = STDERR_FILENO;
|
|
|
43fe83 |
|
|
|
43fe83 |
- editor = getenv("VISUAL");
|
|
|
43fe83 |
+ editor = virGetEnvBlockSUID("VISUAL");
|
|
|
43fe83 |
if (!editor)
|
|
|
43fe83 |
- editor = getenv("EDITOR");
|
|
|
43fe83 |
+ editor = virGetEnvBlockSUID("EDITOR");
|
|
|
43fe83 |
if (!editor)
|
|
|
43fe83 |
editor = "vi"; /* could be cruel & default to ed(1) here */
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -2299,11 +2299,11 @@ vshEventLoop(void *opaque)
|
|
|
43fe83 |
static void
|
|
|
43fe83 |
vshInitDebug(vshControl *ctl)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
- char *debugEnv;
|
|
|
43fe83 |
+ const char *debugEnv;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (ctl->debug == VSH_DEBUG_DEFAULT) {
|
|
|
43fe83 |
/* log level not set from commandline, check env variable */
|
|
|
43fe83 |
- debugEnv = getenv("VIRSH_DEBUG");
|
|
|
43fe83 |
+ debugEnv = virGetEnvAllowSUID("VIRSH_DEBUG");
|
|
|
43fe83 |
if (debugEnv) {
|
|
|
43fe83 |
int debug;
|
|
|
43fe83 |
if (virStrToLong_i(debugEnv, NULL, 10, &debug) < 0 ||
|
|
|
43fe83 |
@@ -2318,7 +2318,7 @@ vshInitDebug(vshControl *ctl)
|
|
|
43fe83 |
|
|
|
43fe83 |
if (ctl->logfile == NULL) {
|
|
|
43fe83 |
/* log file not set from cmdline */
|
|
|
43fe83 |
- debugEnv = getenv("VIRSH_LOG_FILE");
|
|
|
43fe83 |
+ debugEnv = virGetEnvBlockSUID("VIRSH_LOG_FILE");
|
|
|
43fe83 |
if (debugEnv && *debugEnv) {
|
|
|
43fe83 |
ctl->logfile = vshStrdup(ctl, debugEnv);
|
|
|
43fe83 |
vshOpenLogFile(ctl);
|
|
|
43fe83 |
@@ -3164,7 +3164,7 @@ int
|
|
|
43fe83 |
main(int argc, char **argv)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
vshControl _ctl, *ctl = &_ctl;
|
|
|
43fe83 |
- char *defaultConn;
|
|
|
43fe83 |
+ const char *defaultConn;
|
|
|
43fe83 |
bool ret = true;
|
|
|
43fe83 |
|
|
|
43fe83 |
memset(ctl, 0, sizeof(vshControl));
|
|
|
43fe83 |
@@ -3202,7 +3202,7 @@ main(int argc, char **argv)
|
|
|
43fe83 |
else
|
|
|
43fe83 |
progname++;
|
|
|
43fe83 |
|
|
|
43fe83 |
- if ((defaultConn = getenv("VIRSH_DEFAULT_CONNECT_URI"))) {
|
|
|
43fe83 |
+ if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) {
|
|
|
43fe83 |
ctl->name = vshStrdup(ctl, defaultConn);
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.4.2
|
|
|
43fe83 |
|