1 /* 2 * radiusplugin -- An OpenVPN plugin for do radius authentication 3 * and accounting. 4 * 5 * Copyright (C) 2005 EWE TEL GmbH/Ralf Luebben <ralfluebben@gmx.de> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef _PLUGIN_H_ 23 #define _PLUGIN_H_ 24 25 26 #include <stdio.h> 27 #include <string.h> 28 #include <ctype.h> 29 #include <unistd.h> 30 #include <stdlib.h> 31 #include <sys/types.h> 32 #include <sys/socket.h> 33 #include <sys/wait.h> 34 #include <fcntl.h> 35 #include <signal.h> 36 #include <dlfcn.h> 37 #include <syslog.h> 38 #include <time.h> 39 #include <fstream> 40 #include <netinet/in.h> 41 #include <arpa/inet.h> 42 #include <stdlib.h> 43 #include <iostream> 44 #include <string> 45 #include <sstream> 46 #include <iomanip> 47 #include <time.h> 48 #include<sys/ipc.h> 49 #include<sys/msg.h> 50 #include<sys/wait.h> 51 #include<sys/errno.h> 52 #include "RadiusClass/RadiusAttribute.h" 53 #include "RadiusClass/RadiusPacket.h" 54 #include "RadiusClass/RadiusServer.h" 55 #include "RadiusClass/RadiusServer.h" 56 #include "RadiusClass/RadiusConfig.h" 57 #include "RadiusClass/radius.h" 58 #include "openvpn-plugin.h" 59 #include "PluginContext.h" 60 #include "UserPlugin.h" 61 #include "UserAuth.h" 62 #include "UserAcct.h" 63 #include "AcctScheduler.h" 64 #include "Exception.h" 65 #include "AccountingProcess.h" 66 #include "AuthenticationProcess.h" 67 68 using namespace std; 69 70 /** This file defines some constants and some functions. The constants and functions 71 * are the original function from openvpn auth-pam plugin.*/ 72 73 #define DEBUG(verb) ((verb) >= 5) /**< A macro for the debugging.*/ 74 75 /* Command codes for foreground -> background communication */ 76 #define COMMAND_VERIFY 0 /**<The verify command for the background process.*/ 77 #define COMMAND_EXIT 1 /**<The ecit command for the background process.*/ 78 #define ADD_USER 2 /**<The add user command for the background process.*/ 79 #define DEL_USER 3 /**<The del user command for the background process.*/ 80 81 /* Response codes for background -> foreground communication */ 82 #define RESPONSE_INIT_SUCCEEDED 10 /**< Response code from background process to foreground procce.*/ 83 #define RESPONSE_INIT_FAILED 11 /**< Response code from background process to foreground procce.*/ 84 #define RESPONSE_SUCCEEDED 12 /**< Response code from background process to foreground procce.*/ 85 #define RESPONSE_FAILED 13 /**< Response code from background process to foreground procce.*/ 86 87 88 89 /** A struct for additional command line arguments.*/ 90 struct name_value { 91 const char *name; /**<The name of name value pair.*/ 92 const char *value; /**<The value of the name value pair.*/ 93 }; 94 95 96 #define N_NAME_VALUE 16 /**<The array length for data in the value list.*/ 97 98 /** A list for the struct name_value.*/ 99 struct name_value_list { 100 int len; /**<The length of the list.*/ 101 struct name_value data[N_NAME_VALUE]; /**<The data of the list.*/ 102 }; 103 104 105 const char * get_env (const char *name, const char *envp[]); 106 int string_array_len (const char *array[]); 107 void close_fds_except (int keep); 108 void set_signals (void); 109 string createSessionId (UserPlugin *); 110 111 void * auth_user_pass_verify(void *); 112 void write_auth_control_file(PluginContext *, string filename, char c); 113 string getTime(); 114 115 116 117 #endif //_PLUGIN_H_ 118