ProxyAuth
Linux PAM to authenticate device via Bluetooth device
src
pam_proxy.c
Go to the documentation of this file.
1
#include "
pam_proxy.h
"
2
3
PAM_EXTERN
int
pam_sm_setcred
( pam_handle_t *pamh,
int
flags,
int
argc,
const
char
**argv ) {
4
return
PAM_SUCCESS;
5
}
6
7
PAM_EXTERN
int
pam_sm_acct_mgmt
(pam_handle_t *pamh,
int
flags,
int
argc,
const
char
**argv) {
8
return
PAM_SUCCESS;
9
}
10
11
12
PAM_EXTERN
int
pam_sm_authenticate
( pam_handle_t *pamh,
int
flags,
int
argc,
const
char
**argv ) {
13
int
bluetooth_status = PAM_AUTH_ERR;
14
15
const
char
* username;
16
char
* detected_dev;
17
18
FILE *log_fp = NULL;
19
20
/*** OPEN LOG FILE ***/
21
if
(!(log_fp = fopen(
"/var/log/pam-proxy-auth.log"
,
"a"
))) {
22
perror(
"Failed to open file"
);
23
}
24
/*********************/
25
26
/*** Get Username ***/
27
if
(pam_get_user(pamh, &username,
"Username: "
) != PAM_SUCCESS) {
28
perror(
"Could not find username"
);
29
if
(log_fp) {
30
fprintf(log_fp,
"Could not find username\n"
);
31
}
32
goto
pam_sm_authenticate
;
33
}
34
/*******************/
35
36
if
(
bluetooth_login
(log_fp,
trusted_dir_path
, username, &detected_dev)) {
37
if
(log_fp) {
38
fprintf(log_fp,
"Login via Auth Proxy\n"
);
39
}
40
exec_deauth
(detected_dev, username, log_fp,
trusted_dir_path
);
41
free(detected_dev);
42
bluetooth_status = PAM_SUCCESS;
43
}
44
45
pam_sm_authenticate
:
46
47
if
(log_fp) {
48
fclose(log_fp);
49
}
50
51
return
bluetooth_status;
52
}
trusted_dir_path
const char * trusted_dir_path
Definition:
pam_bt_misc.c:3
bluetooth_login
int bluetooth_login(FILE *log_fp, const char *trusted_dir_path, const char *username, char **detected_dev)
Definition:
pam_bt_trust.c:148
exec_deauth
int exec_deauth(char *bt_addr, const char *username, FILE *log_fp, const char *trusted_dir_path)
Definition:
pam_post_auth.c:3
pam_sm_acct_mgmt
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc, const char **argv)
Definition:
pam_proxy.c:7
pam_sm_authenticate
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv)
Definition:
pam_proxy.c:12
pam_sm_setcred
PAM_EXTERN int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
Definition:
pam_proxy.c:3
pam_proxy.h
Generated on Mon Mar 7 2022 06:53:49 for ProxyAuth by
1.9.1