-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpam.cpp
54 lines (44 loc) · 1.12 KB
/
pam.cpp
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
// Copyright (c) <2017> <Alexander Basov>
#define PAM_SM_AUTH
#include <security/pam_modules.h>
#include <syslog.h>
#include <security/pam_ext.h>
#include "usb_device.h"
#define UNUSED __attribute__ ((unused))
extern "C"
{
/* expected hook */
PAM_EXTERN
int
pam_sm_setcred(pam_handle_t *ph,
int flags UNUSED,
int argc UNUSED,
const char **argv UNUSED)
{
pam_syslog(ph, LOG_WARNING, "%s : %s", __PRETTY_FUNCTION__, "PAM_SUCCESS");
// TODO implement this function
return PAM_SUCCESS;
}
PAM_EXTERN
int pam_sm_acct_mgmt(pam_handle_t *ph,
int flags UNUSED,
int argc UNUSED,
const char **argv UNUSED)
{
pam_syslog(ph, LOG_WARNING, "%s : %s", __PRETTY_FUNCTION__, "PAM_SUCCESS");
// TODO implement this function
return PAM_SUCCESS;
}
PAM_EXTERN
int
pam_sm_authenticate(pam_handle_t *ph UNUSED,
int flags UNUSED,
int argc UNUSED,
const char **argv UNUSED)
{
if (isDeviceConnected()) {
return PAM_SUCCESS;
}
return PAM_AUTH_ERR;
}
}