ProxyAuth
Linux PAM to authenticate device via Bluetooth device
Functions
pam_misc.h File Reference
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
Include dependency graph for pam_misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void get_login_time (char *curr_time)
 
int get_num_lines (FILE *fp)
 
int check_or_creat_dir (const char *dir_path, FILE *log_fp)
 

Function Documentation

◆ check_or_creat_dir()

int check_or_creat_dir ( const char *  dir_path,
FILE *  log_fp 
)

Check if the directory exists. If not try to create the directory

Parameters
dir_pathThe path to the directory
log_fpthe handle of the log file
Returns
-1: cannot access dir or file is not a directory or directory could not be created
0: created the directory
1: file exists and it is a directory

Definition at line 37 of file pam_misc.c.

◆ get_login_time()

void get_login_time ( char *  curr_time)

Set the login time to the given pointer
Format: a b d H:M:S Y
Example: Fri Feb 11 02:59:18 2020

a: locale's abbreviated weekday name (e.g., Sun)
b: locale's abbreviated month name (e.g., Jan)
d: day of month (e.g., 01)
H: hour (00..23)
M: minute (00..59)
S: second (00..60)
Y: year
Credits: man date for the format specifier

Parameters
curr_timea pointer to store the current time
Returns
nothing

Definition at line 3 of file pam_misc.c.

◆ get_num_lines()

int get_num_lines ( FILE *  fp)

Return the number of lines there are in the file

Use Case: Each user will have a list of trusted bluetooth MAC stored in a file. E Each line will contain a trusted bluetooth MAC address. The number of lines in the file will represent the number of trusted devices

Parameters
FILE*fp: the file handle that contains the user's device
Returns
: the number of lines there are in the file

Definition at line 13 of file pam_misc.c.