[Pkg-privacy-commits] [msva-perl] 273/356: add option to msva-query-agent to just return agent version info

Ximin Luo infinity0 at moszumanska.debian.org
Mon Aug 24 07:42:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository msva-perl.

commit f0ce7b2df91fed66a47bd56cd3d7a0a2bcc210c6
Author: Jameson Rollins <jrollins at finestructure.net>
Date:   Tue Dec 28 10:20:58 2010 -0500

    add option to msva-query-agent to just return agent version info
    
    This option makes only a simple GET request to the agent and returns
    the agent version portion of the response.
---
 Crypt/Monkeysphere/MSVA/Client.pm | 14 ++++++++++++++
 msva-query-agent                  | 23 ++++++++++++++++++++---
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Crypt/Monkeysphere/MSVA/Client.pm b/Crypt/Monkeysphere/MSVA/Client.pm
index 046936a..4871e90 100644
--- a/Crypt/Monkeysphere/MSVA/Client.pm
+++ b/Crypt/Monkeysphere/MSVA/Client.pm
@@ -36,6 +36,20 @@
     $self->{logger}->log(@_);
   }
 
+  sub agent_info {
+    my $self = shift;
+    my $requesturl = $self->{socket} . '/';
+    my $request = HTTP::Request->new('GET', $requesturl);
+    $self->log('debug', "Contacting MSVA at %s\n", $requesturl);
+    my $response = $self->{ua}->request($request);
+    my $status = $response->status_line;
+    my $ret;
+    if ($status eq '200 OK') {
+      $ret = from_json($response->content);
+    }
+    return $status, $ret;
+  }
+
   sub query_agent {
     my $self = shift;
     my $context = shift;
diff --git a/msva-query-agent b/msva-query-agent
index 972037f..3ba8e2a 100755
--- a/msva-query-agent
+++ b/msva-query-agent
@@ -23,10 +23,25 @@ use Crypt::Monkeysphere::MSVA::Client;
 
 my $context = shift;
 if ($context eq '--help') {
-    printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n";
-    printf STDERR "       msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA\n";
+  printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n";
+  printf STDERR "       msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA\n";
+  printf STDERR "       msva-query-agent --version\n";
+  exit 0;
+} elsif ($context eq '--version') {
+  my $client = Crypt::Monkeysphere::MSVA::Client->new(
+						      socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
+						      log_level => $ENV{MSVA_LOG_LEVEL},
+						     );
+  my ($status,$ret) = $client->agent_info();
+  $client->log('verbose', "status: %s\n", $status);
+  if (defined $ret) {
+    printf("%s", $ret->{server});
+    printf("\n") if (-t STDOUT);
     exit 0;
+  }
+  exit 1;
 }
+
 my $peer = shift;
 my $pkctype = shift;
 my $peertype = shift;
@@ -47,7 +62,7 @@ my $client = Crypt::Monkeysphere::MSVA::Client->new(
 
 my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
 
-$client->log('info', "status: %s\n", $status);
+$client->log('verbose', "status: %s\n", $status);
 if (defined $ret) {
   $client->log('info', "valid: %s\n", $ret->{valid});
   $client->log('info', "server: %s\n", $ret->{server});
@@ -70,6 +85,8 @@ msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier
 
 msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
 
+msva-query-agent --version
+
 =head1 ABSTRACT
 
 msva-query-agent validates certificates for a given use by querying a

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/msva-perl.git



More information about the Pkg-privacy-commits mailing list