Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfluebben committed Aug 29, 2012
1 parent 67f4724 commit f3562cc
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 52 deletions.
2 changes: 1 addition & 1 deletion AccountingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void AccountingProcess::Accounting(PluginContext * context)
string key; //The unique key.
AcctScheduler scheduler; //The scheduler for the accounting.
fd_set set; //A set for the select function.
struct timeval tv; //A timeinterval for the select funtion.
struct timeval tv; //A timeinterval for the select function.



Expand Down
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ radiusplugin_2.1:
- Adapted to OPENVPN_PLUGIN_VERSION 2
- Internal key is now based on untrusted_ip and untrusted_before.
- Separated key for status file is added.
- Update password and username if the user (key) is already known. Before if the ip and port would be the same and the timeout hasn't occured the login will success. The update prevents against this behaviour.
- Update password and username if the user (key) is already known. Before if the ip and port were the same and the timeout hasn't occurred the login will success. The update prevents against this behaviour.
- Initialization of gcrypt library added.
- Rewrite ACF file when the user is authenticated.
- Include nested configfiles from main configfile.
Expand Down
2 changes: 1 addition & 1 deletion Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Config
string statusfile; /**< The path and filename of the status file, where openvpn writes the status information.*/
char subnet[16]; /**<The subnet which is assigned to the client in topology option.*/
char p2p[16]; /**<The OpenVPN server address which is assigned to the client in topology p2p.*/
string vsascript; /**<A script whcih handles vendor specific attributes.*/
string vsascript; /**<A script which handles vendor specific attributes.*/
string vsanamedpipe; /**<The named pipe to the vsascript.*/
bool usernameascommonname; /**<Use the username as commonname in the plugin (for OpenVPN option username-as-common-name (no commonname in the enviroment!)).*/
bool clientcertnotrequired; /**<For OpenVPN option client_cert_not_required, commonname = UNDEF.*/
Expand Down
47 changes: 29 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
BLUE =\033[20;36m
GREEN =\033[32m
RED =\033[31m
ESC =\033[0m
OK =[$(GREEN) Ok $(ESC)]
FAILED =[$(RED) failed $(ESC)]

CC=g++


CXX ?=g++

INCL=
LDFLAGS=

LIBS=-lgcrypt -lpthread
CFLAGS=-Wall -shared -fPIC -DPIC
CXXFLAGS ?= -O2 -g
CXXFLAGS +=-Wall -shared -fPIC -DPIC


PLUGIN=radiusplugin.so
Expand All @@ -37,18 +29,37 @@ OBJECTS=\
UserPlugin.o \
Config.o

ifeq ($(V),1)
Q=
NQ=true
else
Q=@
NQ=echo
endif

all: $(PLUGIN)

$(PLUGIN): $(OBJECTS)
@echo -e 'BIN: $(GREEN) $(PLUGIN) $(ESC)'
@$(CC) $(CFLAGS) $(OBJECTS) -o $(PLUGIN) $(LDFLAGS) $(LIBS)
@$(NQ) 'CXXLD $@'
$(Q)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(PLUGIN) $(LDFLAGS) $(LIBS)

%.o: %.cpp
@echo -e 'OBJ: $(GREEN) $@ $(ESC)'
@$(CC) $(INCL) $(CFLAGS) -o $@ -c $<
@$(NQ) 'CXX $@'
$(Q)$(CXX) $(INCL) $(CXXFLAGS) -o $@ -c $<

test: $(OBJECTS)
@$(CC) -Wall $(OBJECTS) -o main $(LDFLAGS) $(LIBS)
@$(NQ) 'CXX $@'
$(Q)$(CXX) -Wall $(OBJECTS) -o main $(LDFLAGS) $(LIBS)

clean:
-rm $(PLUGIN) *.o */*.o
rm -f $(PLUGIN) *.o */*.o

# use make dist-gz PLUGIN_VERS=2.2
dist-gz:
@[ x"$(PLUGIN_VERS)" != x"" ] || ( echo 'Need a non empty PLUGIN_VERS value to create versionned tar' && false )
rm -rf ./tmp && mkdir tmp
cd tmp && cvs -z3 -d `cat ../CVS/Root` export -DNOW radiusplugin
mv tmp/radiusplugin tmp/radiusplugin-$(PLUGIN_VERS)
rm -rf tmp/radiusplugin-$(PLUGIN_VERS)/radiusplugin_v2.0a
cd tmp && tar zcf ../radiusplugin-$(PLUGIN_VERS).tar.gz radiusplugin-$(PLUGIN_VERS)
@rm -rf ./tm
8 changes: 4 additions & 4 deletions PluginContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void PluginContext::setVerbosity(int v)
}

/** The getter method for the authentication
* background proccess id.
* background process id.
* @returns The process id.
*/
pid_t PluginContext::getAuthPid(void)
Expand All @@ -168,7 +168,7 @@ pid_t PluginContext::getAuthPid(void)
}

/** The setter method for the authentication
* background proccess id.
* background process id.
* @param The process id.
*/
void PluginContext::setAuthPid(pid_t p)
Expand All @@ -177,7 +177,7 @@ void PluginContext::setAuthPid(pid_t p)
}

/** The getter method for the accounting
* background proccess id.
* background process id.
* @returns The process id.
*/
pid_t PluginContext::getAcctPid(void)
Expand All @@ -186,7 +186,7 @@ pid_t PluginContext::getAcctPid(void)
}

