Score:0

Caching sessions with pam_timestamp on ubuntu

cn flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.