From: kkalev Date: Sat, 21 Sep 2002 13:38:23 +0000 (+0000) Subject: Add support for realm in username and allow for realm striping in the web pages and... X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=98ede2d596108058fd3b4961be2773e1a211f7df;p=freeradius-dialup-admin.git Add support for realm in username and allow for realm striping in the web pages and in log_badlogins --- diff --git a/Changelog b/Changelog index 16101e7..af443d6 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ Ver 1.60: * In the buttons toolbar Edit User should not be clickable. * Add an arrow gif in htdocs/images to be used in the buttons page when adding multiple finger pages * In snmpfinger also consider '-' as a valid character for a username +* Add support for realm in username and allow for realm striping in the web pages and in log_badlogins Ver 1.59: * Small html fixes in user_edit.php3 and password.php3 * Show number of failed logins in the last 7 days in the user admin page diff --git a/bin/log_badlogins b/bin/log_badlogins index 2184406..8f50af1 100755 --- a/bin/log_badlogins +++ b/bin/log_badlogins @@ -19,8 +19,13 @@ while(){ $sql_password = $val if ($key eq 'sql_password'); $sql_database = $val if ($key eq 'sql_database'); $sql_accounting_table = $val if ($key eq 'sql_accounting_table'); + $realm_strip = $val if ($key eq 'general_strip_realms'); + $realm_del = $val if ($key eq 'general_realm_delimiter'); + $realm_for = $val if ($key eq 'general_realm_format'); } close CONF; +$realm_del = '@' if ($realm_del eq ''); +$realm_for = 'suffix' if ($realm_for eq ''); $pass = ($sql_password ne '') ? "-p$sql_password" : ''; open LOG, "<$file" @@ -78,6 +83,12 @@ for(;;){ $addr = gethostbyname $nas; ($a,$b,$c,$d)=unpack('C4',$addr); $addr = "$a.$b.$c.$d"; + if ($user ne '' && $realm_strip eq 'yes'){ + ($one,$two) = (split /$realm_del/, $user)[0,1]; + if ($two ne ''){ + $user = ($realm_for eq 'suffix') ? $one : $two; + } + } open TMP, ">$tmpfile" or die "Could not open temporary file\n"; print TMP "INSERT INTO $sql_accounting_table (UserName,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$addr','$port','$time','$time','0','0','0','$caller','$cause');"; diff --git a/conf/admin.conf b/conf/admin.conf index 1d4c566..26509b0 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -24,6 +24,23 @@ general_use_session: no general_most_recent_fl: 30 # +# Realm setup +# +# Set general_strip_realms to yes in order to stip realms from usernames. +# By default realms are not striped +#general_strip_realms : yes +# +# The delimiter used in realms. Default is @ +# +general_realm_delimiter: @ +# +# The format of the realms. Can be either suffix (realm is after the username) +# or prefix (realm is before the username). Default is suffix +# +general_realm_format: suffix +# + + general_ldap_attrmap: %{general_radiusd_base_dir}/etc/raddb/ldap.attrmap general_sql_attrmap: %{general_base_dir}/conf/sql.attrmap general_extra_ldap_attrmap: %{general_base_dir}/conf/extra.ldap-attrmap diff --git a/conf/config.php3 b/conf/config.php3 index 1fc7124..9c0f375 100644 --- a/conf/config.php3 +++ b/conf/config.php3 @@ -26,4 +26,11 @@ if ($use_session == 0 && $config[general_use_session] == 'yes'){ // Start session @session_start(); } +if ($login != '' && $config[general_strip_realms] == 'yes'){ + $realm_del = ($config[general_realm_delimiter] != '') ? $config[general_realm_delimiter] : '@'; + $realm_for = ($config[general_realm_format] != '') ? $config[general_realm_format] : 'suffix'; + $new = explode($realm_del,$login,2); + if (count($new) == 2) + $login = ($realm_for == 'suffix') ? $new[0] : $new[1]; +} ?>