/* clear the environment */
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"));
/* 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"));
if (!(progname = strrchr(argv[0], '/')))
return 0;
}
- unsetenv("LISTEN_PID");
- unsetenv("LISTEN_FDS");
+ g_unsetenv("LISTEN_PID");
+ g_unsetenv("LISTEN_FDS");
VIR_DEBUG("Got %u file descriptors", nfds);
*/
if (setAppHome) {
if (dir != NULL) {
- setenv("VBOX_APP_HOME", dir, 1 /* always override */);
+ g_setenv("VBOX_APP_HOME", dir, TRUE);
} else {
- unsetenv("VBOX_APP_HOME");
+ g_unsetenv("VBOX_APP_HOME");
}
}
* results. In order to detect things that just work by a blind
* chance, we need to set an virtual timezone that no libvirt
* developer resides in. */
- if (setenv("TZ", "VIR00:30", 1) < 0) {
- perror("setenv");
+ if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
+ perror("g_setenv");
return EXIT_FAILURE;
}
/* Unset or set all envvars here that are copied in lxcdBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
- setenv("PATH", "/bin", 1);
+ g_setenv("PATH", "/bin", TRUE);
DO_TEST("systemd");
DO_TEST("hostdev");
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
- setenv("PATH", "/bin", 1);
+ g_setenv("PATH", "/bin", TRUE);
/* Test a normal user redefine */
DO_TEST_OUT("redefine", 0);
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
- setenv("PATH", "/bin", 1);
+ g_setenv("PATH", "/bin", TRUE);
DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
TEST_INTERNAL);
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)
return -1;
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
if (qemuTestDriverInit(&driver) < 0)
return EXIT_FAILURE;
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
if (qemuTestDriverInit(&driver) < 0) {
VIR_FREE(fakerootdir);
/* Mocking is enabled only when this env variable is set.
* See mock code for explanation. */
- if (setenv(ENVVAR, "1", 0) < 0)
+ if (g_setenv(ENVVAR, "1", FALSE) == FALSE)
return -1;
if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
ret = 0;
cleanup:
- unsetenv(ENVVAR);
+ g_unsetenv(ENVVAR);
freePaths();
return ret;
}
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)
return -1;
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.
* If we don't do that, then localtime() may return unpredictable
* results. In order to detect things that just work by a blind
* chance, we need to set an virtual timezone that no libvirt
* developer resides in. */
- if (setenv("TZ", "VIR00:30", 1) < 0) {
- perror("setenv");
+ if (g_setenv("TZ", "VIR00:30", TRUE) == FALSE) {
+ perror("g_setenv");
return EXIT_FAILURE;
}
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
- setenv("PATH", "/bin", 1);
- setenv("USER", "test", 1);
- setenv("LOGNAME", "test", 1);
- setenv("HOME", "/home/test", 1);
- unsetenv("TMPDIR");
- unsetenv("LD_PRELOAD");
- unsetenv("LD_LIBRARY_PATH");
- unsetenv("QEMU_AUDIO_DRV");
- unsetenv("SDL_AUDIODRIVER");
+ g_setenv("PATH", "/bin", TRUE);
+ g_setenv("USER", "test", TRUE);
+ g_setenv("LOGNAME", "test", TRUE);
+ g_setenv("HOME", "/home/test", TRUE);
+ g_unsetenv("TMPDIR");
+ g_unsetenv("LD_PRELOAD");
+ g_unsetenv("LD_LIBRARY_PATH");
+ g_unsetenv("QEMU_AUDIO_DRV");
+ g_unsetenv("SDL_AUDIODRIVER");
DO_TEST("minimal", NONE);
DO_TEST("minimal-sandbox",
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
/* Required for tpm-emulator tests
*/
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
- setenv("PATH", "/bin", 1);
+ g_setenv("PATH", "/bin", TRUE);
DO_TEST("minimal", NONE);
DO_TEST_CAPS_LATEST("genid");
errno = EINVAL;
return -1;
}
- return setenv("FAKE_SELINUX_CONTEXT", context, 1);
+ return g_setenv("FAKE_SELINUX_CONTEXT", context, TRUE);
}
int setcon(const char *context)
return -1;
}
- return setenv("FAKE_SELINUX_DISABLED", "1", 1);
+ return g_setenv("FAKE_SELINUX_DISABLED", "1", TRUE);
}
int security_getenforce(void)
/* Some test are fragile about environ settings. If that's
* the case, don't poison it. */
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())
fprintf(stderr, " ");
fprintf(stderr, "!");
}
- unsetenv("VIR_TEST_MOCK_TESTNAME");
+ g_unsetenv("VIR_TEST_MOCK_TESTNAME");
return ret;
}
}
if (new_path &&
- setenv("PATH", new_path, 1) < 0)
+ g_setenv("PATH", new_path, TRUE) < 0)
goto cleanup;
ret = 0;
if (STRPREFIX(progname, "lt-"))
progname += 3;
- setenv("VIR_TEST_MOCK_PROGNAME", progname, 1);
+ g_setenv("VIR_TEST_MOCK_PROGNAME", progname, TRUE);
virFileActivateDirOverrideForProg(argv[0]);
#ifdef __APPLE__
# define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
# define FORCE_FLAT_NAMESPACE \
- setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
+ g_setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", TRUE);
# define MOCK_EXT ".dylib"
#else
# define PRELOAD_VAR "LD_PRELOAD"
} else { \
newenv = g_strdup_printf("%s:%s", lib, preload); \
} \
- setenv(PRELOAD_VAR, newenv, 1); \
+ g_setenv(PRELOAD_VAR, newenv, TRUE); \
FORCE_FLAT_NAMESPACE \
execv(argv[0], argv); \
} \
cpu = cpuPower8;
}
- unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
+ g_unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
if (cpu) {
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 (cpu)
virBuffer buf = VIR_BUFFER_INITIALIZER;
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);
result = 0;
cleanup:
- unsetenv("VIR_CGROUP_MOCK_FILENAME");
+ g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
VIR_FREE(parsed);
virCgroupFree(&group);
virBufferFreeAndReset(&buf);
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
if (mode)
- setenv("VIR_CGROUP_MOCK_MODE", mode, 1);
+ g_setenv("VIR_CGROUP_MOCK_MODE", mode, TRUE);
if (filename)
- setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1);
+ g_setenv("VIR_CGROUP_MOCK_FILENAME", filename, TRUE);
return fakerootdir;
}
virFileDeleteTree(fakerootdir);
VIR_FREE(fakerootdir);
- unsetenv("LIBVIRT_FAKE_ROOT_DIR");
- unsetenv("VIR_CGROUP_MOCK_MODE");
- unsetenv("VIR_CGROUP_MOCK_FILENAME");
+ g_unsetenv("LIBVIRT_FAKE_ROOT_DIR");
+ g_unsetenv("VIR_CGROUP_MOCK_MODE");
+ g_unsetenv("VIR_CGROUP_MOCK_FILENAME");
}
static int
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");
goto cleanup;
}
ret = 0;
cleanup:
VIR_FREE(mtabFile);
- unsetenv("LIBVIRT_MTAB");
+ g_unsetenv("LIBVIRT_MTAB");
return ret;
#endif
}
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
# define DO_TEST(fnc) \
do { \
{
int ret = 0;
- setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+ g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
testTLSInit(KEYFILE);
{
int ret = 0;
- setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+ g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", TRUE);
testTLSInit(KEYFILE);
abort();
}
- setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+ g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
# define DO_TEST(fnc) \
do { \
if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0)
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)
ret = -1;
};
int rv;
- setenv("FAIL_NO_SERVICE", "1", 1);
+ g_setenv("FAIL_NO_SERVICE", "1", TRUE);
if ((rv = virSystemdCreateMachine("demo",
"qemu",
false,
0, NULL,
NULL, 0)) == 0) {
- unsetenv("FAIL_NO_SERVICE");
+ g_unsetenv("FAIL_NO_SERVICE");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
}
- unsetenv("FAIL_NO_SERVICE");
+ g_unsetenv("FAIL_NO_SERVICE");
if (rv != -2) {
fprintf(stderr, "%s", "Unexpected create machine error\n");
};
int rv;
- setenv("FAIL_NOT_REGISTERED", "1", 1);
+ g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
if ((rv = virSystemdCreateMachine("demo",
"qemu",
false,
0, NULL,
NULL, 0)) == 0) {
- unsetenv("FAIL_NOT_REGISTERED");
+ g_unsetenv("FAIL_NOT_REGISTERED");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
}
- unsetenv("FAIL_NOT_REGISTERED");
+ g_unsetenv("FAIL_NOT_REGISTERED");
if (rv != -2) {
fprintf(stderr, "%s", "Unexpected create machine error\n");
};
int rv;
- setenv("FAIL_BAD_SERVICE", "1", 1);
+ g_setenv("FAIL_BAD_SERVICE", "1", TRUE);
if ((rv = virSystemdCreateMachine("demo",
"qemu",
false,
0, NULL,
NULL, 0)) == 0) {
- unsetenv("FAIL_BAD_SERVICE");
+ g_unsetenv("FAIL_BAD_SERVICE");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
}
- unsetenv("FAIL_BAD_SERVICE");
+ g_unsetenv("FAIL_BAD_SERVICE");
if (rv != -1) {
fprintf(stderr, "%s", "Unexpected create machine error\n");
const struct testPMSupportData *data = opaque;
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) {
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
return -1;
fprintf(stderr, "Unexpected result for answer '%s'\n", results[i]);
goto error;
}
- unsetenv("RESULT_SUPPORT");
+ g_unsetenv("RESULT_SUPPORT");
}
return 0;
error:
- unsetenv("RESULT_SUPPORT");
+ g_unsetenv("RESULT_SUPPORT");
return -1;
}
bool result;
const struct testPMSupportData *data = opaque;
- setenv("FAIL_NO_SERVICE", "1", 1);
+ g_setenv("FAIL_NO_SERVICE", "1", TRUE);
if ((rv = data->tested(&result)) == 0) {
- unsetenv("FAIL_NO_SERVICE");
+ g_unsetenv("FAIL_NO_SERVICE");
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
return -1;
}
- unsetenv("FAIL_NO_SERVICE");
+ g_unsetenv("FAIL_NO_SERVICE");
if (rv != -2) {
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
bool result;
const struct testPMSupportData *data = opaque;
- setenv("FAIL_NOT_REGISTERED", "1", 1);
+ g_setenv("FAIL_NOT_REGISTERED", "1", TRUE);
if ((rv = data->tested(&result)) == 0) {
- unsetenv("FAIL_NOT_REGISTERED");
+ g_unsetenv("FAIL_NOT_REGISTERED");
fprintf(stderr, "%s", "Unexpected canSuspend success\n");
return -1;
}
- unsetenv("FAIL_NOT_REGISTERED");
+ g_unsetenv("FAIL_NOT_REGISTERED");
if (rv != -2) {
fprintf(stderr, "%s", "Unexpected canSuspend error\n");
g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
- setenv("LISTEN_FDS", nfdstr, 1);
- setenv("LISTEN_PID", pidstr, 1);
+ g_setenv("LISTEN_FDS", nfdstr, TRUE);
+ g_setenv("LISTEN_PID", pidstr, TRUE);
if (useNames)
- setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
+ g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), TRUE);
else
- unsetenv("LISTEN_FDNAMES");
+ g_unsetenv("LISTEN_FDNAMES");
map[0].name = "demo-unix.socket";
map[0].family = AF_UNIX;
{
virSystemdActivationPtr act;
- unsetenv("LISTEN_FDS");
+ g_unsetenv("LISTEN_FDS");
if (virSystemdGetActivation(NULL, 0, &act) < 0)
return -1;
const testTimeLocalOffsetData *data = args;
long actual;
- if (setenv("TZ", data->zone, 1) < 0) {
- perror("setenv");
+ if (g_setenv("TZ", data->zone, TRUE) == FALSE) {
+ perror("g_setenv");
return -1;
}
tzset();
}
clearenv();
- setenv("PATH", "/bin:/usr/bin", 1);
- setenv("SHELL", shcmd, 1);
- setenv("USER", name, 1);
- setenv("LOGNAME", name, 1);
- setenv("HOME", homedir, 1);
+ g_setenv("PATH", "/bin:/usr/bin", TRUE);
+ g_setenv("SHELL", shcmd, TRUE);
+ g_setenv("USER", name, TRUE);
+ g_setenv("LOGNAME", name, TRUE);
+ g_setenv("HOME", homedir, TRUE);
if (term)
- setenv("TERM", term, 1);
+ g_setenv("TERM", term, TRUE);
if (execv(shcmd, (char *const*) shargv) < 0) {
virReportSystemError(errno, _("Unable to exec shell %s"),