File: pam_geoip.h

package info (click to toggle)
pam-geoip 2.1.1-8
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: ansic: 498; makefile: 98
file content (78 lines) | stat: -rw-r--r-- 2,222 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * pam_geoip.h - account module to check GeoIP information
 *
 * $Id$
 *
 */

#ifndef _PAM_GEOIP_H
#define _PAM_GEOIP_H

#define _GNU_SOURCE
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/socket.h>
#include <syslog.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <math.h>
#include <maxminddb.h>
#include <security/pam_modutil.h> /* pam_modutil_user_in_group_nam_nam() */
#include <security/pam_ext.h>     /* pam_syslog() */
#include <security/pam_appl.h>
#define PAM_SM_ACCOUNT
#include <security/pam_modules.h>

#define LINE_LENGTH 4095
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif /* PATH_MAX */

#ifndef LANG_MAX
# define LANG_MAX 128
#endif /* LANG_MAX */

#define SYSTEM_FILE  "/etc/security/geoip.conf"
#define SERVICE_FILE "/etc/security/geoip.%s.conf"
#define GEOIPDB_FILE "/usr/share/GeoIP/GeoLite2-City.mmdb"

/* GeoIP locations in geoip.conf */
struct locations {
    char *country;
    char *city;
    double latitude;
    double longitude;
    float radius;     /* in km */
    struct locations *next;
};

/* options set on "command line" in /etc/pam.d/ */
struct options {
    char *system_file;
    char *geoip_db;
    char *service_file; /* not on cmd line */
    int  by_service;    /* if service_file can be opened this is true */
    int  action;
    int  is_city_db;
    int  debug;
    char *language;
};

extern struct locations *parse_locations(pam_handle_t *pamh, struct options *opts, char *location_string);
extern void free_locations(struct locations *list);
extern void free_opts(struct options *opts);
extern int parse_action(pam_handle_t *pamh, char *name);
extern int parse_conf_line(pam_handle_t *pamh, char *line, char *domain, char *service, char *location);
extern int check_service(pam_handle_t *pamh, char *services, char *srv);
extern double calc_distance(double latitude, double longitude, double geo_lat, double geo_long);
extern int check_location(pam_handle_t *pamh, struct options *opts, char *location_string, struct locations *geo);
extern void _parse_args(pam_handle_t *pamh, int argc, const char **argv, struct options *opts);

#endif /* _PAM_GEOIP_H */

/*
 * vim: ts=4 sw=4 expandtab
 */