summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9a54d9)
raw | patch | inline | side by side (parent: c9a54d9)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 4 Feb 2008 13:48:11 +0000 (13:48 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 4 Feb 2008 13:48:11 +0000 (13:48 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8738 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/new-gosa-si-client | patch | blob | history |
index c26b4835001f06d95e07d8d858b63f50383098d2..d24ced9d6426c21b331ab2267fa5044ad2233ba5 100755 (executable)
my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file);
my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain);
-my ($client_ip, $client_port, $ldap_enabled, $ldap_config, $pam_config, $nss_config);
+my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config);
my $xml;
my $default_server_key;
my $event_hash;
our $cfg_file;
our $server_address;
our $client_address;
-our $client_mac_address;
our $server_key;
# default variables
"client" =>
{"client_port" => [\$client_port, "20083"],
"client_ip" => [\$client_ip, "0.0.0.0"],
+ "client_mac_address" => [\$client_mac_address, "00:00:00:00:00:00:00"],
"ldap" => [\$ldap_enabled, 1],
"ldap_config" => [\$ldap_config, "/etc/ldap/ldap.conf"],
"pam_config" => [\$pam_config, "/etc/pam_ldap.conf"],
# DESCRIPTION: Uses ioctl to get mac address directly from system.
#===============================================================================
sub get_mac {
- my $ifreq= shift;
- my $result;
- if ($ifreq && length($ifreq) > 0) {
- if($ifreq eq "all") {
- if(defined($server_ip)) {
- $result = &get_local_mac_for_remote_ip($server_ip);
+ my $ifreq= shift;
+ my $result;
+ if ($ifreq && length($ifreq) > 0) {
+ if($ifreq eq "all") {
+ if(defined($server_ip)) {
+ $result = &get_local_mac_for_remote_ip($server_ip);
}
- elsif ($client_mac_address && length($client_mac_address) > 0){
+ elsif ($client_mac_address && length($client_mac_address) > 0){
$result = &client_mac_address;
- }
- else {
- $result = "00:00:00:00:00:00";
- }
- } else {
- my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
-
- # A configured MAC Address should always override a guessed value
- if ($client_mac_address and length($client_mac_address) > 0) {
- $result= $client_mac_address;
- }
-
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
-
- if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
- my ($if, $mac)= unpack 'h36 H12', $ifreq;
-
- if (length($mac) > 0) {
- $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
- $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
- $result = $mac;
- }
- }
- }
- }
- return $result;
+ }
+ else {
+ $result = "00:00:00:00:00:00";
+ }
+ } else {
+ my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
+
+ # A configured MAC Address should always override a guessed value
+ if ($client_mac_address and length($client_mac_address) > 0) {
+ $result= $client_mac_address;
+ }
+ else {
+ socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
+ or die "socket: $!";
+
+ if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
+ my ($if, $mac)= unpack 'h36 H12', $ifreq;
+
+ if (length($mac) > 0) {
+ $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
+ $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
+ $result = $mac;
+ }
+ }
+ }
+ }
+ }
+ return $result;
}
# detect own ip and mac address
my $network_interface= &get_interface_for_ip($client_ip);
+daemon_log("Mac address at this point: $client_mac_address", 1);
+daemon_log("Interface at this point: $network_interface", 1);
$client_mac_address= &get_mac($network_interface);
daemon_log("gosa-si-client ip address detected: $client_ip", 1);
daemon_log("gosa-si-client mac address detected: $client_mac_address", 1);