#include #include #include #include #include #include #include #include #include #include static int converse(int n, const struct pam_message **msg, struct pam_response **resp, void *data) { return PAM_SUCCESS; } int main() { pam_handle_t *pamh; struct pam_conv pamc; pamc.conv = converse; int rc = pam_start("pamapp", "admin", &pamc, &pamh); if (rc != PAM_SUCCESS) { printf("Failed to init PAM (%s)\n", pam_strerror(pamh, rc)); return EXIT_FAILURE; } char buff[256]; gethostname(buff, sizeof(buff)); rc = pam_set_item(pamh, PAM_RUSER, "admin"); rc = pam_set_item(pamh, PAM_RHOST, strdup(buff)); if (rc != PAM_SUCCESS) printf("Failed to set items: %s (%d)\n", pam_strerror(pamh, rc), rc); rc = pam_authenticate(pamh, 0); if (rc != PAM_SUCCESS) { printf("Failed to authenticate: %s (%d)\n", pam_strerror(pamh, rc), rc); if (rc == PAM_MODULE_UNKNOWN) printf("Are 32 bit modules installed? (apt-get install libpam-modules:i386)"); } pam_end(pamh, rc); return rc =! PAM_SUCCESS; }