ProxyAuth
Linux PAM to authenticate device via Bluetooth device
pam_test.c
Go to the documentation of this file.
1 /*
2 * AUTHOR: zakuarbor (Ju Hong Kim)
3 * DESC: For testing new features of the PAM module before deployment testing (i.e. Test if feature works as intended without any obvious bugs).
4 * This does not replace testing the PAM module. It is suppose to be used for quick, dirty and simple runtime testing with memory leak checker.
5 */
6 
7 #include <errno.h>
8 #include <limits.h>
9 #include <pwd.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <sys/socket.h>
14 #include <sys/stat.h>
15 #include <time.h>
16 #include <unistd.h>
17 
18 #include <bluetooth/bluetooth.h>
19 #include <bluetooth/hci.h>
20 #include <bluetooth/hci_lib.h>
21 #include <glib.h>
22 #include <gio/gio.h>
23 #include <security/pam_appl.h>
24 #include <security/pam_modules.h>
25 
26 #include "pam_misc.h"
27 #include "pam_bt_misc.h"
28 #include "pam_bt_pair.h"
29 #include "pam_bt_trust.h"
30 #include "pam_post_auth.h"
31 #include "pam_sec.h"
32 
33 int main(int argc, char **argv)
34 {
35  const char *username = "zaku";
36  char *detected_dev;
37 
38  FILE *log_fp = NULL;
39 
40  /*** OPEN LOG FILE ***/
41  if (!(log_fp = fopen("pam-proxy-auth.log", "a"))) {
42  perror("Failed to open file");
43  }
44 
45  /*********************/
46  printf("start bluetooth_login\n");
47  if (bluetooth_login(log_fp, trusted_dir_path, username, &detected_dev)) {
48  printf("Welcome %s. Login via Auth Proxy.\n", username);
49  //exec_deauth(detected_dev, username, log_fp, trusted_dir_path);
50  }
51 
52  if (log_fp) {
53  fclose(log_fp);
54  }
55  free(detected_dev);
56 }
const char * trusted_dir_path
Definition: pam_bt_misc.c:3
int bluetooth_login(FILE *log_fp, const char *trusted_dir_path, const char *username, char **detected_dev)
Definition: pam_bt_trust.c:148
int main(int argc, char **argv)
Definition: pam_test.c:33