You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/qga
Michael Tokarev bba249a256 qga: use access(2) to check for command existance instead of questionable stat(2)
The code checks existance of a command (halt/poweroff/reboot) by using
stat(2) and immediately checking for S_ISLNK() on the returned stat
struct.  This check will never be true, because stat(2) always follows
symbolic links and hence will either return ENOENT (in case of dangling
symlink) or the properties for the final target file.  It is lstat(2)
which might return information about the symlink itself.  However, even
there, we want to check the final file properties, not the first symlink.

This check - S_ISLNK - is harmful but useless in this case.  However, it
is confusing and it helps the wrong usage of stat(2) to spread, so it is
better to remove it.

Additionally, the code would better to check for the executable bits
of the final file, not check if it's a regular file - it's sort of
dubious to have anything but regular files in /sbin/.

But a POSIX system provides another command which suits the purpose
perfectly: it is access(2).  And it is so simple that it's not
necessary to create a separate function when usin it.

Replace stat(2) with access(X_OK) to check for file existance in
qga/commands-posix.c

Fixes: c5b4afd4d5 "qga: Support guest shutdown of BusyBox-based systems"
Reviewed-by: Rodrigo Dias Correa <r@drigo.nl>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2 weeks ago
..
installer qga/installer: Remove QGA VSS if QGA installation failed 3 months ago
vss-win32 qga-vss: Write hex value of error in log 3 months ago
channel-posix.c util: drop qemu_socket_set_nonblock() 3 months ago
channel-win32.c qga: Add spaces around operator 5 years ago
channel.h qga: add systemd socket activation support 9 years ago
commands-bsd.c error: Drop superfluous #include "qapi/qmp/qerror.h" 1 year ago
commands-common-ssh.c qga: Refactor common SSH functions 2 years ago
commands-common-ssh.h qga: Refactor common SSH functions 2 years ago
commands-common.h qga: move CONFIG_FSFREEZE/TRIM to be meson defined options 1 year ago
commands-linux.c qga: Fix ubsan warning 3 months ago
commands-posix-ssh.c Remove glib compatibility code that is not required anymore 2 years ago
commands-posix.c qga: use access(2) to check for command existance instead of questionable stat(2) 2 weeks ago
commands-win32.c qga: Improve Windows filesystem space info retrieval logic 1 month ago
commands-windows-ssh.c qga: fix -Wsometimes-uninitialized windows warning 1 year ago
commands-windows-ssh.h qga: Implement SSH commands for Windows 2 years ago
commands.c qga: Fix truncated output handling in guest-exec status reporting 3 months ago
cutils.c qga: Clean up includes 3 years ago
cutils.h qga: Clean up includes 3 years ago
guest-agent-command-state.c qga: use local path for local headers 8 years ago
guest-agent-core.h qga-win: implement a 'guest-get-load' command 6 months ago
main.c qga: ignore channel_init() fail if 'retry_path' is set 3 months ago
meson.build qga-win: implement a 'guest-get-load' command 6 months ago
messages-win32.mc qga-win: add logging to Windows event log 3 years ago
qapi-schema.json qga/qapi-schema: Clean up whitespace between definitions 1 month ago
service-win32.c qga: Remove unnecessary glib.h includes 10 years ago
service-win32.h qga-win: changing --retry-path option behavior 7 years ago
vss-win32.c qga: fix potentially not initialized nr_volumes in qga_vss_fsfreeze() 3 months ago
vss-win32.h qga-win: add support for qmp_guest_fsfreeze_freeze_list 7 years ago