From 82945c29e7554161c48403d4f312d24f256b20a3 Mon Sep 17 00:00:00 2001 From: kkalev Date: Fri, 18 Jan 2002 12:41:20 +0000 Subject: [PATCH] * Add general_ld_library_path directive and set LD_LIBRARY_PATH accordingly (used in snmpfinger and radaclient). * Add general_finger_type directive to determine if we will use snmpfinger in user_finger.php3 * Fix a bug in config.php3 when we have a directive containing ':' * Fix a bug in lib/ldap/change_attrs.php3 that did not allow changing more than one value of a multivalued attribute simultaneously. --- Changelog | 7 +++++++ conf/admin.conf | 6 ++++++ conf/config.php3 | 2 +- htdocs/user_finger.php3 | 13 ++++++++----- htdocs/user_test.php3 | 2 ++ lib/ldap/change_attrs.php3 | 13 +++++++------ lib/sql/change_attrs.php3 | 5 +++-- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index 11de3f0..ef4b06f 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,10 @@ +Ver 1.29: +* Add general_ld_library_path directive and set LD_LIBRARY_PATH accordingly (used in snmpfinger and + radaclient). +* Add general_finger_type directive to determine if we will use snmpfinger in user_finger.php3 +* Fix a bug in config.php3 when we have a directive containing ':' +* Fix a bug in lib/ldap/change_attrs.php3 that did not allow changing more than one value of a + multivalued attribute simultaneously. Ver 1.28: * Make user_delete.php3 print something when a user is deleted * Cache nas hostname lookups in user_accounting diff --git a/conf/admin.conf b/conf/admin.conf index a20566c..472829a 100644 --- a/conf/admin.conf +++ b/conf/admin.conf @@ -18,6 +18,12 @@ general_lib_type: ldap general_user_edit_attrs_file: %{general_base_dir}/conf/user_edit.attrs general_sql_attrs_file: %{general_base_dir}/conf/sql.attrs general_default_file: %{general_base_dir}/conf/default.vals +#general_ld_library_path: /usr/local/snmpd/lib +# +# can be 'snmp' (for snmpfinger) or empty to query the radacct table without first +# querying the nas +# +general_finger_type: snmp general_snmpfinger_bin: %{general_base_dir}/bin/snmpfinger general_radclient_bin: %{general_radiusd_base_dir}/bin/radclient # diff --git a/conf/config.php3 b/conf/config.php3 index 565eb28..2ebc122 100644 --- a/conf/config.php3 +++ b/conf/config.php3 @@ -4,7 +4,7 @@ foreach($ARR as $val) { $val=chop($val); if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val)) continue; - list($key,$v)=split(":[[:space:]]*",$val); + list($key,$v)=split(":[[:space:]]*",$val,2); if (preg_match("/%\{(.+)\}/",$v,$matches)){ $val=$config[$matches[1]]; $v=preg_replace("/%\{$matches[1]\}/",$val,$v); diff --git a/htdocs/user_finger.php3 b/htdocs/user_finger.php3 index a66c222..b8dc33d 100644 --- a/htdocs/user_finger.php3 +++ b/htdocs/user_finger.php3 @@ -48,11 +48,14 @@ if ($link){ $community_data = $config[$community]; $server_name[$i] = $config[$name]; $server_model[$i] = $config[$model]; - $users=exec("$config[general_snmpfinger_bin] $name_data $community_data"); - if (strlen($users)) - $extra = "AND UserName IN ($users)"; - else - $extra = ""; + if ($config[general_ld_library_path] != '') + putenv("LD_LIBRARY_PATH=$config[general_ld_library_path]"); + $extra = ""; + if ($config[general_finger_type] == 'snmp'){ + $users=exec("$config[general_snmpfinger_bin] $name_data $community_data"); + if (strlen($users)) + $extra = "AND UserName IN ($users)"; + } $search = @da_sql_query($link,$config, "SELECT DISTINCT UserName,AcctStartTime,FramedIPAddress,CallingStationId FROM $config[sql_accounting_table] WHERE diff --git a/htdocs/user_test.php3 b/htdocs/user_test.php3 index e28bb68..93da0a8 100644 --- a/htdocs/user_test.php3 +++ b/htdocs/user_test.php3 @@ -65,6 +65,8 @@ if ($test_user == 1){ $port = $config[general_radius_server_port]; $tmp_file = tempnam("$config[general_tmp_dir]",'DA'); $req=file($config[general_auth_request_file]); + if ($config[general_ld_library_path] != '') + putenv("LD_LIBRARY_PATH=$config[general_ld_library_path]"); $comm = $config[general_radclient_bin] . " $server:$port" . ' auth ' . $config[general_radius_server_secret] . ' >' . $tmp_file; $fp = popen("$comm","w"); diff --git a/lib/ldap/change_attrs.php3 b/lib/ldap/change_attrs.php3 index 7a0ea52..23692bd 100644 --- a/lib/ldap/change_attrs.php3 +++ b/lib/ldap/change_attrs.php3 @@ -7,12 +7,14 @@ foreach($show_attrs as $key => $attr){ if ($attrmap["$key"] == 'none') continue; - $i = $j = 0; + $i = 0; + $j = -1; $name = $attrmap["$key"] . $i; while (isset($$name)){ $val = $$name; $i++; + $j++; $name = $attrmap["$key"] . $i; // // if value is the same as the default and the corresponding attribute in ldap does not exist or @@ -32,20 +34,19 @@ // if (($val == $default_vals["$key"] || $val == '') && isset($item_vals["$key"][$j])) - $del[$attrmap["$key"]] = $item_vals["$key"][$j]; + $del[$attrmap["$key"]][] = $item_vals["$key"][$j]; // // else modify the ldap attribute // else{ if (isset($item_vals["$key"][$j])){ - $mod[$attrmap["$key"]] = $item_vals["$key"][$j]; - $add_r[$attrmap["$key"]] = $val; + $mod[$attrmap["$key"]][] = $item_vals["$key"][$j]; + $add_r[$attrmap["$key"]][] = $val; } else{ - $add_r[$attrmap["$key"]] = $val; + $add_r[$attrmap["$key"]][] = $val; } } - $j++; } } if (isset($mod)){ diff --git a/lib/sql/change_attrs.php3 b/lib/sql/change_attrs.php3 index 38c5baa..de8f76e 100644 --- a/lib/sql/change_attrs.php3 +++ b/lib/sql/change_attrs.php3 @@ -10,12 +10,14 @@ if ($link){ foreach($show_attrs as $key => $desc){ if ($attrmap["$key"] == 'none') continue; - $i = $j = 0; + $i = 0; + $j = -1; $name = $attrmap["$key"] . $i; while(isset($$name)){ $val=$$name; $i++; + $j++; $name = $attrmap["$key"] . $i; $sql_attr=$attrmap["$key"]; @@ -49,7 +51,6 @@ if ($link){ if (!$res || !@da_sql_affected_rows($link,$res,$config)) echo "Change failed for attribute $key
\n"; } - $j++; } } } -- 2.39.5