[libvirt] [PATCH 1/4] replace use of gnulib setenv by g_setenv

Pavel Hrdina phrdina at redhat.com
Thu Nov 14 10:42:27 UTC 2019


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/security/virt-aa-helper.c           |  4 ++--
 src/vbox/vbox_XPCOMCGlue.c              |  2 +-
 tests/libxlxml2domconfigtest.c          |  4 ++--
 tests/lxcxml2xmltest.c                  |  2 +-
 tests/qemudomaincheckpointxml2xmltest.c |  2 +-
 tests/qemudomainsnapshotxml2xmltest.c   |  2 +-
 tests/qemufirmwaretest.c                |  2 +-
 tests/qemuhotplugtest.c                 |  2 +-
 tests/qemumemlocktest.c                 |  2 +-
 tests/qemusecuritytest.c                |  2 +-
 tests/qemuvhostusertest.c               |  2 +-
 tests/qemuxml2argvtest.c                | 14 +++++++-------
 tests/qemuxml2xmltest.c                 |  4 ++--
 tests/securityselinuxhelper.c           |  4 ++--
 tests/testutils.c                       |  6 +++---
 tests/testutils.h                       |  4 ++--
 tests/testutilsqemu.c                   |  2 +-
 tests/vircgrouptest.c                   |  8 ++++----
 tests/virfiletest.c                     |  2 +-
 tests/virhostdevtest.c                  |  2 +-
 tests/virnettlscontexttest.c            |  2 +-
 tests/virnettlssessiontest.c            |  2 +-
 tests/virpcitest.c                      |  2 +-
 tests/virportallocatortest.c            |  2 +-
 tests/virsystemdtest.c                  | 18 +++++++++---------
 tests/virtimetest.c                     |  4 ++--
 tools/virt-login-shell-helper.c         | 12 ++++++------
 27 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 5ac9a9eeb8..12edc9c73f 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1408,11 +1408,11 @@ main(int argc, char **argv)
 
     /* clear the environment */
     environ = NULL;
-    if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
+    if (g_setenv("PATH", "/sbin:/usr/sbin", 1) != 0)
         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", 1) != 0)
         vah_error(ctl, 1, _("could not set IFS"));
 
     if (!(progname = strrchr(argv[0], '/')))
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index f48a78a923..9cd39df0d8 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -104,7 +104,7 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
      */
     if (setAppHome) {
         if (dir != NULL) {
-            setenv("VBOX_APP_HOME", dir, 1 /* always override */);
+            g_setenv("VBOX_APP_HOME", dir, 1 /* always override */);
         } else {
             unsetenv("VBOX_APP_HOME");
         }
diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index 5bda6db360..43584477a9 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -172,8 +172,8 @@ mymain(void)
      * 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", 1) < 0) {
+        perror("g_setenv");
         return EXIT_FAILURE;
     }
 
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 6a720503a9..f79d683c8d 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -79,7 +79,7 @@ mymain(void)
     /* 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", 1);
 
     DO_TEST("systemd");
     DO_TEST("hostdev");
diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomaincheckpointxml2xmltest.c
index 49e8cddeb3..c2e5db7e94 100644
--- a/tests/qemudomaincheckpointxml2xmltest.c
+++ b/tests/qemudomaincheckpointxml2xmltest.c
@@ -175,7 +175,7 @@ mymain(void)
     /* 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", 1);
 
     /* Test a normal user redefine */
     DO_TEST_OUT("redefine", 0);
diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapshotxml2xmltest.c
index fd3bb04e26..04b67111c4 100644
--- a/tests/qemudomainsnapshotxml2xmltest.c
+++ b/tests/qemudomainsnapshotxml2xmltest.c
@@ -160,7 +160,7 @@ mymain(void)
     /* 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", 1);
 
     DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8",
                 TEST_INTERNAL);
diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c
index 906d594ace..dffe47c386 100644
--- a/tests/qemufirmwaretest.c
+++ b/tests/qemufirmwaretest.c
@@ -70,7 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED)
 
     fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
 
-    setenv("XDG_CONFIG_HOME", fakehome, 1);
+    g_setenv("XDG_CONFIG_HOME", fakehome, 1);
 
     if (qemuFirmwareFetchConfigs(&fwList, false) < 0)
         return -1;
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index a0a579f29a..0c013d138b 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -598,7 +598,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 #if !WITH_YAJL
     fputs("libvirt not compiled with JSON support, skipping this test\n", stderr);
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index d5a4fb1268..50e25ee80f 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -67,7 +67,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
     if (qemuTestDriverInit(&driver) < 0) {
         VIR_FREE(fakerootdir);
diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c
index 685ac4dca2..71719241c3 100644
--- a/tests/qemusecuritytest.c
+++ b/tests/qemusecuritytest.c
@@ -112,7 +112,7 @@ testDomain(const void *opaque)
 
     /* 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", 0) < 0)
         return -1;
 
     if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c
index cc1e523841..6ff7923099 100644
--- a/tests/qemuvhostusertest.c
+++ b/tests/qemuvhostusertest.c
@@ -68,7 +68,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED)
 
     fakehome = g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config");
 
-    setenv("XDG_CONFIG_HOME", fakehome, 1);
+    g_setenv("XDG_CONFIG_HOME", fakehome, 1);
 
     if (qemuVhostUserFetchConfigs(&vuList, false) < 0)
         return -1;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f0405866e1..62fd95b97d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -614,15 +614,15 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
     /* 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", 1) < 0) {
+        perror("g_setenv");
         return EXIT_FAILURE;
     }
 
@@ -793,10 +793,10 @@ mymain(void)
     /* 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);
+    g_setenv("PATH", "/bin", 1);
+    g_setenv("USER", "test", 1);
+    g_setenv("LOGNAME", "test", 1);
+    g_setenv("HOME", "/home/test", 1);
     unsetenv("TMPDIR");
     unsetenv("LD_PRELOAD");
     unsetenv("LD_LIBRARY_PATH");
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 8b256b9b19..047e1d2b91 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -147,7 +147,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
     /* Required for tpm-emulator tests
      */
