-
Notifications
You must be signed in to change notification settings - Fork 42
/
radiusplugin.h
executable file
·118 lines (99 loc) · 3.84 KB
/
radiusplugin.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* radiusplugin -- An OpenVPN plugin for do radius authentication
* and accounting.
*
* Copyright (C) 2005 EWE TEL GmbH/Ralf Luebben <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <dlfcn.h>
#include <syslog.h>
#include <time.h>
#include <fstream>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <time.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include<sys/wait.h>
#include<sys/errno.h>
#include "RadiusClass/RadiusAttribute.h"
#include "RadiusClass/RadiusPacket.h"
#include "RadiusClass/RadiusServer.h"
#include "RadiusClass/RadiusServer.h"
#include "RadiusClass/RadiusConfig.h"
#include "RadiusClass/radius.h"
#include "openvpn-plugin.h"
#include "PluginContext.h"
#include "UserPlugin.h"
#include "UserAuth.h"
#include "UserAcct.h"
#include "AcctScheduler.h"
#include "Exception.h"
#include "AccountingProcess.h"
#include "AuthenticationProcess.h"
using namespace std;
/** This file defines some constants and some functions. The constants and functions
* are the original function from openvpn auth-pam plugin.*/
#define DEBUG(verb) ((verb) >= 5) /**< A macro for the debugging.*/
/* Command codes for foreground -> background communication */
#define COMMAND_VERIFY 0 /**<The verify command for the background process.*/
#define COMMAND_EXIT 1 /**<The ecit command for the background process.*/
#define ADD_USER 2 /**<The add user command for the background process.*/
#define DEL_USER 3 /**<The del user command for the background process.*/
/* Response codes for background -> foreground communication */
#define RESPONSE_INIT_SUCCEEDED 10 /**< Response code from background process to foreground procce.*/
#define RESPONSE_INIT_FAILED 11 /**< Response code from background process to foreground procce.*/
#define RESPONSE_SUCCEEDED 12 /**< Response code from background process to foreground procce.*/
#define RESPONSE_FAILED 13 /**< Response code from background process to foreground procce.*/
/** A struct for additional command line arguments.*/
struct name_value {
const char *name; /**<The name of name value pair.*/
const char *value; /**<The value of the name value pair.*/
};
#define N_NAME_VALUE 16 /**<The array length for data in the value list.*/
/** A list for the struct name_value.*/
struct name_value_list {
int len; /**<The length of the list.*/
struct name_value data[N_NAME_VALUE]; /**<The data of the list.*/
};
const char * get_env (const char *name, const char *envp[]);
int string_array_len (const char *array[]);
void close_fds_except (int keep);
void set_signals (void);
string createSessionId (UserPlugin *);
void get_user_env(PluginContext *, const int type,const char *envp[], UserPlugin *);
void * auth_user_pass_verify(void *);
void * client_connect(void *);
void write_control_file(PluginContext *, string filename, char c);
string getTime();
#endif //_PLUGIN_H_