1 /*
2 * $Id$
3 *
4 * Copyright (c) Andrew G. Morgan <morgan@ftp.kernel.org>
5 *
6 */
7
8 #ifndef LIBPAMC_H
9 #define LIBPAMC_H
10
11 #include "config.h"
12
13 #include <security/pam_client.h>
14 #include <security/_pam_macros.h>
15
16 #include <sys/stat.h>
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <dirent.h>
20 #include <sys/wait.h>
21 #include <stdint.h>
22 #include <stdlib.h>
23 #include <errno.h>
24 #include <ctype.h>
25
26 #define _PAMC_DEFAULT_TOP_FD 10
27
28 struct pamc_handle_s {
29 struct pamc_agent_s *current;
30 struct pamc_agent_s *chain;
31 struct pamc_blocked_s *blocked_agents;
32 int max_path;
33 char **agent_paths;
34 int combined_status;
35 int highest_fd_to_close;
36 };
37
38 typedef struct pamc_blocked_s {
39 char *id; /* <NUL> terminated */
40 struct pamc_blocked_s *next;
41 } pamc_blocked_t;
42
43 typedef struct pamc_agent_s {
44 char *id;
45 int id_length;
46 struct pamc_agent_s *next;
47 int writer; /* write to agent */
48 int reader; /* read from agent */
49 pid_t pid; /* agent process id */
50 } pamc_agent_t;
51
52 /* used to build a tree of unique, sorted agent ids */
53
54 typedef struct pamc_id_node {
55 struct pamc_id_node *left, *right;
56 int child_count;
57 char *agent_id;
58 } pamc_id_node_t;
59
60 /* internal function */
61 int __pamc_valid_agent_id(int id_length, const char *id);
62
63 #define PAMC_SYSTEM_AGENT_PATH "/lib/pamc:/usr/lib/pamc"
64 #define PAMC_SYSTEM_AGENT_SEPARATOR ':'
65
66 #endif /* LIBPAMC_H */