mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
src: switch to use g_setenv/g_unsetenv
Eliminate direct use of normal setenv/unsetenv calls in favour of GLib's wrapper. This eliminates two gnulib modules Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
4eed65abec
commit
2c33532423
@ -1447,11 +1447,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* clear the environment */
|
/* clear the environment */
|
||||||
environ = NULL;
|
environ = NULL;
|
||||||
if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
|
if (g_setenv("PATH", "/sbin:/usr/sbin", TRUE) == FALSE)
|
||||||
vah_error(ctl, 1, _("could not set PATH"));
|
vah_error(ctl, 1, _("could not set PATH"));
|
||||||
|
|
||||||
/* ensure the traditional IFS setting */
|
/* ensure the traditional IFS setting */
|
||||||
if (setenv("IFS", " \t\n", 1) != 0)
|
if (g_setenv("IFS", " \t\n", TRUE) == FALSE)
|
||||||
vah_error(ctl, 1, _("could not set IFS"));
|
vah_error(ctl, 1, _("could not set IFS"));
|
||||||
|
|
||||||
if (!(progname = strrchr(argv[0], '/')))
|
if (!(progname = strrchr(argv[0], '/')))
|
||||||
|
@ -854,8 +854,8 @@ virSystemdGetListenFDs(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsetenv("LISTEN_PID");
|
g_unsetenv("LISTEN_PID");
|
||||||
unsetenv("LISTEN_FDS");
|
g_unsetenv("LISTEN_FDS");
|
||||||
|
|
||||||
VIR_DEBUG("Got %u file descriptors", nfds);
|
VIR_DEBUG("Got %u file descriptors", nfds);
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
|
|||||||
*/
|
*/
|
||||||
if (setAppHome) {
|
if (setAppHome) {
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
setenv("VBOX_APP_HOME", dir, 1 /* always override */);
|
g_setenv("VBOX_APP_HOME", dir, TRUE);
|
||||||
} else {
|
} else {
|
||||||
unsetenv("VBOX_APP_HOME");
|
g_unsetenv("VBOX_APP_HOME");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +160,8 @@ mymain(void)
|
|||||||
* results. In order to detect things that just work by a blind
|
* results. In order to detect things that just work by a blind
|
||||||
* chance, we need to set an virtual timezone that no libvirt
|
* chance, we need to set an virtual timezone that no libvirt
|
||||||
* developer resides in. */
|
* developer resides in. */
|
||||||
if (setenv("TZ", "VIR00:30", 1) < 0) {
|
if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
|
||||||
perror("setenv");
|
perror("g_setenv");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ mymain(void)
|
|||||||
/* Unset or set all envvars here that are copied in lxcdBuildCommandLine
|
/* Unset or set all envvars here that are copied in lxcdBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
setenv("PATH", "/bin", 1);
|
g_setenv("PATH", "/bin", TRUE);
|
||||||
|
|
||||||
DO_TEST("systemd");
|
DO_TEST("systemd");
|
||||||
DO_TEST("hostdev");
|
DO_TEST("hostdev");
|
||||||
|
@ -175,7 +175,7 @@ mymain(void)
|
|||||||
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
setenv("PATH", "/bin", 1);
|
g_setenv("PATH", "/bin", TRUE);
|
||||||
|
|
||||||
/* Test a normal user redefine */
|
/* Test a normal user redefine */
|
||||||
DO_TEST_OUT("redefine", 0);
|
DO_TEST_OUT("redefine", 0);
|
||||||
|
@ -160,7 +160,7 @@ mymain(void)
|
|||||||
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
setenv("PATH", "/bin", 1);
|
g_setenv("PATH", "/bin", TRUE);
|
||||||
|
|
||||||
DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
|
DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
|
||||||
TEST_INTERNAL);
|
TEST_INTERNAL);
|
||||||
|
@ -70,7 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
|
fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
|
||||||
|
|
||||||
setenv("XDG_CONFIG_HOME", fakehome, 1);
|
g_setenv("XDG_CONFIG_HOME", fakehome, TRUE);
|
||||||
|
|
||||||
if (qemuFirmwareFetchConfigs(&fwList, false) < 0)
|
if (qemuFirmwareFetchConfigs(&fwList, false) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -603,7 +603,7 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
if (qemuTestDriverInit(&driver) < 0)
|
if (qemuTestDriverInit(&driver) < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -67,7 +67,7 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
if (qemuTestDriverInit(&driver) < 0) {
|
if (qemuTestDriverInit(&driver) < 0) {
|
||||||
VIR_FREE(fakerootdir);
|
VIR_FREE(fakerootdir);
|
||||||
|
@ -111,7 +111,7 @@ testDomain(const void *opaque)
|
|||||||
|
|
||||||
/* Mocking is enabled only when this env variable is set.
|
/* Mocking is enabled only when this env variable is set.
|
||||||
* See mock code for explanation. */
|
* See mock code for explanation. */
|
||||||
if (setenv(ENVVAR, "1", 0) < 0)
|
if (g_setenv(ENVVAR, "1", FALSE) == FALSE)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
|
if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
|
||||||
@ -124,7 +124,7 @@ testDomain(const void *opaque)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
unsetenv(ENVVAR);
|
g_unsetenv(ENVVAR);
|
||||||
freePaths();
|
freePaths();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
fakehome = g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config");
|
fakehome = g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config");
|
||||||
|
|
||||||
setenv("XDG_CONFIG_HOME", fakehome, 1);
|
g_setenv("XDG_CONFIG_HOME", fakehome, TRUE);
|
||||||
|
|
||||||
if (qemuVhostUserFetchConfigs(&vuList, false) < 0)
|
if (qemuVhostUserFetchConfigs(&vuList, false) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -618,15 +618,15 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
/* Set the timezone because we are mocking the time() function.
|
/* Set the timezone because we are mocking the time() function.
|
||||||
* If we don't do that, then localtime() may return unpredictable
|
* If we don't do that, then localtime() may return unpredictable
|
||||||
* results. In order to detect things that just work by a blind
|
* results. In order to detect things that just work by a blind
|
||||||
* chance, we need to set an virtual timezone that no libvirt
|
* chance, we need to set an virtual timezone that no libvirt
|
||||||
* developer resides in. */
|
* developer resides in. */
|
||||||
if (setenv("TZ", "VIR00:30", 1) < 0) {
|
if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
|
||||||
perror("setenv");
|
perror("g_setenv");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,15 +797,15 @@ mymain(void)
|
|||||||
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
setenv("PATH", "/bin", 1);
|
g_setenv("PATH", "/bin", TRUE);
|
||||||
setenv("USER", "test", 1);
|
g_setenv("USER", "test", TRUE);
|
||||||
setenv("LOGNAME", "test", 1);
|
g_setenv("LOGNAME", "test", TRUE);
|
||||||
setenv("HOME", "/home/test", 1);
|
g_setenv("HOME", "/home/test", TRUE);
|
||||||
unsetenv("TMPDIR");
|
g_unsetenv("TMPDIR");
|
||||||
unsetenv("LD_PRELOAD");
|
g_unsetenv("LD_PRELOAD");
|
||||||
unsetenv("LD_LIBRARY_PATH");
|
g_unsetenv("LD_LIBRARY_PATH");
|
||||||
unsetenv("QEMU_AUDIO_DRV");
|
g_unsetenv("QEMU_AUDIO_DRV");
|
||||||
unsetenv("SDL_AUDIODRIVER");
|
g_unsetenv("SDL_AUDIODRIVER");
|
||||||
|
|
||||||
DO_TEST("minimal", NONE);
|
DO_TEST("minimal", NONE);
|
||||||
DO_TEST("minimal-sandbox",
|
DO_TEST("minimal-sandbox",
|
||||||
|
@ -147,7 +147,7 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
/* Required for tpm-emulator tests
|
/* Required for tpm-emulator tests
|
||||||
*/
|
*/
|
||||||
@ -234,7 +234,7 @@ mymain(void)
|
|||||||
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
|
||||||
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
|
||||||
* values for these envvars */
|
* values for these envvars */
|
||||||
setenv("PATH", "/bin", 1);
|
g_setenv("PATH", "/bin", TRUE);
|
||||||
|
|
||||||
DO_TEST("minimal", NONE);
|
DO_TEST("minimal", NONE);
|
||||||
DO_TEST_CAPS_LATEST("genid");
|
DO_TEST_CAPS_LATEST("genid");
|
||||||
|
@ -145,7 +145,7 @@ int setcon_raw(const char *context)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return setenv("FAKE_SELINUX_CONTEXT", context, 1);
|
return g_setenv("FAKE_SELINUX_CONTEXT", context, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int setcon(const char *context)
|
int setcon(const char *context)
|
||||||
@ -224,7 +224,7 @@ int security_disable(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return setenv("FAKE_SELINUX_DISABLED", "1", 1);
|
return g_setenv("FAKE_SELINUX_DISABLED", "1", TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int security_getenforce(void)
|
int security_getenforce(void)
|
||||||
|
@ -127,7 +127,7 @@ virTestRun(const char *title,
|
|||||||
/* Some test are fragile about environ settings. If that's
|
/* Some test are fragile about environ settings. If that's
|
||||||
* the case, don't poison it. */
|
* the case, don't poison it. */
|
||||||
if (getenv("VIR_TEST_MOCK_PROGNAME"))
|
if (getenv("VIR_TEST_MOCK_PROGNAME"))
|
||||||
setenv("VIR_TEST_MOCK_TESTNAME", title, 1);
|
g_setenv("VIR_TEST_MOCK_TESTNAME", title, TRUE);
|
||||||
|
|
||||||
if (testCounter == 0 && !virTestGetVerbose())
|
if (testCounter == 0 && !virTestGetVerbose())
|
||||||
fprintf(stderr, " ");
|
fprintf(stderr, " ");
|
||||||
@ -176,7 +176,7 @@ virTestRun(const char *title,
|
|||||||
fprintf(stderr, "!");
|
fprintf(stderr, "!");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsetenv("VIR_TEST_MOCK_TESTNAME");
|
g_unsetenv("VIR_TEST_MOCK_TESTNAME");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +836,7 @@ virTestSetEnvPath(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (new_path &&
|
if (new_path &&
|
||||||
setenv("PATH", new_path, 1) < 0)
|
g_setenv("PATH", new_path, TRUE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -870,7 +870,7 @@ int virTestMain(int argc,
|
|||||||
if (STRPREFIX(progname, "lt-"))
|
if (STRPREFIX(progname, "lt-"))
|
||||||
progname += 3;
|
progname += 3;
|
||||||
|
|
||||||
setenv("VIR_TEST_MOCK_PROGNAME", progname, 1);
|
g_setenv("VIR_TEST_MOCK_PROGNAME", progname, TRUE);
|
||||||
|
|
||||||
virFileActivateDirOverrideForProg(argv[0]);
|
virFileActivateDirOverrideForProg(argv[0]);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ int virTestMain(int argc,
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
|
# define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
|
||||||
# define FORCE_FLAT_NAMESPACE \
|
# define FORCE_FLAT_NAMESPACE \
|
||||||
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
|
g_setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", TRUE);
|
||||||
# define MOCK_EXT ".dylib"
|
# define MOCK_EXT ".dylib"
|
||||||
#else
|
#else
|
||||||
# define PRELOAD_VAR "LD_PRELOAD"
|
# define PRELOAD_VAR "LD_PRELOAD"
|
||||||
@ -143,7 +143,7 @@ int virTestMain(int argc,
|
|||||||
} else { \
|
} else { \
|
||||||
newenv = g_strdup_printf("%s:%s", lib, preload); \
|
newenv = g_strdup_printf("%s:%s", lib, preload); \
|
||||||
} \
|
} \
|
||||||
setenv(PRELOAD_VAR, newenv, 1); \
|
g_setenv(PRELOAD_VAR, newenv, TRUE); \
|
||||||
FORCE_FLAT_NAMESPACE \
|
FORCE_FLAT_NAMESPACE \
|
||||||
execv(argv[0], argv); \
|
execv(argv[0], argv); \
|
||||||
} \
|
} \
|
||||||
|
@ -260,10 +260,10 @@ qemuTestSetHostCPU(virQEMUDriverPtr driver,
|
|||||||
cpu = cpuPower8;
|
cpu = cpuPower8;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
|
g_unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
|
||||||
if (cpu) {
|
if (cpu) {
|
||||||
if (cpu->model)
|
if (cpu->model)
|
||||||
setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
|
g_setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, TRUE);
|
||||||
}
|
}
|
||||||
if (driver) {
|
if (driver) {
|
||||||
if (cpu)
|
if (cpu)
|
||||||
|
@ -187,7 +187,7 @@ testCgroupDetectMounts(const void *args)
|
|||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
|
g_setenv("VIR_CGROUP_MOCK_FILENAME", data->file, TRUE);
|
||||||
|
|
||||||
parsed = g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir, data->file);
|
parsed = g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir, data->file);
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ testCgroupDetectMounts(const void *args)
|
|||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
||||||
VIR_FREE(parsed);
|
VIR_FREE(parsed);
|
||||||
virCgroupFree(&group);
|
virCgroupFree(&group);
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
@ -994,13 +994,13 @@ initFakeFS(const char *mode,
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
if (mode)
|
if (mode)
|
||||||
setenv("VIR_CGROUP_MOCK_MODE", mode, 1);
|
g_setenv("VIR_CGROUP_MOCK_MODE", mode, TRUE);
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1);
|
g_setenv("VIR_CGROUP_MOCK_FILENAME", filename, TRUE);
|
||||||
|
|
||||||
return fakerootdir;
|
return fakerootdir;
|
||||||
}
|
}
|
||||||
@ -1012,9 +1012,9 @@ cleanupFakeFS(char *fakerootdir)
|
|||||||
virFileDeleteTree(fakerootdir);
|
virFileDeleteTree(fakerootdir);
|
||||||
|
|
||||||
VIR_FREE(fakerootdir);
|
VIR_FREE(fakerootdir);
|
||||||
unsetenv("LIBVIRT_FAKE_ROOT_DIR");
|
g_unsetenv("LIBVIRT_FAKE_ROOT_DIR");
|
||||||
unsetenv("VIR_CGROUP_MOCK_MODE");
|
g_unsetenv("VIR_CGROUP_MOCK_MODE");
|
||||||
unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -327,7 +327,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
mtabFile = g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabFile);
|
mtabFile = g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabFile);
|
||||||
|
|
||||||
if (setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) {
|
if (g_setenv("LIBVIRT_MTAB", mtabFile, TRUE) == FALSE) {
|
||||||
fprintf(stderr, "Unable to set env variable\n");
|
fprintf(stderr, "Unable to set env variable\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(mtabFile);
|
VIR_FREE(mtabFile);
|
||||||
unsetenv("LIBVIRT_MTAB");
|
g_unsetenv("LIBVIRT_MTAB");
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
# define DO_TEST(fnc) \
|
# define DO_TEST(fnc) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -111,7 +111,7 @@ mymain(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
|
||||||
|
|
||||||
testTLSInit(KEYFILE);
|
testTLSInit(KEYFILE);
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ mymain(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
|
g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
|
||||||
|
|
||||||
testTLSInit(KEYFILE);
|
testTLSInit(KEYFILE);
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ mymain(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||||
|
|
||||||
# define DO_TEST(fnc) \
|
# define DO_TEST(fnc) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -171,7 +171,7 @@ mymain(void)
|
|||||||
if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0)
|
if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1);
|
g_setenv("LIBVIRT_TEST_IPV4ONLY", "really", TRUE);
|
||||||
|
|
||||||
if (virTestRun("Test IPv4-only alloc all", testAllocAll, NULL) < 0)
|
if (virTestRun("Test IPv4-only alloc all", testAllocAll, NULL) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -236,7 +236,7 @@ static int testCreateNoSystemd(const void *opaque G_GNUC_UNUSED)
|
|||||||
};
|
};
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
setenv("FAIL_NO_SERVICE", "1", 1);
|
g_setenv("FAIL_NO_SERVICE", "1", TRUE);
|
||||||
|
|
||||||
if ((rv = virSystemdCreateMachine("demo",
|
if ((rv = virSystemdCreateMachine("demo",
|
||||||
"qemu",
|
"qemu",
|
||||||
@ -246,11 +246,11 @@ static int testCreateNoSystemd(const void *opaque G_GNUC_UNUSED)
|
|||||||
false,
|
false,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
NULL, 0)) == 0) {
|
NULL, 0)) == 0) {
|
||||||
unsetenv("FAIL_NO_SERVICE");
|
g_unsetenv("FAIL_NO_SERVICE");
|
||||||
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsetenv("FAIL_NO_SERVICE");
|
g_unsetenv("FAIL_NO_SERVICE");
|
||||||
|
|
||||||
if (rv != -2) {
|
if (rv != -2) {
|
||||||
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
||||||
@ -270,7 +270,7 @@ static int testCreateSystemdNotRunning(const void *opaque G_GNUC_UNUSED)
|
|||||||
};
|
};
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
setenv("FAIL_NOT_REGISTERED", "1", 1);
|
g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
|
||||||
|
|
||||||
if ((rv = virSystemdCreateMachine("demo",
|
if ((rv = virSystemdCreateMachine("demo",
|
||||||
"qemu",
|
"qemu",
|
||||||
@ -280,11 +280,11 @@ static int testCreateSystemdNotRunning(const void *opaque G_GNUC_UNUSED)
|
|||||||
false,
|
false,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
NULL, 0)) == 0) {
|
NULL, 0)) == 0) {
|
||||||
unsetenv("FAIL_NOT_REGISTERED");
|
g_unsetenv("FAIL_NOT_REGISTERED");
|
||||||
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsetenv("FAIL_NOT_REGISTERED");
|
g_unsetenv("FAIL_NOT_REGISTERED");
|
||||||
|
|
||||||
if (rv != -2) {
|
if (rv != -2) {
|
||||||
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
||||||
@ -304,7 +304,7 @@ static int testCreateBadSystemd(const void *opaque G_GNUC_UNUSED)
|
|||||||
};
|
};
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
setenv("FAIL_BAD_SERVICE", "1", 1);
|
g_setenv("FAIL_BAD_SERVICE", "1", TRUE);
|
||||||
|
|
||||||
if ((rv = virSystemdCreateMachine("demo",
|
if ((rv = virSystemdCreateMachine("demo",
|
||||||
"qemu",
|
"qemu",
|
||||||
@ -314,11 +314,11 @@ static int testCreateBadSystemd(const void *opaque G_GNUC_UNUSED)
|
|||||||
false,
|
false,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
NULL, 0)) == 0) {
|
NULL, 0)) == 0) {
|
||||||
unsetenv("FAIL_BAD_SERVICE");
|
g_unsetenv("FAIL_BAD_SERVICE");
|
||||||
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
fprintf(stderr, "%s", "Unexpected create machine success\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsetenv("FAIL_BAD_SERVICE");
|
g_unsetenv("FAIL_BAD_SERVICE");
|
||||||
|
|
||||||
if (rv != -1) {
|
if (rv != -1) {
|
||||||
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
fprintf(stderr, "%s", "Unexpected create machine error\n");
|
||||||
@ -445,7 +445,7 @@ static int testPMSupportHelper(const void *opaque)
|
|||||||
const struct testPMSupportData *data = opaque;
|
const struct testPMSupportData *data = opaque;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
setenv("RESULT_SUPPORT", results[i], 1);
|
g_setenv("RESULT_SUPPORT", results[i], TRUE);
|
||||||
if ((rv = data->tested(&result)) < 0) {
|
if ((rv = data->tested(&result)) < 0) {
|
||||||
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -455,12 +455,12 @@ static int testPMSupportHelper(const void *opaque)
|
|||||||
fprintf(stderr, "Unexpected result for answer '%s'\n", results[i]);
|
fprintf(stderr, "Unexpected result for answer '%s'\n", results[i]);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
unsetenv("RESULT_SUPPORT");
|
g_unsetenv("RESULT_SUPPORT");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
unsetenv("RESULT_SUPPORT");
|
g_unsetenv("RESULT_SUPPORT");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,14 +470,14 @@ static int testPMSupportHelperNoSystemd(const void *opaque)
|
|||||||
bool result;
|
bool result;
|
||||||
const struct testPMSupportData *data = opaque;
|
const struct testPMSupportData *data = opaque;
|
||||||
|
|
||||||
setenv("FAIL_NO_SERVICE", "1", 1);
|
g_setenv("FAIL_NO_SERVICE", "1", TRUE);
|
||||||
|
|
||||||
if ((rv = data->tested(&result)) == 0) {
|
if ((rv = data->tested(&result)) == 0) {
|
||||||
unsetenv("FAIL_NO_SERVICE");
|
g_unsetenv("FAIL_NO_SERVICE");
|
||||||
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
|
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsetenv("FAIL_NO_SERVICE");
|
g_unsetenv("FAIL_NO_SERVICE");
|
||||||
|
|
||||||
if (rv != -2) {
|
if (rv != -2) {
|
||||||
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
||||||
@ -493,14 +493,14 @@ static int testPMSupportSystemdNotRunning(const void *opaque)
|
|||||||
bool result;
|
bool result;
|
||||||
const struct testPMSupportData *data = opaque;
|
const struct testPMSupportData *data = opaque;
|
||||||
|
|
||||||
setenv("FAIL_NOT_REGISTERED", "1", 1);
|
g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
|
||||||
|
|
||||||
if ((rv = data->tested(&result)) == 0) {
|
if ((rv = data->tested(&result)) == 0) {
|
||||||
unsetenv("FAIL_NOT_REGISTERED");
|
g_unsetenv("FAIL_NOT_REGISTERED");
|
||||||
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
|
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsetenv("FAIL_NOT_REGISTERED");
|
g_unsetenv("FAIL_NOT_REGISTERED");
|
||||||
|
|
||||||
if (rv != -2) {
|
if (rv != -2) {
|
||||||
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
|
||||||
@ -567,13 +567,13 @@ testActivation(bool useNames)
|
|||||||
g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
|
g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
|
||||||
g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
|
g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
|
||||||
|
|
||||||
setenv("LISTEN_FDS", nfdstr, 1);
|
g_setenv("LISTEN_FDS", nfdstr, TRUE);
|
||||||
setenv("LISTEN_PID", pidstr, 1);
|
g_setenv("LISTEN_PID", pidstr, TRUE);
|
||||||
|
|
||||||
if (useNames)
|
if (useNames)
|
||||||
setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
|
g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), TRUE);
|
||||||
else
|
else
|
||||||
unsetenv("LISTEN_FDNAMES");
|
g_unsetenv("LISTEN_FDNAMES");
|
||||||
|
|
||||||
map[0].name = "demo-unix.socket";
|
map[0].name = "demo-unix.socket";
|
||||||
map[0].family = AF_UNIX;
|
map[0].family = AF_UNIX;
|
||||||
@ -640,7 +640,7 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
virSystemdActivationPtr act;
|
virSystemdActivationPtr act;
|
||||||
|
|
||||||
unsetenv("LISTEN_FDS");
|
g_unsetenv("LISTEN_FDS");
|
||||||
|
|
||||||
if (virSystemdGetActivation(NULL, 0, &act) < 0)
|
if (virSystemdGetActivation(NULL, 0, &act) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -79,8 +79,8 @@ testTimeLocalOffset(const void *args)
|
|||||||
const testTimeLocalOffsetData *data = args;
|
const testTimeLocalOffsetData *data = args;
|
||||||
long actual;
|
long actual;
|
||||||
|
|
||||||
if (setenv("TZ", data->zone, 1) < 0) {
|
if (g_setenv("TZ", data->zone, TRUE) == FALSE) {
|
||||||
perror("setenv");
|
perror("g_setenv");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tzset();
|
tzset();
|
||||||
|
@ -382,13 +382,13 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearenv();
|
clearenv();
|
||||||
setenv("PATH", "/bin:/usr/bin", 1);
|
g_setenv("PATH", "/bin:/usr/bin", TRUE);
|
||||||
setenv("SHELL", shcmd, 1);
|
g_setenv("SHELL", shcmd, TRUE);
|
||||||
setenv("USER", name, 1);
|
g_setenv("USER", name, TRUE);
|
||||||
setenv("LOGNAME", name, 1);
|
g_setenv("LOGNAME", name, TRUE);
|
||||||
setenv("HOME", homedir, 1);
|
g_setenv("HOME", homedir, TRUE);
|
||||||
if (term)
|
if (term)
|
||||||
setenv("TERM", term, 1);
|
g_setenv("TERM", term, TRUE);
|
||||||
|
|
||||||
if (execv(shcmd, (char *const*) shargv) < 0) {
|
if (execv(shcmd, (char *const*) shargv) < 0) {
|
||||||
virReportSystemError(errno, _("Unable to exec shell %s"),
|
virReportSystemError(errno, _("Unable to exec shell %s"),
|
||||||
|
Loading…
Reference in New Issue
Block a user