debug test

This commit is contained in:
2026-03-17 16:35:15 +11:00
parent bdbd94eda2
commit 793a643731
2 changed files with 35 additions and 6 deletions

View File

@@ -6,6 +6,7 @@
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <security/pam_ext.h>
#include <cstring>
#include "rust_backend_ffi.h"
#include "auth_client.h"
@@ -19,10 +20,20 @@ int pam_sm_authenticate(pam_handle_t* pamh, int flags, int argc, const char** ar
const char* user = nullptr;
pam_get_user(pamh, &user, NULL);
const void* pw_ptr = nullptr;
int item_result = pam_get_item(pamh, PAM_AUTHTOK, &pw_ptr);
const char* password = (item_result == PAM_SUCCESS && pw_ptr) ? static_cast<const char*>(pw_ptr) : nullptr;
int rc = pam_get_user(pamh, &user, nullptr);
if (rc != PAM_SUCCESS || user == nullptr) {
RUST_CERR() << "Failed to get username: " << pam_strerror(pamh, rc) << std::flush;
return PAM_AUTH_ERR;
}
const char* password = nullptr;
rc = pam_get_authtok(pamh, PAM_AUTHTOK, &password, nullptr);
if (rc != PAM_SUCCESS || password == nullptr) {
RUST_CERR() << "Failed to get password: " << pam_strerror(pamh, rc) << std::flush;
return PAM_AUTH_ERR;
}
RUST_CDEBUG() << "Extracted credentials: user='" << (user ? user : "(null)") << "' password='" << (password ? "(redacted)" : "(null)") << "'" << std::flush;
int result = auth_client_authenticate(user, password);
return result;
} catch (...) {