I am trying to use PAM and the pam_timestamp module to reduce the number of passwords I need to enter.
Test program via https://learning.oreilly.com/library/view/linux-security-cookbook/0596003919/ch04s01.html#linuxsckbk-CHP-4-SECT-1.2:
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <pwd.h>
#include <sys/types.h>
#include <stdio.h>
#define MY_CONFIG "myconfig"
static struct pam_conv conv = { misc_conv, NULL };
main( )
{
pam_handle_t *pamh;
int result;
struct passwd *pw;
if ((pw = getpwuid(getuid( ))) == NULL)
perror("getpwuid");
else if ((result = pam_start(MY_CONFIG, pw->pw_name, &conv, &pamh)) != PAM_SUCCESS)
fprintf(stderr, "start failed: %d\n", result);
else if ((result = pam_authenticate(pamh, 0)) != PAM_SUCCESS)
fprintf(stderr, "authenticate failed: %d\n", result);
else if ((result = pam_acct_mgmt(pamh, 0)) != PAM_SUCCESS)
fprintf(stderr, "acct_mgmt failed: %d\n", result);
else if ((result = pam_end(pamh, result)) != PAM_SUCCESS)
fprintf(stderr, "end failed: %d\n", result);
else
fprintf(stderr, "SUCCESS!\n");
}
Test pam config, /etc/pam.d/myconfig
- this is straight out of the man page
auth sufficient pam_timestamp.so verbose
auth required pam_unix.so
session required pam_unix.so
session optional pam_timestamp.so
However, when I run the test program, it always asks for the password, i would have expected it to not ask after the timestamp file is created.
nfultz@neal-slg2:/tmp/pamapp$ ./a.out
Password:
SUCCESS!
nfultz@neal-slg2:/tmp/pamapp$ ./a.out
Password:
authenticate failed: 7
This is on Ubuntu 23.04 if that matters.