@@ -234,7 +234,7 @@ mymain(void)
     /* 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", 1);
 
     DO_TEST("minimal", NONE);
     DO_TEST_CAPS_LATEST("genid");
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index 8b90ddada9..50d4f40dc5 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -145,7 +145,7 @@ int setcon_raw(const char *context)
         errno = EINVAL;
         return -1;
     }
-    return setenv("FAKE_SELINUX_CONTEXT", context, 1);
+    return g_setenv("FAKE_SELINUX_CONTEXT", context, 1);
 }
 
 int setcon(const char *context)
@@ -224,7 +224,7 @@ int security_disable(void)
         return -1;
     }
 
-    return setenv("FAKE_SELINUX_DISABLED", "1", 1);
+    return g_setenv("FAKE_SELINUX_DISABLED", "1", 1);
 }
 
 int security_getenforce(void)
diff --git a/tests/testutils.c b/tests/testutils.c
index a3bedd0fef..3c786b3e29 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -96,7 +96,7 @@ virTestRun(const char *title,
     /* 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, 1);
 
     if (testCounter == 0 && !virTestGetVerbose())
         fprintf(stderr, "      ");
@@ -813,7 +813,7 @@ virTestSetEnvPath(void)
     }
 
     if (new_path &&
-        setenv("PATH", new_path, 1) < 0)
+        g_setenv("PATH", new_path, 1) < 0)
         goto cleanup;
 
     ret = 0;
@@ -847,7 +847,7 @@ int virTestMain(int argc,
     if (STRPREFIX(progname, "lt-"))
         progname += 3;
 
-    setenv("VIR_TEST_MOCK_PROGNAME", progname, 1);
+    g_setenv("VIR_TEST_MOCK_PROGNAME", progname, 1);
 
     virFileActivateDirOverrideForProg(argv[0]);
 
diff --git a/tests/testutils.h b/tests/testutils.h
index 0088251dca..c9ee11855f 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -118,7 +118,7 @@ int virTestMain(int argc,
 #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", 1);
 # define MOCK_EXT ".dylib"
 #else
 # define PRELOAD_VAR "LD_PRELOAD"
@@ -140,7 +140,7 @@ int virTestMain(int argc,
             } else { \
                 newenv = g_strdup_printf("%s:%s", lib, preload); \
             } \
-            setenv(PRELOAD_VAR, newenv, 1); \
+            g_setenv(PRELOAD_VAR, newenv, 1); \
             FORCE_FLAT_NAMESPACE \
             execv(argv[0], argv); \
         } \
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 6fe385e545..081ed331fa 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -603,7 +603,7 @@ qemuTestSetHostCPU(virCapsPtr caps,
     if (cpu) {
         caps->host.arch = cpu->arch;
         if (cpu->model)
-            setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
+            g_setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
     }
     caps->host.cpu = cpu;
 }
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index e1770426d7..dfedb0b91c 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -187,7 +187,7 @@ testCgroupDetectMounts(const void *args)
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     size_t i;
 
-    setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
+    g_setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1);
 
     parsed = g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir, data->file);
 
@@ -994,13 +994,13 @@ initFakeFS(const char *mode,
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
     if (mode)
-        setenv("VIR_CGROUP_MOCK_MODE", mode, 1);
+        g_setenv("VIR_CGROUP_MOCK_MODE", mode, 1);
 
     if (filename)
-        setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1);
+        g_setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1);
 
     return fakerootdir;
 }
diff --git a/tests/virfiletest.c b/tests/virfiletest.c
index c7d5f6abeb..70ad4ab92c 100644
--- a/tests/virfiletest.c
+++ b/tests/virfiletest.c
@@ -327,7 +327,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED)
 
     mtabFile = g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabFile);
 
-    if (setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) {
+    if (g_setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) {
         fprintf(stderr, "Unable to set env variable\n");
         goto cleanup;
     }
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 1f3f730433..05e1933b9e 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -507,7 +507,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 # define DO_TEST(fnc) \
     do { \
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 6c01336420..2210c8cc91 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -111,7 +111,7 @@ mymain(void)
 {
     int ret = 0;
 
-    setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+    g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
 
     testTLSInit(KEYFILE);
 
diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c
index 997cf5a372..59924c7037 100644
--- a/tests/virnettlssessiontest.c
+++ b/tests/virnettlssessiontest.c
@@ -239,7 +239,7 @@ mymain(void)
 {
     int ret = 0;
 
-    setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
+    g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1);
 
     testTLSInit(KEYFILE);
 
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index d6dbe8c1ef..d99f53beaf 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -335,7 +335,7 @@ mymain(void)
         abort();
     }
 
-    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
+    g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
 # define DO_TEST(fnc) \
     do { \
diff --git a/tests/virportallocatortest.c b/tests/virportallocatortest.c
index 8e62fc4519..4e50cd74b3 100644
--- a/tests/virportallocatortest.c
+++ b/tests/virportallocatortest.c
@@ -171,7 +171,7 @@ mymain(void)
     if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0)
         ret = -1;
 
-    setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1);
+    g_setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1);
 
     if (virTestRun("Test IPv4-only alloc all", testAllocAll, NULL) < 0)
         ret = -1;
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index b85259f61f..3564eea50d 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -236,7 +236,7 @@ static int testCreateNoSystemd(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_NO_SERVICE", "1", 1);
+    g_setenv("FAIL_NO_SERVICE", "1", 1);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -270,7 +270,7 @@ static int testCreateSystemdNotRunning(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_NOT_REGISTERED", "1", 1);
+    g_setenv("FAIL_NOT_REGISTERED", "1", 1);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -304,7 +304,7 @@ static int testCreateBadSystemd(const void *opaque G_GNUC_UNUSED)
     };
     int rv;
 
-    setenv("FAIL_BAD_SERVICE", "1", 1);
+    g_setenv("FAIL_BAD_SERVICE", "1", 1);
 
     if ((rv = virSystemdCreateMachine("demo",
                                       "qemu",
@@ -445,7 +445,7 @@ static int testPMSupportHelper(const void *opaque)
     const struct testPMSupportData *data = opaque;
 
     for (i = 0; i < 4; i++) {
-        setenv("RESULT_SUPPORT",  results[i], 1);
+        g_setenv("RESULT_SUPPORT",  results[i], 1);
         if ((rv = data->tested(&result)) < 0) {
             fprintf(stderr, "%s", "Unexpected canSuspend error\n");
             return -1;
@@ -470,7 +470,7 @@ static int testPMSupportHelperNoSystemd(const void *opaque)
     bool result;
     const struct testPMSupportData *data = opaque;
 
-    setenv("FAIL_NO_SERVICE", "1", 1);
+    g_setenv("FAIL_NO_SERVICE", "1", 1);
 
     if ((rv = data->tested(&result)) == 0) {
         unsetenv("FAIL_NO_SERVICE");
@@ -493,7 +493,7 @@ static int testPMSupportSystemdNotRunning(const void *opaque)
     bool result;
     const struct testPMSupportData *data = opaque;
 
-    setenv("FAIL_NOT_REGISTERED", "1", 1);
+    g_setenv("FAIL_NOT_REGISTERED", "1", 1);
 
     if ((rv = data->tested(&result)) == 0) {
         unsetenv("FAIL_NOT_REGISTERED");
@@ -567,11 +567,11 @@ testActivation(bool useNames)
     snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
     snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
 
-    setenv("LISTEN_FDS", nfdstr, 1);
-    setenv("LISTEN_PID", pidstr, 1);
+    g_setenv("LISTEN_FDS", nfdstr, 1);
+    g_setenv("LISTEN_PID", pidstr, 1);
 
     if (useNames)
-        setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
+        g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1);
     else
         unsetenv("LISTEN_FDNAMES");
 
diff --git a/tests/virtimetest.c b/tests/virtimetest.c
index 1eb321858b..0a5542ee34 100644
--- a/tests/virtimetest.c
+++ b/tests/virtimetest.c
@@ -79,8 +79,8 @@ testTimeLocalOffset(const void *args)
     const testTimeLocalOffsetData *data = args;
     long actual;
 
-    if (setenv("TZ", data->zone, 1) < 0) {
-        perror("setenv");
+    if (g_setenv("TZ", data->zone, 1) < 0) {
+        perror("g_setenv");
         return -1;
     }
     tzset();
diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helper.c
index ace8733968..87735833d9 100644
--- a/tools/virt-login-shell-helper.c
+++ b/tools/virt-login-shell-helper.c
@@ -382,13 +382,13 @@ main(int argc, char **argv)
         }
 
         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", 1);
+        g_setenv("SHELL", shcmd, 1);
+        g_setenv("USER", name, 1);
+        g_setenv("LOGNAME", name, 1);
+        g_setenv("HOME", homedir, 1);
         if (term)
-            setenv("TERM", term, 1);
+            g_setenv("TERM", term, 1);
 
         if (execv(shcmd, (char *const*) shargv) < 0) {
             virReportSystemError(errno, _("Unable to exec shell %s"),
-- 
2.23.0




More information about the libvir-list mailing list