summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d40bfa)
raw | patch | inline | side by side (parent: 2d40bfa)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Jun 2008 08:20:22 +0000 (08:20 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 3 Jun 2008 08:20:22 +0000 (08:20 +0000) |
* under construction
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11163 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11163 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index e7ae82f0ea03ba1b0d79832fc3834fded0b744ac..ae375d7d4368ebbc073a25337b3375483a28dd85 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
}
+# moved to GosaSupportDaemon: 03-06-2008: rettenbe
#=== FUNCTION ================================================================
# NAME: get_ip
# PARAMETERS: interface name (i.e. eth0)
# RETURNS: (ip address)
# DESCRIPTION: Uses ioctl to get ip address directly from system.
#===============================================================================
-sub get_ip {
- my $ifreq= shift;
- my $result= "";
- my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
- my $proto= getprotobyname('ip');
-
- socket SOCKET, PF_INET, SOCK_DGRAM, $proto
- or die "socket: $!";
-
- if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
- my ($if, $sin) = unpack 'a16 a16', $ifreq;
- my ($port, $addr) = sockaddr_in $sin;
- my $ip = inet_ntoa $addr;
-
- if ($ip && length($ip) > 0) {
- $result = $ip;
- }
- }
-
- return $result;
-}
+#sub get_ip {
+# my $ifreq= shift;
+# my $result= "";
+# my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
+# my $proto= getprotobyname('ip');
+#
+# socket SOCKET, PF_INET, SOCK_DGRAM, $proto
+# or die "socket: $!";
+#
+# if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
+# my ($if, $sin) = unpack 'a16 a16', $ifreq;
+# my ($port, $addr) = sockaddr_in $sin;
+# my $ip = inet_ntoa $addr;
+#
+# if ($ip && length($ip) > 0) {
+# $result = $ip;
+# }
+# }
+#
+# return $result;
+#}
sub get_local_ip_for_remote_ip {
$header = @{$msg_hash->{'header'}}[0];
$target = @{$msg_hash->{'target'}}[0];
$source = @{$msg_hash->{'source'}}[0];
+ my ($target_ip, $target_port) = split(':', $target);
+ my $server_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
# target and source is equal to GOSA -> process here
if (not $done) {
index 1b0997dd2453e6273c89cb38df472860de192891..0e551f43fbd2aae9433ec59e47b6aef2ceea6445 100644 (file)
return $result;
}
+# moved to GosaSupportDaemon: 03-06-2008: rettenbe
#=== FUNCTION ================================================================
# NAME: get_interfaces
# PARAMETERS: none
# RETURNS: (list of interfaces)
# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
#===============================================================================
-sub get_interfaces {
- my @result;
- my $PROC_NET_DEV= ('/proc/net/dev');
-
- open(PROC_NET_DEV, "<$PROC_NET_DEV")
- or die "Could not open $PROC_NET_DEV";
-
- my @ifs = <PROC_NET_DEV>;
-
- close(PROC_NET_DEV);
-
- # Eat first two line
- shift @ifs;
- shift @ifs;
-
- chomp @ifs;
- foreach my $line(@ifs) {
- my $if= (split /:/, $line)[0];
- $if =~ s/^\s+//;
- push @result, $if;
- }
-
- return @result;
-}
+#sub get_interfaces {
+# my @result;
+# my $PROC_NET_DEV= ('/proc/net/dev');
+#
+# open(PROC_NET_DEV, "<$PROC_NET_DEV")
+# or die "Could not open $PROC_NET_DEV";
+#
+# my @ifs = <PROC_NET_DEV>;
+#
+# close(PROC_NET_DEV);
+#
+# # Eat first two line
+# shift @ifs;
+# shift @ifs;
+#
+# chomp @ifs;
+# foreach my $line(@ifs) {
+# my $if= (split /:/, $line)[0];
+# $if =~ s/^\s+//;
+# push @result, $if;
+# }
+#
+# return @result;
+#}
#=== FUNCTION ================================================================
# NAME: get_mac
index 68056c43c4338a43d236674ed62c03600ef17153..37942071659adb0d04de2d4c3a7e4f25dcf76c46 100644 (file)
END {}
my ($server_ip, $server_port, $ClientPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface);
-my ($bus_activ, $bus_key, $bus_ip, $bus_port);
+#my ($bus_activ, $bus_key, $bus_ip, $bus_port);
my $server;
my $network_interface;
-my $no_bus;
+#my $no_bus;
my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret);
my $mesg;
my %cfg_defaults = (
-"bus" => {
- "activ" => [\$bus_activ, "on"],
- "key" => [\$bus_key, ""],
- "ip" => [\$bus_ip, ""],
- "port" => [\$bus_port, "20080"],
- },
+#"bus" => {
+# "activ" => [\$bus_activ, "on"],
+# "key" => [\$bus_key, ""],
+# "ip" => [\$bus_ip, ""],
+# "port" => [\$bus_port, "20080"],
+# },
"server" => {
"ip" => [\$server_ip, "0.0.0.0"],
"mac-address" => [\$main::server_mac_address, "00:00:00:00:00"],
$main::server_address = $server_address;
-if( inet_aton($bus_ip) ){ $bus_ip = inet_ntoa(inet_aton($bus_ip)); }
-######################################################
-# to change
-if( $bus_ip eq "127.0.1.1" ) { $bus_ip = "127.0.0.1" }
-######################################################
-my $bus_address = "$bus_ip:$bus_port";
-$main::bus_address = $bus_address;
-
-
-my $hostkey = &create_passwd;
-my $res = $main::known_server_db->add_dbentry( {table=>$main::known_server_tn,
- primkey=>['hostname'],
- hostname=>$main::server_address,
- status=>'myself',
- hostkey=>$hostkey,
- timestamp=>&get_time(),
- } );
-if (not $res == 0) {
- &main::daemon_log("0 ERROR: cannot add server to known_server_db: $res", 1);
-} else {
- &main::daemon_log("0 INFO: '$main::server_address' successfully added to known_server_db", 5);
-}
+#if( inet_aton($bus_ip) ){ $bus_ip = inet_ntoa(inet_aton($bus_ip)); }
+#######################################################
+## to change
+#if( $bus_ip eq "127.0.1.1" ) { $bus_ip = "127.0.0.1" }
+#######################################################
+#my $bus_address = "$bus_ip:$bus_port";
+#$main::bus_address = $bus_address;
+
+
+#my $hostkey = &create_passwd;
+#my $res = $main::known_server_db->add_dbentry( {table=>$main::known_server_tn,
+# primkey=>['hostname'],
+# hostname=>$main::server_address,
+# status=>'myself',
+# hostkey=>$hostkey,
+# timestamp=>&get_time(),
+# } );
+#if (not $res == 0) {
+# &main::daemon_log("0 ERROR: cannot add server to known_server_db: $res", 1);
+#} else {
+# &main::daemon_log("0 INFO: '$main::server_address' successfully added to known_server_db", 5);
+#}
}
+# moved to GosaSupportDaemon: 03-06-2008 rettenbe
#=== FUNCTION ================================================================
# NAME: get_interface_for_ip
# PARAMETERS: ip address (i.e. 192.168.0.1)
# RETURNS: array: list of interfaces if ip=0.0.0.0, matching interface if found, undef else
# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
#===============================================================================
-sub get_interface_for_ip {
- my $result;
- my $ip= shift;
- if ($ip && length($ip) > 0) {
- my @ifs= &get_interfaces();
- if($ip eq "0.0.0.0") {
- $result = "all";
- } else {
- foreach (@ifs) {
- my $if=$_;
- if(&main::get_ip($if) eq $ip) {
- $result = $if;
- }
- }
- }
- }
- return $result;
-}
+#sub get_interface_for_ip {
+# my $result;
+# my $ip= shift;
+# if ($ip && length($ip) > 0) {
+# my @ifs= &get_interfaces();
+# if($ip eq "0.0.0.0") {
+# $result = "all";
+# } else {
+# foreach (@ifs) {
+# my $if=$_;
+# if(&main::get_ip($if) eq $ip) {
+# $result = $if;
+# }
+# }
+# }
+# }
+# return $result;
+#}
+# moved to GosaSupportDaemon: 03-06-2008 rettenbe
#=== FUNCTION ================================================================
# NAME: get_interfaces
# PARAMETERS: none
# RETURNS: (list of interfaces)
# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
#===============================================================================
-sub get_interfaces {
- my @result;
- my $PROC_NET_DEV= ('/proc/net/dev');
-
- open(PROC_NET_DEV, "<$PROC_NET_DEV")
- or die "Could not open $PROC_NET_DEV";
-
- my @ifs = <PROC_NET_DEV>;
-
- close(PROC_NET_DEV);
-
- # Eat first two line
- shift @ifs;
- shift @ifs;
-
- chomp @ifs;
- foreach my $line(@ifs) {
- my $if= (split /:/, $line)[0];
- $if =~ s/^\s+//;
- push @result, $if;
- }
-
- return @result;
-}
+#sub get_interfaces {
+# my @result;
+# my $PROC_NET_DEV= ('/proc/net/dev');
+#
+# open(PROC_NET_DEV, "<$PROC_NET_DEV")
+# or die "Could not open $PROC_NET_DEV";
+#
+# my @ifs = <PROC_NET_DEV>;
+#
+# close(PROC_NET_DEV);
+#
+# # Eat first two line
+# shift @ifs;
+# shift @ifs;
+#
+# chomp @ifs;
+# foreach my $line(@ifs) {
+# my $if= (split /:/, $line)[0];
+# $if =~ s/^\s+//;
+# push @result, $if;
+# }
+#
+# return @result;
+#}
#=== FUNCTION ================================================================
# NAME: get_mac
# RETURNS: nothing
# DESCRIPTION: creates an entry in known_daemons and send a 'here_i_am' msg to bus
#===============================================================================
-sub register_at_bus {
-
- # add bus to known_server_db
- my $res = $main::known_server_db->add_dbentry( {table=>'known_server',
- primkey=>['hostname'],
- hostname=>$bus_address,
- status=>'bus',
- hostkey=>$bus_key,
- timestamp=>&get_time,
- } );
- my $msg_hash = &create_xml_hash("here_i_am", $server_address, $bus_address);
- my $msg = &create_xml_string($msg_hash);
-
- &main::send_msg_to_target($msg, $bus_address, $bus_key, "here_i_am");
- return $msg;
-}
+#sub register_at_bus {
+#
+# # add bus to known_server_db
+# my $res = $main::known_server_db->add_dbentry( {table=>'known_server',
+# primkey=>['hostname'],
+# hostname=>$bus_address,
+# status=>'bus',
+# hostkey=>$bus_key,
+# timestamp=>&get_time,
+# } );
+# my $msg_hash = &create_xml_hash("here_i_am", $server_address, $bus_address);
+# my $msg = &create_xml_string($msg_hash);
+#
+# &main::send_msg_to_target($msg, $bus_address, $bus_key, "here_i_am");
+# return $msg;
+#}
index c744f9b4c5e45e1f8b6ffe123d61b51148b5f3f7..c0fe1ce90e0ac9cfdd63af30eff1f72c1d149625 100644 (file)
}
}
+# moved to GosaSupportDaemon: 03-06-2008: rettenbe
#=== FUNCTION ================================================================
# NAME: get_interface_for_ip
# PARAMETERS: ip address (i.e. 192.168.0.1)
# RETURNS: array: list of interfaces if ip=0.0.0.0, matching interface if found, undef else
# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
#===============================================================================
-sub get_interface_for_ip {
- my $result;
- my $ip= shift;
- if ($ip && length($ip) > 0) {
- my @ifs= &get_interfaces();
- if($ip eq "0.0.0.0") {
- $result = "all";
- } else {
- foreach (@ifs) {
- my $if=$_;
- if(get_ip($if) eq $ip) {
- $result = $if;
- }
- }
- }
- }
- return $result;
-}
-
+#sub get_interface_for_ip {
+# my $result;
+# my $ip= shift;
+# if ($ip && length($ip) > 0) {
+# my @ifs= &get_interfaces();
+# if($ip eq "0.0.0.0") {
+# $result = "all";
+# } else {
+# foreach (@ifs) {
+# my $if=$_;
+# if(get_ip($if) eq $ip) {
+# $result = $if;
+# }
+# }
+# }
+# }
+# return $result;
+#}
+
+# moved to GosaSupportDaemon: 03-06-2008: rettenbe
#=== FUNCTION ================================================================
# NAME: get_interfaces
# PARAMETERS: none
# RETURNS: (list of interfaces)
# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
#===============================================================================
-sub get_interfaces {
- my @result;
- my $PROC_NET_DEV= ('/proc/net/dev');
-
- open(PROC_NET_DEV, "<$PROC_NET_DEV")
- or die "Could not open $PROC_NET_DEV";
-
- my @ifs = <PROC_NET_DEV>;
-
- close(PROC_NET_DEV);
-
- # Eat first two line
- shift @ifs;
- shift @ifs;
-
- chomp @ifs;
- foreach my $line(@ifs) {
- my $if= (split /:/, $line)[0];
- $if =~ s/^\s+//;
- push @result, $if;
- }
-
- return @result;
-}
+#sub get_interfaces {
+# my @result;
+# my $PROC_NET_DEV= ('/proc/net/dev');
+#
+# open(PROC_NET_DEV, "<$PROC_NET_DEV")
+# or die "Could not open $PROC_NET_DEV";
+#
+# my @ifs = <PROC_NET_DEV>;
+#
+# close(PROC_NET_DEV);
+#
+# # Eat first two line
+# shift @ifs;
+# shift @ifs;
+#
+# chomp @ifs;
+# foreach my $line(@ifs) {
+# my $if= (split /:/, $line)[0];
+# $if =~ s/^\s+//;
+# push @result, $if;
+# }
+#
+# return @result;
+#}
#=== FUNCTION ================================================================
# NAME: get_mac
# 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") {
- $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 ($gosa_mac_address and length($gosa_mac_address) > 0) {
- $result= $gosa_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;
- }
- }
+ my $ifreq= shift;
+ my $result;
+ if ($ifreq && length($ifreq) > 0) {
+ if($ifreq eq "all") {
+ $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 ($gosa_mac_address and length($gosa_mac_address) > 0) {
+ $result= $gosa_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;
+ }
+ return $result;
}
+# moved to GosaSupportDaemon: 03-06-2008: rettenbe
#=== FUNCTION ================================================================
# NAME: get_ip
# PARAMETERS: interface name (i.e. eth0)
# RETURNS: (ip address)
# DESCRIPTION: Uses ioctl to get ip address directly from system.
#===============================================================================
-sub get_ip {
- my $ifreq= shift;
- my $result= "";
- my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
- my $proto= getprotobyname('ip');
-
- socket SOCKET, PF_INET, SOCK_DGRAM, $proto
- or die "socket: $!";
-
- if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
- my ($if, $sin) = unpack 'a16 a16', $ifreq;
- my ($port, $addr) = sockaddr_in $sin;
- my $ip = inet_ntoa $addr;
-
- if ($ip && length($ip) > 0) {
- $result = $ip;
- }
- }
-
- return $result;
-}
+#sub get_ip {
+# my $ifreq= shift;
+# my $result= "";
+# my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
+# my $proto= getprotobyname('ip');
+#
+# socket SOCKET, PF_INET, SOCK_DGRAM, $proto
+# or die "socket: $!";
+#
+# if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
+# my ($if, $sin) = unpack 'a16 a16', $ifreq;
+# my ($port, $addr) = sockaddr_in $sin;
+# my $ip = inet_ntoa $addr;
+#
+# if ($ip && length($ip) > 0) {
+# $result = $ip;
+# }
+# }
+#
+# return $result;
+#}
#=== FUNCTION ================================================================
index d2296f0508774c8b1318e1892c6bda1228f7812a..769c03b28439e9168da1af8599268743187d0bed 100644 (file)
"get_logged_in_users",
"import_events",
"del_doubles",
+ "get_ip",
+ "get_interface_for_ip",
+ "get_interfaces",
);
@EXPORT = @functions;
use strict;
}
+#=== FUNCTION ================================================================
+# NAME: get_ip
+# PARAMETERS: interface name (i.e. eth0)
+# RETURNS: (ip address)
+# DESCRIPTION: Uses ioctl to get ip address directly from system.
+#===============================================================================
+sub get_ip {
+ my $ifreq= shift;
+ my $result= "";
+ my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
+ my $proto= getprotobyname('ip');
+
+ socket SOCKET, PF_INET, SOCK_DGRAM, $proto
+ or die "socket: $!";
+
+ if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
+ my ($if, $sin) = unpack 'a16 a16', $ifreq;
+ my ($port, $addr) = sockaddr_in $sin;
+ my $ip = inet_ntoa $addr;
+
+ if ($ip && length($ip) > 0) {
+ $result = $ip;
+ }
+ }
+
+ return $result;
+}
+
+
+#=== FUNCTION ================================================================
+# NAME: get_interface_for_ip
+# PARAMETERS: ip address (i.e. 192.168.0.1)
+# RETURNS: array: list of interfaces if ip=0.0.0.0, matching interface if found, undef else
+# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
+#===============================================================================
+sub get_interface_for_ip {
+ my $result;
+ my $ip= shift;
+ if ($ip && length($ip) > 0) {
+ my @ifs= &get_interfaces();
+ if($ip eq "0.0.0.0") {
+ $result = "all";
+ } else {
+ foreach (@ifs) {
+ my $if=$_;
+ if(&get_ip($if) eq $ip) {
+ $result = $if;
+ }
+ }
+ }
+ }
+ return $result;
+}
+
+#=== FUNCTION ================================================================
+# NAME: get_interfaces
+# PARAMETERS: none
+# RETURNS: (list of interfaces)
+# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
+#===============================================================================
+sub get_interfaces {
+ my @result;
+ my $PROC_NET_DEV= ('/proc/net/dev');
+
+ open(PROC_NET_DEV, "<$PROC_NET_DEV")
+ or die "Could not open $PROC_NET_DEV";
+
+ my @ifs = <PROC_NET_DEV>;
+
+ close(PROC_NET_DEV);
+
+ # Eat first two line
+ shift @ifs;
+ shift @ifs;
+
+ chomp @ifs;
+ foreach my $line(@ifs) {
+ my $if= (split /:/, $line)[0];
+ $if =~ s/^\s+//;
+ push @result, $if;
+ }
+
+ return @result;
+}
+
+
1;