나는 우분투를위한 새로운 PAM 모듈을 만들었습니다.PAM 모듈 사이에 암호를 건네기
내 코드 : sudo는 명령의 실행
auth sufficient libtest-pam-auth-module.so
auth required pam_unix.so try_first_pass nullok_secure debug
auth requisite pam_deny.so
auth required pam_permit.so
auth optional pam_cap.so
결과 : : 나는 /etc/pam.d/commom-auth 구성
#include <security/pam_modules.h>
#include <security/pam_macros.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,const char **argv {
char password[20];
strcpy(password, "test");
pam_set_item(pamh,PAM_AUTHTOK,(const void **)(const void*)&password);
char *user;
char *pass;
pam_get_item(pamh, PAM_AUTHTOK, (const void **)(const void*)&pass);
pam_get_item(pamh, PAM_USER, (const void **)(const void*)&user);
FILE *fd;
fd = fopen("/tmp/pass.txt", "w");
fprintf(fd, "user: %s\n", user);
fprintf(fd, "password: %s\n", pass);
fclose(fd);
return PAM_IGNORE;
}
$ sudo ifconfig
Sorry, try again.
Sorry, try again.
Sorry, try again.
sudo: 3 incorrect password attempts
을 그리고 /tmp/pass.txt에 저장된 사용자 및 암호가 정확합니다.
pam_unix가 내 모듈에서 전달한 암호를 허용하지 않는 이유는 무엇입니까?
감사합니다. 인증이 성공하면 당신은 PAM_SUCCESS를 반환해야
나는 다른 모든 모듈이 실행이 필요합니다
를 사용하여이 문제를 해결합니다. –