From 83439ab0d6467280094d874a563ee7900ae1aa74 Mon Sep 17 00:00:00 2001 From: Martin Haase <martin.haase@daasi.de> Date: Wed, 8 Jun 2011 16:23:52 +0000 Subject: [PATCH] debugging, start with at demon now git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@10071 7c539038-3410-0410-b1ec-0f2a7bf1c452 --- .../pwdaemon/etc/mapSIDtoPassPhrase.sys | 4 +- .../pwdaemon/mapSIDtoPassPhrase | 45 +++++++++++-------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/info.textgrid.middleware.tgauth.rbac/pwdaemon/etc/mapSIDtoPassPhrase.sys b/info.textgrid.middleware.tgauth.rbac/pwdaemon/etc/mapSIDtoPassPhrase.sys index c0a38e1..54bd397 100644 --- a/info.textgrid.middleware.tgauth.rbac/pwdaemon/etc/mapSIDtoPassPhrase.sys +++ b/info.textgrid.middleware.tgauth.rbac/pwdaemon/etc/mapSIDtoPassPhrase.sys @@ -1,8 +1,8 @@ progname = "mapSIDtoPassPhrase" -version = 0.1 +version = 0.2 -date = "2010-07-13" +date = "2011-06-06" <author> name = "Martin Haase" org= "DAASI International GmbH" diff --git a/info.textgrid.middleware.tgauth.rbac/pwdaemon/mapSIDtoPassPhrase b/info.textgrid.middleware.tgauth.rbac/pwdaemon/mapSIDtoPassPhrase index b4e8c0f..c02a082 100755 --- a/info.textgrid.middleware.tgauth.rbac/pwdaemon/mapSIDtoPassPhrase +++ b/info.textgrid.middleware.tgauth.rbac/pwdaemon/mapSIDtoPassPhrase @@ -1,4 +1,4 @@ -#!/usr/bin/perl -W +#!/usr/bin/perl -w ################################################### # This Daemon has 3 Methods: # getCSR (sid) @@ -37,6 +37,7 @@ # 2010-05-19: debugged/fixed, ported to perl 5.10 # 2010-07-13: introduce configuration file using DAASIlib::CONF # 2010-07-15: changed from INET to local UNIX socket +# 2011-06-06: random initialization, better debuggg logging # use IO::Socket; @@ -63,14 +64,14 @@ use DAASIlib::CONF qw (is_debug); use DAASIlib::Data; # these two need: IO::Prompt, Log::Log4perl, DBI, DAASIlib::Gettext, Config::General - my $data = new DAASIlib::Data; my ($progname, $progpath, $etcdir, $sysconfig) = $data->getProgramFiles($0); +#print "progname: $progname, path: $progpath, etc: $etcdir, sysconfig: $sysconfig\n"; + my $conf = new DAASIlib::CONF; $conf->loadConfig($sysconfig, $progpath, $etcdir); - my %ldap_config; foreach $k (keys %{$conf->{data}}) { if ($k =~ /^ldap_conf_(\S+)/) { @@ -78,6 +79,9 @@ foreach $k (keys %{$conf->{data}}) { } } + +$DEBUG = 0; +if (defined $conf->{data}->{debugmode} && $conf->{data}->{debugmode}) { $DEBUG = 1 } my $socketfile = $conf->{data}{socketfile}; my $RBACuser = $conf->{data}{rbacuser}; my $passphraselength = $conf->{data}{passphraselength}; @@ -96,8 +100,6 @@ $SIG{INT} = sub { die "$$ dying...\n" }; # shared hash in-memory for passphrases $handle = tie %passphrases, 'IPC::Shareable', undef, {destroy => 1}; -random_set_seed_from_phrase(Time::HiRes::time); - unlink $socketfile; $server = IO::Socket::UNIX->new(Local => $socketfile, Type => SOCK_STREAM, @@ -110,6 +112,8 @@ use vars qw($login $pass); ($login,$pass,$uid,$gid) = getpwnam($RBACuser) or die "$RBACuser not in passwd file"; chown $uid, $gid, $socketfile; +debuggg ("\n------------ Demon restart at ". scalar ( localtime()) . " ------------\n"); + while (1) { $client = $server->accept(); @@ -131,16 +135,24 @@ while (1) { sub doJob { - print scalar ( localtime()) . " doing Job ...\n"; + random_set_seed_from_phrase(Time::HiRes::time); + + debuggg (scalar ( localtime()) . " doing Job ...\n"); my $client = shift; my $routine = <$client>; chomp $routine; - print "Routine is $routine ...\n"; + debuggg ("Routine is $routine ...\n"); + + my $sid = <$client>; + chomp $sid; + debuggg ("SID is $sid ...\n"); + + debuggg ("SID Inventory:\nSID: "); + debuggg (join "\nSID: ",keys %passphrases); + debuggg ("\n"); if ($routine eq "getCSR") { - my $sid = <$client>; - chomp $sid; my ($csr, $key) = &getCSR(); $handle->shlock(); @@ -151,9 +163,6 @@ sub doJob { print $client $csr; } elsif ($routine eq "putCRT") { - my $sid = <$client>; - chomp $sid; - my $crt = ""; while ($next = <$client>) { last if $next =~ />>>EOF<<</; @@ -166,9 +175,6 @@ sub doJob { print $client $result; } elsif ($routine eq "getPassphrase") { - my $sid = <$client>; - chomp $sid; - my $passphrase = &getPassphrase($sid); print $client "getPassphraseresult\n"; @@ -177,7 +183,7 @@ sub doJob { } else { die "Unknown command: $routine"; } -# print "returned $routine result to socket client\n...\n"; +# debuggg "returned $routine result to socket client\n...\n"; print $client "\n".'>>>EOF<<<'."\n"; # jetzt sagt der server nix mehr (s. exit im while) } @@ -186,7 +192,6 @@ sub doJob { # specific functions ################ sub getCSR { -# print "getCSR doing something...\n"; # create dummy CSR with key my $req = Crypt::OpenSSL::PKCS10->new(); @@ -200,7 +205,6 @@ sub getCSR { sub putCRT { -# print "putCRT doing something...\n"; my ($sid, $crt) = @_; my $key = $passphrases{$sid}; @@ -227,7 +231,6 @@ sub putCRT { } sub getPassphrase { -# print "getPassphrase doing something...\n"; my $sid = shift; if (length $passphrases{$sid} > $passphraselength) { @@ -417,3 +420,7 @@ sub ldapSearch { return ($mesg); } +sub debuggg { + return unless $DEBUG; + print shift; +} -- GitLab