summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 780d7d5)
raw | patch | inline | side by side (parent: 780d7d5)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 5 Sep 2008 09:40:36 +0000 (09:40 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 5 Sep 2008 09:40:36 +0000 (09:40 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12368 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history | |
gosa-si/server/events/clMessages.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index b0b4ffbda0538ff09ae0daddd10b52694cc07919..8bc1100fd8952f69ad42795e76a594fea4ae8587 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
use Net::LDAP;
use Net::LDAP::Util qw(:escape);
use Time::HiRes qw( usleep);
-use DateTime;
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
our $opsi_client;
our $opsi_url;
+# Lifetime of logged in user information. If no update information comes after n seconds,
+# the user is expeceted to be no longer logged in or the host is no longer running. Because
+# of this, the user is deleted from login_users_db
+our $logged_in_user_date_of_expiry = 600;
%cfg_defaults = (
},
"ClientPackages" => {
"key" => [\$ClientPackages_key, "none"],
+ "user-date-of-expiry" => [\$logged_in_user_date_of_expiry, 600],
},
"ServerPackages"=> {
"address" => [\$foreign_server_string, ""],
index ff9da894e5868b2aed795fe82f3508452d1a876b..47a077b7e158248cba816ab88881f364734943b9 100644 (file)
"inform_all_other_si_server",
"read_configfile",
"check_opsi_res",
+ "calc_timestamp",
);
@EXPORT = @functions;
use strict;
use XML::Simple;
use Data::Dumper;
use Net::DNS;
+use DateTime;
my $op_hash = {
return 0;
}
+sub calc_timestamp {
+ my ($timestamp, $operation, $value) = @_ ;
+ my $res_timestamp = 0;
+
+ $value = int($value);
+ $timestamp = int($timestamp);
+ $timestamp =~ /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
+ my $dt = DateTime->new( year => $1,
+ month => $2,
+ day => $3,
+ hour => $4,
+ minute => $5,
+ second => $6,
+ );
+
+ if ($operation eq "plus" || $operation eq "+") {
+ $dt->add( seconds => $value);
+ $res_timestamp = $dt->ymd('').$dt->hms('');
+ }
+
+ if ($operation eq "minus" || $operation eq "-") {
+ $dt->subtract(seconds => $value);
+ $res_timestamp = $dt->ymd('').$dt->hms('');
+ }
+
+ return $res_timestamp;
+}
+
1;
index fde8b36b43a555b3a70b53f4977a6b1b1cf5aab4..56925c9def398075a40f610a02fe791213e7e8fe 100644 (file)
&main::daemon_log("$session_id WARNING: delete user '$obsolete_user' at client '$source' from login_user_db", 3);
}
+ # Delete all users which logged in information is older than their logged_in_user_date_of_expiry
+ my $act_time = &get_time();
+ my $expiry_date = &calc_timestamp($act_time, "minus", $main::logged_in_user_date_of_expiry);
+
+ $sql_statement = "SELECT * FROM $main::login_users_tn WHERE CAST(timestamp as INTEGER)<$expiry_date";
+ $db_res = $main::login_users_db->select_dbentry($sql_statement);
+
+ while( my($hit_id, $hit) = each(%{$db_res}) ) {
+ &main::daemon_log("$session_id INFO: user '".$hit->{'user'}."' is no longer reported to be logged in at host '".$hit->{'client'}."'", 5);
+ my $sql = "DELETE FROM $main::login_users_tn WHERE (client='".$hit->{'client'}."' AND user='".$hit->{'user'}."')";
+ my $res = $main::login_users_db->del_dbentry($sql);
+ &main::daemon_log("$session_id INFO: delete user '".$hit->{'user'}."' at client '".$hit->{'client'}."' from login_user_db", 5);
+ }
+
return;
}