Paste P333

(An Untitled Masterwork)
ActivePublic

Authored by lpapp on Feb 25 2019, 12:09 PM.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
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;
}
lpapp created this paste.Feb 25 2019, 12:09 PM
lpapp created this object in space S1 KDE Community.