forked from tester1969/pam-validity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pam_validity.c
56 lines (48 loc) · 1.39 KB
/
pam_validity.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
/* expected hook */
PAM_EXTERN int pam_sm_setcred( pam_handle_t *pamh, int flags, int argc, const char **argv ) {
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv) {
return PAM_SUCCESS;
}
/* expected hook, this is where custom stuff happens */
PAM_EXTERN int pam_sm_authenticate( pam_handle_t *pamh, int flags,int argc, const char **argv ) {
int retval;
pid_t pid;
const char* pUsername;
char *const parmList[] = {"/bin/ls", "-l", "/u/userid/dirname", NULL};
char *const envParms[2] = {"STEPLIB=SASC.V6.LINKLIB", NULL};
int i = 1; int waitstatus;
// ubuntu, fedora
//chdir("/usr/local/bin/python-validity");
// arch
chdir("/usr/share/python-validity/playground");
pid = fork();
if (pid < 0) {
fprintf(stderr, "Fork failed");
return 1;
}
else if (pid == 0) {
//i = execv("/usr/local/bin/python-validity/pam_validity.sh", NULL);
i = execv("/usr/share/python-validity/playground/pam_validity.sh", NULL);
}
else {
wait(&waitstatus);
i = WEXITSTATUS(waitstatus);
}
retval = pam_get_user(pamh, &pUsername, "Username: ");
if (i == 0) {
return PAM_SUCCESS;
}
else {
return PAM_AUTH_ERR;
}
}