On 01/05/2024 09.43, Konstantin Kostiuk wrote:
From: Andrey Drobyshev <andrey.drobys...@virtuozzo.com>
There's no need to check for the existence of the "chpasswd", "pw"
executables, as the exec() call will do that for us.
Signed-off-by: Andrey Drobyshev <andrey.drobys...@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berra...@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkost...@redhat.com>
Link:
https://lore.kernel.org/r/20240320161648.158226-8-andrey.drobys...@virtuozzo.com
Signed-off-by: Konstantin Kostiuk <kkost...@redhat.com>
---
qga/commands-posix.c | 96 ++++++--------------------------------------
1 file changed, 13 insertions(+), 83 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 9910957ff5..7a065c4085 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2151,14 +2151,8 @@ void qmp_guest_set_user_password(const char *username,
Error **errp)
{
Error *local_err = NULL;
- char *passwd_path = NULL;
- pid_t pid;
- int status;
- int datafd[2] = { -1, -1 };
- char *rawpasswddata = NULL;
+ g_autofree char *rawpasswddata = NULL;
size_t rawpasswdlen;
- char *chpasswddata = NULL;
- size_t chpasswdlen;
rawpasswddata = (char *)qbase64_decode(password, -1, &rawpasswdlen, errp);
if (!rawpasswddata) {
@@ -2169,95 +2163,31 @@ void qmp_guest_set_user_password(const char *username,
if (strchr(rawpasswddata, '\n')) {
error_setg(errp, "forbidden characters in raw password");
- goto out;
+ return;
}
if (strchr(username, '\n') ||
strchr(username, ':')) {
error_setg(errp, "forbidden characters in username");
- goto out;
+ return;
}
#ifdef __FreeBSD__
- chpasswddata = g_strdup(rawpasswddata);
- passwd_path = g_find_program_in_path("pw");
+ g_autofree char *chpasswdata = g_strdup(rawpasswddata);
Hi!
This broke compilation on FreeBSD:
https://gitlab.com/qemu-project/qemu/-/jobs/6760232764#L7125
Looks like a typo in the variable name?
Thomas