[Netpass-devel] NetPass/lib/NetPass API.pm,1.24,1.25 DB.pm,1.48,1.49
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-08-03 02:44:47
|
Update of /cvsroot/netpass/NetPass/lib/NetPass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19022/lib/NetPass Modified Files: API.pm DB.pm Log Message: some bug fixes, resetport.pl re-write, appstarter completion, install/initd tweaks Index: DB.pm =================================================================== RCS file: /cvsroot/netpass/NetPass/lib/NetPass/DB.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- DB.pm 19 Jul 2005 14:47:50 -0000 1.48 +++ DB.pm 3 Aug 2005 02:44:39 -0000 1.49 @@ -1563,7 +1563,7 @@ } _log ("INFO", qq{$whoami added user $u groups "$groups"}); $self->audit(-ip => $myip, -user => $whoami, -severity => 'ALERT', - "user added: $u groups: $groups"); + -msg => ["user added: $u groups: $groups"]); } else { @@ -1579,8 +1579,8 @@ return "db failure ".$self->{'dbh'}->errstr; } _log ("INFO", qq{$whoami modified user $u groups "$groups_orig" to "$groups"}); - $self->audit(-ip => $myip, -user => $whoami, -severity => 'ALERT', - "groups for $u changed from: $groups_orig to: $groups"); + $self->audit(-ip => $myip, -user => $whoami, -severity => 'ALERT', -msg => + ["groups for $u changed from: $groups_orig to: $groups"]); } } } @@ -1617,7 +1617,7 @@ return "invalid params (no groups given)"; } - $self->reconnect() || return "db failure"; + $self->reconnect() || return "db failure: disconnected"; my $gs = join(';', @groups); my $sql = qq{INSERT INTO users VALUES ('$user', '$gs')}; @@ -1629,18 +1629,52 @@ return 0; } -=head2 getAppAction () +=head2 getAppAction( ) -Fetch the current list of pending tasks for appStarter to perform. Returns a -reference to an array of array references. +Fetch the current list of pending tasks for appStarter to perform. - [ [ $application, $action, $actionAs] , [ $application, ... ] , ... ] +RETURNS + + a reference to an array of array references on success + + [ [ rowid, application, action, actionAs] , [ rowid, application, ... ] , ... ] + + "db failure" on failure =cut sub getAppAction { my $self = shift; + $self->reconnect() || return "db failure: disconnected"; + + my $aref = $self->{'dbh'}->selectall_arrayref(qq{SELECT rowid, application, action, actionAs FROM appStarter WHERE status = 'pending'}); + if (!defined($aref)) { + return "db failure: ".$self->{'dbh'}->errstr; + } + return $aref; +} + +=head2 ackAppAction(rowid) + +Change the status of rowid to 'completed' + +RETURNS + 1 on success + "db failure" on failure + +=cut + +sub ackAppAction { + my $self = shift; + my $rowid = shift; + + my $sql = "UPDATE appStarter SET status = 'completed' WHERE rowid = ".$self->{'dbh'}->quote($rowid); + my $rv = $self->{'dbh'}->do($sql); + if (!defined($rv)) { + return "db failure: ". $self->{'dbh'}->errstr; + } + return 1; } =head2 reqAppAction ($proc, $action, $actionas) @@ -2744,6 +2778,30 @@ return $self->{'dbh'}->commit; } +=head2 clearRegister( ) + +Delete all data from the register data. + +RETURNS + + 1 on success + "db failure" on database failure + +=cut + +sub clearRegister { + my $self = shift; + $self->reconnect() || return "db failure: not connected"; + + my $rv = $self->{'dbh'}->do('DELETE FROM register'); + if (!defined($rv)) { + _log("ERROR", "db failure ".$self->{'dbh'}->errstr); + return "db failure ".$self->{'dbh'}->errstr; + } + return 1; +} + + =head2 updateRegister(-mac => '', -status => [QUAR|PQUAR|UNQUAR|PUNQUAR]) Update the register table for the given MAC address. Index: API.pm =================================================================== RCS file: /cvsroot/netpass/NetPass/lib/NetPass/API.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- API.pm 26 Jul 2005 15:09:37 -0000 1.24 +++ API.pm 3 Aug 2005 02:44:39 -0000 1.25 @@ -70,7 +70,7 @@ eval { require NetPass::API::Local; }; if ($@) { - _log("DEBUG", "NetPass::API::Local does not exist or has an error in it ".$@); + #_log("DEBUG", "NetPass::API::Local does not exist or has an error in it ".$@); return 0; } |