/** The setter method for the accounting
* background proccess id.
* background process id.
* @param The process id.
*/
void PluginContext::setAcctPid(pid_t p)
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ FOR TESTING
-----------

Attention: Some values are hard coded in main.cpp testing, so you can get unexpected values when testing.
For example the framedip is always 10.8.0.100, because it is read from the enviroment variable "ifconfig_pool_remote_ip", which is passed
For example the framedip is always 10.8.0.100, because it is read from the environment variable "ifconfig_pool_remote_ip", which is passed
to the plugin from OpenVPN!
All hard coded variabled:
env1[0]="username=user1";
Expand Down
22 changes: 11 additions & 11 deletions User.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ using namespace std;
class User
{
protected:
string username; /**<The username.*/
string commonname; /**<The commonname.*/
string framedroutes; /**<The framedroutes, they are stored as a string. if there are more routes, they must be delimted by an ';'*/
string username; /**<The username.*/
string commonname; /**<The commonname.*/
string framedroutes; /**<The framedroutes, they are stored as a string. If there are more routes, they must be delimited by an ';'*/
string framedip; /**<The framed ip.*/
string callingstationid; /**<The calling station id, in this case the real ip addres of the client.*/
string callingstationid; /**<The calling station id, in this case the real ip address of the client.*/
string key; /**<A unique key to find the user in a map. */
string statusfilekey; /**<Unique identifier in the status log file (version 1) "commonname,untrusted_ip:untrusted_port"*/
int portnumber; /**<The portnumber.*/
string statusfilekey; /**<Unique identifier in the status log file (version 1) "commonname,untrusted_ip:untrusted_port"*/
int portnumber; /**<The portnumber.*/
time_t acctinteriminterval; /**<The acct interim interval.*/
string untrustedport; /**<The untrusted port number from OpenVPN for a client.*/
//string trustedport; /**<The trusted port number from OpenVPN for a client.*/
//string trustedip; /**<The trusted ip from OpenVPN for a client.*/
Octet * vsabuf; /**<Buffer for all VSA attributes.*/
unsigned int vsabuflen; /**<Length of vsabuf.*/
string sessionid; /**<The user sessionid.*/
//string trustedport; /**<The trusted port number from OpenVPN for a client.*/
//string trustedip; /**<The trusted ip from OpenVPN for a client.*/
Octet * vsabuf; /**<Buffer for all VSA attributes.*/
unsigned int vsabuflen; /**<Length of vsabuf.*/
string sessionid; /**<The user sessionid.*/

public:
User();
Expand Down
2 changes: 1 addition & 1 deletion UserAcct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ int UserAcct::sendStopPacket(PluginContext * context)

if (packet.addRadiusAttribute(&ra2))
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND-ACCT: Fail to add attribute ATTRIB_FramedIP_Adress.\n";
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND-ACCT: Fail to add attribute ATTRIB_FramedIP_Address.\n";
}
if (packet.addRadiusAttribute(&ra3))
{
Expand Down
2 changes: 1 addition & 1 deletion UserAcct.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


/** The class represents a user in the accounting background process. The class is
* derived from the User class. This class defined additonal attributes
* derived from the User class. This class defined additional attributes
* for accounting a user.*/

class UserAcct : public User
Expand Down
2 changes: 1 addition & 1 deletion UserAuth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ UserAuth::~UserAuth()
* - NAS_Port_Type
* - Service_Type.
* @param context The context of the background process.
* @return An integer, 0 if the authentication succeded, else 1.*/
* @return An integer, 0 if the authentication succeeded, else 1.*/
int UserAuth::sendAcceptRequestPacket(PluginContext * context)
{
list<RadiusServer> * serverlist;
Expand Down
24 changes: 12 additions & 12 deletions radiusplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
extern "C"
{

/** The function is needed by the OpenVpn plugin model. The funtion is called
/** The function is needed by the OpenVpn plugin model. The function is called
* when OpenVpn starts. In this case here two background process are
* started. One for authentication and one for accounting. The communication
* between the processes is made via sockets.
Expand All @@ -43,7 +43,7 @@ extern "C"
* and it is undependent from the openvpn process.
* @param The type of plugin, maybe client_connect, client_disconnect, user_auth_pass_verify...
* @param A list of arguments which are set in the configuration file of openvpn in plugin line.
* @param The list of enviromental variables, it is created by the OpenVpn-Process.
* @param The list of environmental variables, it is created by the OpenVpn-Process.
*/


Expand Down Expand Up @@ -320,7 +320,7 @@ extern "C"
}


/** This funtion is called from the OpenVpn process everytime
/** This function is called from the OpenVpn process every time
* a event happens. The function handle the events (plugins)
* AUTH_USER_PASS_VERIFY, CLIENT_CONNECT, CLIENT_DISCONNECT.
* The function reads the information from the envriomental
Expand All @@ -336,8 +336,8 @@ extern "C"
* @param The handle which was allocated in the open function.
* @param The type of plugin, maybe client_conect, client_disconnect, auth_user_pass_verify
* @param A list of arguments which are set in the openvpn configuration file.
* @param The list of enviromental variables, it is created by the OpenVpn-Process.
* @return A interger with the status of the funtion (OPENVPN_PLUGIN_FUNC_SUCCESS or OPENVPN_PLUGIN_FUNC_ERROR).
* @param The list of environmental variables, it is created by the OpenVpn-Process.
* @return An integer with the status of the function (OPENVPN_PLUGIN_FUNC_SUCCESS or OPENVPN_PLUGIN_FUNC_ERROR).
*/

//OPENVPN_EXPORT int
Expand Down Expand Up @@ -377,7 +377,7 @@ extern "C"
UserPlugin *newuser=NULL; /**< A context for an new user.*/
UserPlugin *tmpuser=NULL; /**< A context for an temporary user.*/

string common_name; /**<A string for the common_name from the enviroment.*/
string common_name; /**<A string for the common_name from the environment.*/
string untrusted_ip; /** untrusted_ip for ipv6 support **/


Expand Down Expand Up @@ -579,7 +579,7 @@ extern "C"
context->acctsocketbackgr.send ( DEL_USER );
context->acctsocketbackgr.send ( newuser->getKey() );

//get the responce
//get the response
const int status = context->acctsocketbackgr.recvInt();
if ( status == RESPONSE_SUCCEEDED )
{
Expand Down Expand Up @@ -733,7 +733,7 @@ extern "C"
* if found or NULL otherwise.
* A field in the envp-array looks like: name=user1
* @param The name of the variable.
* @param The array with the enviromental variables.
* @param The array with the environmental variables.
* @return A poniter to the variable value or NULL, if the varaible was not found.
*/
const char * get_env ( const char *name, const char *envp[] )
Expand All @@ -745,7 +745,7 @@ const char * get_env ( const char *name, const char *envp[] )

for ( i = 0; envp[i]; ++i )
{
//compare the enviromental names
//compare the environmental names
if ( !strncmp ( envp[i], name, namelen ) )
{
//if the varibale is found
Expand Down Expand Up @@ -963,7 +963,7 @@ void * auth_user_pass_verify(void * c)
//there must be a username
if ( newuser->getUsername().size() > 0 ) //&& olduser==NULL)
{
//send the informations to the backgorund process
//send the informations to the background process
context->authsocketbackgr.send ( COMMAND_VERIFY );
context->authsocketbackgr.send ( newuser->getUsername() );
context->authsocketbackgr.send ( newuser->getPassword() );
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void * auth_user_pass_verify(void * c)
context->acctsocketbackgr.send ( DEL_USER );
context->acctsocketbackgr.send ( newuser->getKey() );

//get the responce
//get the response
const int status = context->acctsocketbackgr.recvInt();
if ( status == RESPONSE_SUCCEEDED )
{
Expand Down Expand Up @@ -1202,7 +1202,7 @@ void get_user_env(PluginContext * context,const int type,const char * envp[], Us
user->setCommonname ("UNDEF");
}

//rewrite the commonname if OpenVPN use the option username-as-comon-name
//rewrite the commonname if OpenVPN use the option username-as-common-name
if ( context->conf.getUsernameAsCommonname() == true )
{
if ( DEBUG ( context->getVerbosity() ) ) cerr << getTime() << "RADIUS-PLUGIN: FOREGROUND: Commonname set to Username\n";
Expand Down

0 comments on commit f3562cc

Please sign in to comment.