From 37f357737fc9d056974c59bd6e346a85f938f68b Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 26 Feb 2008 11:06:25 +0000 Subject: [PATCH] Code killing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9126 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-client | 95 ------------- gosa-si/gosa-si-server | 9 -- gosa-si/modules/ArpHandler.pm | 74 ---------- gosa-si/modules/GosaSupportDaemon.pm | 92 ------------ gosa-si/modules/SIPackages.pm | 201 --------------------------- 5 files changed, 471 deletions(-) diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 9aaa5db31..9838f476e 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -249,15 +249,6 @@ sub daemon_log { } close( LOG_HANDLE ); } -#log into syslog -# my ($msg, $level, $facility) = @_; -# if(not defined $msg) {return} -# if(not defined $level) {$level = "info"} -# if(not defined $facility) {$facility = "LOG_DAEMON"} -# openlog($0, "pid,cons,", $facility); -# syslog($level, $msg); -# closelog; -# return; } @@ -575,91 +566,10 @@ sub get_server_addresses { } } -# my $dig_cmd= 'dig +nocomments srv _gosa-si._tcp.'.$domain; -# -# my $output= `$dig_cmd 2>&1`; -# open (PIPE, "$dig_cmd 2>&1 |"); -# while() { -# chomp $_; -# # If it's not a comment -# if($_ =~ m/^[^;]/) { -# my @matches= split /\s+/; -# -# # Push hostname with port -# if($matches[3] eq 'SRV') { -# push @result, $matches[7].':'.$matches[6]; -# } elsif ($matches[3] eq 'A') { -# my $i=0; -# -# # Substitute the hostname with the ip address of the matching A record -# foreach my $host (@result) { -# if ((split /\:/, $host)[0] eq $matches[0]) { -# $result[$i]= $matches[4].':'.(split /\:/, $host)[1]; -# } -# $i++; -# } -# } -# } -# } -# close(PIPE); return @result; } -##=== FUNCTION ================================================================ -## NAME: create_ciphering -## PARAMETERS: passwd - string - used to create ciphering -## RETURNS: cipher - object -## DESCRIPTION: creates a Crypt::Rijndael::MODE_CBC object with passwd as key -##=============================================================================== -#sub create_ciphering { -# my ($passwd) = @_; -# $passwd = substr(md5_hex("$passwd") x 32, 0, 32); -# my $iv = substr(md5_hex('GONICUS GmbH'),0, 16); -# -# #daemon_log("iv: $iv", 7); -# #daemon_log("key: $passwd", 7); -# my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC()); -# $my_cipher->set_iv($iv); -# return $my_cipher; -#} -# -# -#sub create_ciphering { -# my ($passwd) = @_; -# $passwd = substr(md5_hex("$passwd") x 32, 0, 32); -# my $iv = substr(md5_hex('GONICUS GmbH'),0, 16); -# my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC()); -# $my_cipher->set_iv($iv); -# return $my_cipher; -#} -# -# -#sub encrypt_msg { -# my ($msg, $key) = @_; -# my $my_cipher = &create_ciphering($key); -# { -# use bytes; -# $msg = "\0"x(16-length($msg)%16).$msg; -# } -# $msg = $my_cipher->encrypt($msg); -# chomp($msg = &encode_base64($msg)); -# # there are no newlines allowed inside msg -# $msg=~ s/\n//g; -# return $msg; -#} -# -# -#sub decrypt_msg { -# my ($msg, $key) = @_ ; -# $msg = &decode_base64($msg); -# my $my_cipher = &create_ciphering($key); -# $msg = $my_cipher->decrypt($msg); -# $msg =~ s/\0*//g; -# return $msg; -#} - - #=== FUNCTION ================================================================ # NAME: send_msg_hash_to_target # PARAMETERS: msg_hash - hash - xml_hash created with function create_xml_hash @@ -1200,11 +1110,6 @@ daemon_log("$prg started!", 1); system('rm -f /tmp/gosa_si_lock*gosa-si-client*'); # detect ip and mac address and complete host address -#if( inet_aton($client_ip) ){ -#print STDERR "ip: $client_ip\n"; -# $client_ip = inet_ntoa(inet_aton($client_ip)); -#print STDERR "ip: $client_ip\n"; -#} $client_address = $client_ip.":".$client_port; my $network_interface= &get_interface_for_ip($client_ip); $client_mac_address= &get_mac($network_interface); diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 7851f24ae..4086f6b24 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -214,15 +214,6 @@ sub daemon_log { } close( LOG_HANDLE ); } -#log into syslog -# my ($msg, $level, $facility) = @_; -# if(not defined $msg) {return} -# if(not defined $level) {$level = "info"} -# if(not defined $facility) {$facility = "LOG_DAEMON"} -# openlog($0, "pid,cons,", $facility); -# syslog($level, $msg); -# closelog; -# return; } diff --git a/gosa-si/modules/ArpHandler.pm b/gosa-si/modules/ArpHandler.pm index 93261ef91..9a4b6657a 100644 --- a/gosa-si/modules/ArpHandler.pm +++ b/gosa-si/modules/ArpHandler.pm @@ -485,82 +485,8 @@ sub search_ldap_entry { base => $sub_tree, filter => $search_string, ) or &main::daemon_log("cannot perform search at ldap: $@", 1); - #if(defined $msg) { - # print $sub_tree."\t".$search_string."\t"; - # print $msg->count."\n"; - # foreach my $entry ($msg->entries) { $entry->dump; }; - #} } return $msg; } -# $ldap = Net::LDAP->new( "localhost" ) or die "$@"; -# $ldap->bind($bind_phrase, -# password => $password, -# ) ; -# -# switch($arp_sig) { -# case 0 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "ip-changed", -# )} -# case 1 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "mac-not-whitelisted", -# )} -# case 2 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "mac-in-blacklist", -# )} -# case 3 {&add_ldap_entry($ldap, $ldap_base, -# $mac, "new-mac-address", $ip, -# $interface, $desc, -# )} -# case 4 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "unauthorized-arp-request", -# )} -# case 5 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "abusive-number-of-arp-requests", -# )} -# case 6 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "ether-and-arp-mac-differs", -# )} -# case 7 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "flood-detected", -# )} -# case 8 {&add_ldap_entry($ldap, $ldap_base, -# $mac, $ip, "new-system", -# )} -# case 9 {&change_ldap_entry($ldap, $ldap_base, -# $mac, "mac-changed", -# )} -# } -# -# - # ldap search -# my $base_phrase = "dc=gonicus,dc=de"; -# my $filter_phrase = "cn=keinesorge"; -# my $attrs_phrase = "cn macAdress"; -# my $msg_search = $ldap->search( base => $base_phrase, -# filter => $filter_phrase, -# attrs => $attrs_phrase, -# ); -# $msg_search->code && die $msg_search->error; -# -# my @entries = $msg_search->entries; -# my $max = $msg_search->count; -# print "anzahl der entries: $max\n"; -# my $i; -# for ( $i = 0 ; $i < $max ; $i++ ) { -# my $entry = $msg_search->entry ( $i ); -# foreach my $attr ( $entry->attributes ) { -# if( not $attr eq "cn") { -# next; -# } -# print join( "\n ", $attr, $entry->get_value( $attr ) ), "\n\n"; -# } -# } - # - # # ldap add - # - # - # $ldap->unbind; - # exit; 1; diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index cc58491b8..5e6baca9e 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -143,98 +143,6 @@ sub add_content2xml_hash { } -#=== FUNCTION ================================================================ -# NAME: encrypt_msg -# PARAMETERS: msg - string - message to encrypt -# my_cipher - ref - reference to a Crypt::Rijndael object -# RETURNS: crypted_msg - string - crypted message -# DESCRIPTION: crypts the incoming message with the Crypt::Rijndael module -#=============================================================================== -#sub encrypt_msg { -# my ($msg, $key) = @_; -# my $my_cipher = &create_ciphering($key); -# { -# use bytes; -# $msg = "\0"x(16-length($msg)%16).$msg; -# } -# $msg = $my_cipher->encrypt($msg); -# chomp($msg = &encode_base64($msg)); -# # there are no newlines allowed inside msg -# $msg=~ s/\n//g; -# return $msg; -#} - - -#=== FUNCTION ================================================================ -# NAME: decrypt_msg -# PARAMETERS: crypted_msg - string - message to decrypt -# my_cipher - ref - reference to a Crypt::Rijndael object -# RETURNS: msg - string - decrypted message -# DESCRIPTION: decrypts the incoming message with the Crypt::Rijndael module -#=============================================================================== -#sub decrypt_msg { -# my ($msg, $my_cipher) = @_ ; -# -# if(defined $msg && defined $my_cipher) { -# $msg = &decode_base64($msg); -# } -# $msg = $my_cipher->decrypt($msg); -# $msg =~ s/\0*//g; -# return $msg; -# my ($msg, $key) = @_ ; -# $msg = &decode_base64($msg); -# my $my_cipher = &create_ciphering($key); -# $msg = $my_cipher->decrypt($msg); -# $msg =~ s/\0*//g; -# return $msg; -#} - - -#=== FUNCTION ================================================================ -# NAME: create_ciphering -# PARAMETERS: passwd - string - used to create ciphering -# RETURNS: cipher - object -# DESCRIPTION: creates a Crypt::Rijndael::MODE_CBC object with passwd as key -#=============================================================================== -#sub create_ciphering { -# my ($passwd) = @_; -# $passwd = substr(md5_hex("$passwd") x 32, 0, 32); -# my $iv = substr(md5_hex('GONICUS GmbH'),0, 16); -# -# #daemon_log("iv: $iv", 7); -# #daemon_log("key: $passwd", 7); -# my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC()); -# $my_cipher->set_iv($iv); -# return $my_cipher; -#} - - -#=== FUNCTION ================================================================ -# NAME: open_socket -# PARAMETERS: PeerAddr string something like 192.168.1.1 or 192.168.1.1:10000 -# [PeerPort] string necessary if port not appended by PeerAddr -# RETURNS: socket IO::Socket::INET -# DESCRIPTION: open a socket to PeerAddr -#=============================================================================== -#sub open_socket { -# my ($PeerAddr, $PeerPort) = @_ ; -# if(defined($PeerPort)){ -# $PeerAddr = $PeerAddr.":".$PeerPort; -# } -# my $socket; -# $socket = new IO::Socket::INET(PeerAddr => $PeerAddr, -# Porto => "tcp", -# Type => SOCK_STREAM, -# Timeout => 5, -# ); -# if(not defined $socket) { -# return; -# } -# &daemon_log("open_socket: $PeerAddr", 7); -# return $socket; -#} - - sub get_time { my ($seconds, $minutes, $hours, $monthday, $month, $year, $weekday, $yearday, $sommertime) = localtime(time); diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index c0d4ccbd4..492b109a0 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -183,61 +183,6 @@ sub get_module_info { } -#sub daemon_log { -# my ($msg, $level) = @_ ; -# &main::daemon_log($msg, $level); -# return; -#} -# - -#sub do_wake { -# my $host = shift; -# my $ipaddr = shift || '255.255.255.255'; -# my $port = getservbyname('discard', 'udp'); -# -# my ($raddr, $them, $proto); -# my ($hwaddr, $hwaddr_re, $pkt); -# -# # get the hardware address (ethernet address) -# -# $hwaddr_re = join(':', ('[0-9A-Fa-f]{1,2}') x 6); -# if ($host =~ m/^$hwaddr_re$/) { -# $hwaddr = $host; -# } else { -# # $host is not a hardware address, try to resolve it -# my $ip_re = join('\.', ('([0-9]|[1-9][0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))') x 4); -# my $ip_addr; -# if ($host =~ m/^$ip_re$/) { -# $ip_addr = $host; -# } else { -# my $h; -# unless ($h = gethost($host)) { -# return undef; -# } -# $ip_addr = inet_ntoa($h->addr); -# } -# } -# -# # Generate magic sequence -# foreach (split /:/, $hwaddr) { -# $pkt .= chr(hex($_)); -# } -# $pkt = chr(0xFF) x 6 . $pkt x 16; -# -# # Allocate socket and send packet -# -# $raddr = gethostbyname($ipaddr)->addr; -# $them = pack_sockaddr_in($port, $raddr); -# $proto = getprotobyname('udp'); -# -# socket(S, AF_INET, SOCK_DGRAM, $proto) or die "socket : $!"; -# setsockopt(S, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt : $!"; -# -# send(S, $pkt, 0, $them) or die "send : $!"; -# close S; -#} - - #=== FUNCTION ================================================================ # NAME: read_configfile # PARAMETERS: cfg_file - string - @@ -499,52 +444,6 @@ sub process_incoming_msg { } -#=== FUNCTION ================================================================ -# NAME: got_ping -# PARAMETERS: msg_hash - hash - hash from function create_xml_hash -# RETURNS: nothing -# DESCRIPTION: process this incoming message -#=============================================================================== -#sub got_ping { -# my ($msg_hash) = @_; -# -# my $source = @{$msg_hash->{source}}[0]; -# my $target = @{$msg_hash->{target}}[0]; -# my $header = @{$msg_hash->{header}}[0]; -# my $session_id = @{$msg_hash->{'session_id'}}[0]; -# my $act_time = &get_time; -# my @out_msg_l; -# my $out_msg; -# -# # check known_clients_db -# my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$source'"; -# my $query_res = $main::known_clients_db->select_dbentry( $sql_statement ); -# if( 1 == keys %{$query_res} ) { -# my $sql_statement= "UPDATE known_clients ". -# "SET status='$header', timestamp='$act_time' ". -# "WHERE hostname='$source'"; -# my $res = $main::known_clients_db->update_dbentry( $sql_statement ); -# } -# -# # check known_server_db -# $sql_statement = "SELECT * FROM known_server WHERE hostname='$source'"; -# $query_res = $main::known_server_db->select_dbentry( $sql_statement ); -# if( 1 == keys %{$query_res} ) { -# my $sql_statement= "UPDATE known_server ". -# "SET status='$header', timestamp='$act_time' ". -# "WHERE hostname='$source'"; -# my $res = $main::known_server_db->update_dbentry( $sql_statement ); -# } -# -# # create out_msg -# my $out_hash = &create_xml_hash($header, $source, "GOSA"); -# &add_content2xml_hash($out_hash, "session_id", $session_id); -# $out_msg = &create_xml_string($out_hash); -# push(@out_msg_l, $out_msg); -# -# return @out_msg_l; -#} - #=== FUNCTION ================================================================ # NAME: new_passwd # PARAMETERS: msg_hash - ref - hash from function create_xml_hash @@ -981,54 +880,6 @@ sub hardware_config { } } } - # need to fill it to LDAP - #$entry->add(gotoHardwareChecksum => $gotoHardwareChecksum); - #if($entry->update($ldap)) { - # &main::daemon_log("gotoHardwareChecksum $gotoHardwareChecksum was added to LDAP", 4); - #} - - ## Look if there another host with this checksum to use the hardware config - #$mesg = $ldap->search( - # base => $ldap_base, - # scope => 'sub', - # filter => "(&(objectClass=GOhard)(gotoHardwareChecksum=$gotoHardwareChecksum))" - #); - - #if($mesg->count>1) { - # my $clone_entry= $mesg->entry(0); - # $entry->changetype("modify"); - # foreach my $attribute ( - # "gotoSndModule", "ghNetNic", "gotoXResolution", "ghSoundAdapter", "ghCpuType", "gotoXkbModel", - # "ghGfxAdapter", "gotoXMousePort", "ghMemSize", "gotoXMouseType", "ghUsbSupport", "gotoXHsync", - # "gotoXDriver", "gotoXVsync", "gotoXMonitor") { - # my $value= $clone_entry->get_value($attribute); - # if(defined($value)) { - # if(defined($entry->get_value($attribute))) { - # $entry->delete($attribute); - # } - # &main::daemon_log("Adding attribute $attribute with value $value",1); - # $entry->add($attribute => $value); - # } - # } - # foreach my $attribute ( - # "gotoModules", "ghScsiDev", "ghIdeDev") { - # my $array= $clone_entry->get_value($attribute, 'as_ref' => 1); - # if(defined($array)) { - # if(defined($entry->get_value($attribute))) { - # $entry->delete($attribute); - # } - # foreach my $array_entry (@{$array}) { - # $entry->add($attribute => $array_entry); - # } - # } - - # } - # if($entry->update($ldap)) { - # &main::daemon_log("Added Hardware configuration to LDAP", 4); - # } - - #} - # Assemble data package my %data = (); @@ -1093,56 +944,4 @@ sub server_matches { return $result; } - -##=== FUNCTION ================================================================ -## NAME: execute_actions -## PARAMETERS: msg_hash - hash - hash from function create_xml_hash -## RETURNS: nothing -## DESCRIPTION: invokes the script specified in msg_hash which is located under -## /etc/gosad/actions -##=============================================================================== -#sub execute_actions { -# my ($msg_hash) = @_ ; -# my $configdir= '/etc/gosad/actions/'; -# my $result; -# -# my $header = @{$msg_hash->{header}}[0]; -# my $source = @{$msg_hash->{source}}[0]; -# my $target = @{$msg_hash->{target}}[0]; -# -# if((not defined $source) -# && (not defined $target) -# && (not defined $header)) { -# &main::daemon_log("ERROR: Entries missing in XML msg for gosad actions under /etc/gosad/actions"); -# } else { -# my $parameters=""; -# my @params = @{$msg_hash->{$header}}; -# my $params = join(", ", @params); -# &main::daemon_log("execute_actions: got parameters: $params", 5); -# -# if (@params) { -# foreach my $param (@params) { -# my $param_value = (&get_content_from_xml_hash($msg_hash, $param))[0]; -# &main::daemon_log("execute_actions: parameter -> value: $param -> $param_value", 7); -# $parameters.= " ".$param_value; -# } -# } -# -# my $cmd= $configdir.$header."$parameters"; -# &main::daemon_log("execute_actions: executing cmd: $cmd", 7); -# $result= ""; -# open(PIPE, "$cmd 2>&1 |"); -# while() { -# $result.=$_; -# } -# close(PIPE); -# } -# -# # process the event result -# -# -# return; -#} -# - 1; -- 2.30.2