
Ich versuche, PAM und das Modul pam_timestamp zu verwenden, um die Anzahl der einzugebenden Passwörter zu reduzieren.
Testprogramm überhttps://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");
}
Testen Sie die PAM-Konfiguration. /etc/pam.d/myconfig
Dies stammt direkt aus der Manpage.
auth sufficient pam_timestamp.so verbose
auth required pam_unix.so
session required pam_unix.so
session optional pam_timestamp.so
Wenn ich das Testprogramm ausführe, werde ich jedoch immer nach dem Kennwort gefragt. Ich hätte erwartet, dass nach der Erstellung der Zeitstempeldatei keine weitere Abfrage erfolgt.
nfultz@neal-slg2:/tmp/pamapp$ ./a.out
Password:
SUCCESS!
nfultz@neal-slg2:/tmp/pamapp$ ./a.out
Password:
authenticate failed: 7
Dies ist auf Ubuntu 23.04, falls das wichtig ist.