xauth-pam: Avoid race for multiple concurrent authentication attempts

The previously static pam_conv instance could get reused by multiple
threads, causing one to use the password of the other.
This commit is contained in:
Tobias Brunner
2026-07-23 10:26:08 +02:00
parent 4bef380ce0
commit eec3164b41
+4 -4
View File
@@ -77,13 +77,13 @@ static int auth_conv(int num_msg, const struct pam_message **msg,
*/
static bool authenticate(char *service, char *user, char *password)
{
struct pam_conv conv = {
.conv = (void*)auth_conv,
.appdata_ptr = password,
};
pam_handle_t *pamh = NULL;
static struct pam_conv conv;
int ret;
conv.conv = (void*)auth_conv;
conv.appdata_ptr = password;
ret = pam_start(service, user, &conv, &pamh);
if (ret != PAM_SUCCESS)
{