Commit 639e23e7 authored by Leigh Stoller's avatar Leigh Stoller

Quickie script to resolve things at the clearinghouse. Mostly for

testing and demonstration.
parent 9a384acb
......@@ -26,7 +26,7 @@ SETUID_LIBX_SCRIPTS =
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(SBIN_STUFF) $(PSBIN_STUFF)
all: $(SBIN_STUFF) $(PSBIN_STUFF) resolve
include $(TESTBED_SRCDIR)/GNUmakerules
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
use Data::Dumper;
#
# Resolve a uuid or hrn at the clearinghouse or an SA.
#
sub usage()
{
print "Usage: resolve <type> [uuid | hrn]\n";
exit(1);
}
my $optlist = "";
my $uuid;
my $hrn;
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $PGENIDOMAIN = "@PROTOGENI_DOMAIN@";
my $PGENISUPPORT = @PROTOGENI_SUPPORT@;
my $SACERT = "$TB/etc/genisa.pem";
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Protos
sub fatal($);
#
# Turn off line buffering on output
#
$| = 1;
# Now we can load the libraries after setting the proper DB.
use lib '@prefix@/lib';
use libaudit;
use GeniDB;
use GeniCertificate;
use GeniAuthority;
use GeniRegistry;
use Genixmlrpc;
#
# Check args.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
usage()
if (@ARGV != 2);
my $type = $ARGV[0];
my $token = $ARGV[1];
if ($type =~ /^([\w]*)$/) {
$type = $1;
}
else {
fatal("Illegal chars in type: $type");
}
if ($token =~ /^([-\d]*)$/) {
$uuid = $1;
}
elsif ($token =~ /^([-\w\.]*)$/) {
$hrn = $1;
}
else {
fatal("Illegal chars in argument: $token");
}
#
# Load the SA cert to act as caller context.
#
my $certificate = GeniCertificate->LoadFromFile($SACERT);
if (!defined($certificate)) {
fatal("Could not load certificate from $SACERT\n");
}
my $context = Genixmlrpc->Context($certificate);
if (!defined($context)) {
fatal("Could not create context to talk to clearinghouse");
}
my $clearinghouse = GeniRegistry::ClearingHouse->Create($context);
if (!defined($clearinghouse)) {
fatal("Could not create a clearinghouse client");
}
my $value;
if ($clearinghouse->Resolve($token, uc($type), \$value) != 0) {
fatal("Could not resolve $token at the clearinghouse");
}
print Dumper($value);
exit(0);
sub fatal($)
{
my ($msg) = @_;
print STDERR "*** $0:\n".
" $msg\n";
# exit value important.
exit(-1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment