mirror of https://gitlab.com/qemu-project/qemu
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.
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:
|
2 weeks ago | |
|---|---|---|
| .. | ||
| installer | 3 months ago | |
| vss-win32 | 3 months ago | |
| channel-posix.c | 3 months ago | |
| channel-win32.c | 5 years ago | |
| channel.h | 9 years ago | |
| commands-bsd.c | 1 year ago | |
| commands-common-ssh.c | 2 years ago | |
| commands-common-ssh.h | 2 years ago | |
| commands-common.h | 1 year ago | |
| commands-linux.c | 3 months ago | |
| commands-posix-ssh.c | 2 years ago | |
| commands-posix.c | 2 weeks ago | |
| commands-win32.c | 1 month ago | |
| commands-windows-ssh.c | 1 year ago | |
| commands-windows-ssh.h | 2 years ago | |
| commands.c | 3 months ago | |
| cutils.c | 3 years ago | |
| cutils.h | 3 years ago | |
| guest-agent-command-state.c | 8 years ago | |
| guest-agent-core.h | 6 months ago | |
| main.c | 3 months ago | |
| meson.build | 6 months ago | |
| messages-win32.mc | 3 years ago | |
| qapi-schema.json | 1 month ago | |
| service-win32.c | 10 years ago | |
| service-win32.h | 7 years ago | |
| vss-win32.c | 3 months ago | |
| vss-win32.h | 7 years ago | |