[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/53] qga: remove explicit environ argument from exec/spawn
From: |
Paolo Bonzini |
Subject: |
[PULL 35/53] qga: remove explicit environ argument from exec/spawn |
Date: |
Tue, 19 Apr 2022 07:50:51 +0200 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Environment is implicitly inherited from the current process "environ"
variable for execl() or g_spawn_sync(), no need to be explicit about it.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220323155743.1585078-31-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 2 --
qga/commands-posix.c | 24 +++++++-----------------
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/meson.build b/meson.build
index 08f8183a66..a0b6de255c 100644
--- a/meson.build
+++ b/meson.build
@@ -1654,8 +1654,6 @@ config_host_data.set('CONFIG_BYTESWAP_H',
cc.has_header_symbol('byteswap.h', 'bswap_32'))
config_host_data.set('CONFIG_EPOLL_CREATE1',
cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
-config_host_data.set('CONFIG_HAS_ENVIRON',
- cc.has_header_symbol('unistd.h', 'environ', prefix:
gnu_source_prefix))
config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
cc.has_header_symbol('linux/falloc.h',
'FALLOC_FL_PUNCH_HOLE') and
cc.has_header_symbol('linux/falloc.h',
'FALLOC_FL_KEEP_SIZE'))
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 1e7b4656ed..84a3b912be 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -32,15 +32,6 @@
#include <utmpx.h>
#endif
-#ifndef CONFIG_HAS_ENVIRON
-#ifdef __APPLE__
-#include <crt_externs.h>
-#define environ (*_NSGetEnviron())
-#else
-extern char **environ;
-#endif
-#endif
-
#if defined(__linux__)
#include <mntent.h>
#include <linux/fs.h>
@@ -109,8 +100,8 @@ void qmp_guest_shutdown(bool has_mode, const char *mode,
Error **errp)
reopen_fd_to_null(1);
reopen_fd_to_null(2);
- execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
- "hypervisor initiated shutdown", (char *)NULL, environ);
+ execl("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
+ "hypervisor initiated shutdown", (char *)NULL);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
@@ -193,8 +184,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns,
Error **errp)
/* Use '/sbin/hwclock -w' to set RTC from the system time,
* or '/sbin/hwclock -s' to set the system time from RTC. */
- execle(hwclock_path, "hwclock", has_time ? "-w" : "-s",
- NULL, environ);
+ execl(hwclock_path, "hwclock", has_time ? "-w" : "-s", NULL);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
@@ -1560,7 +1550,7 @@ static void execute_fsfreeze_hook(FsfreezeHookArg arg,
Error **errp)
reopen_fd_to_null(1);
reopen_fd_to_null(2);
- execle(hook, hook, arg_str, NULL, environ);
+ execl(hook, hook, arg_str, NULL);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
@@ -1874,7 +1864,7 @@ static int run_process_child(const char *command[], Error
**errp)
spawn_flag = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL |
G_SPAWN_STDERR_TO_DEV_NULL;
- success = g_spawn_sync(NULL, (char **)command, environ, spawn_flag,
+ success = g_spawn_sync(NULL, (char **)command, NULL, spawn_flag,
NULL, NULL, NULL, NULL,
&exit_status, &g_err);
@@ -2555,9 +2545,9 @@ void qmp_guest_set_user_password(const char *username,
reopen_fd_to_null(2);
if (crypted) {
- execle(passwd_path, "chpasswd", "-e", NULL, environ);
+ execl(passwd_path, "chpasswd", "-e", NULL);
} else {
- execle(passwd_path, "chpasswd", NULL, environ);
+ execl(passwd_path, "chpasswd", NULL);
}
_exit(EXIT_FAILURE);
} else if (pid < 0) {
--
2.35.1
- [PULL 13/53] osdep: poison {HOST,TARGET}_WORDS_BIGENDIAN, (continued)
- [PULL 13/53] osdep: poison {HOST,TARGET}_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 09/53] meson: remove test-qdev-global-props dependency on testqapi, Paolo Bonzini, 2022/04/19
- [PULL 10/53] char: move qemu_openpty_raw from util/ to char/, Paolo Bonzini, 2022/04/19
- [PULL 17/53] qga: replace deprecated g_get_current_time(), Paolo Bonzini, 2022/04/19
- [PULL 12/53] Replace TARGET_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 02/53] qtest: replace gettimeofday with GTimer, Paolo Bonzini, 2022/04/19
- [PULL 15/53] tests: replace free_all() usage with g_auto, Paolo Bonzini, 2022/04/19
- [PULL 31/53] include: move os_*() to os-foo.h, Paolo Bonzini, 2022/04/19
- [PULL 33/53] Move CPU softfloat unions to cpu-float.h, Paolo Bonzini, 2022/04/19
- [PULL 34/53] Move fcntl_setfl() to oslib-posix, Paolo Bonzini, 2022/04/19
- [PULL 35/53] qga: remove explicit environ argument from exec/spawn,
Paolo Bonzini <=
- [PULL 28/53] include: move target page bits declaration to page-vary.h, Paolo Bonzini, 2022/04/19
- [PULL 29/53] include: move progress API to qemu-progress.h, Paolo Bonzini, 2022/04/19
- [PULL 45/53] hyperv: Add definitions for syndbg, Paolo Bonzini, 2022/04/19
- [PULL 46/53] hyperv: Add support to process syndbg commands, Paolo Bonzini, 2022/04/19
- [PULL 36/53] Remove qemu-common.h include from most units, Paolo Bonzini, 2022/04/19
- [PULL 48/53] s390x: follow qdev tree to detect SCSI device on a CCW bus, Paolo Bonzini, 2022/04/19
- [PULL 22/53] include: move qemu_write_full() declaration to osdep.h, Paolo Bonzini, 2022/04/19
- [PULL 18/53] error-report: replace deprecated g_get_current_time() with glib >= 2.62, Paolo Bonzini, 2022/04/19
- [PULL 43/53] thread-posix: optimize qemu_sem_timedwait with zero timeout, Paolo Bonzini, 2022/04/19
- [PULL 50/53] virtio-ccw: move device type declarations to .c files, Paolo Bonzini, 2022/04/19