1#! /usr/bin/perl -w
2
3use strict;
4
5use ExtUtils::testlib;
6use GSSAPI;
7
8my $targethostname = 'HTTP@moerbsen.grolmsnet.lan';
9my $status;
10#-----------------------------------------------------------------
11my $server =  $ARGV[0] || die "\n\nusage: $0 servicename \n (eg HTTP\@moerbsen.grolmsnet.lan) \n\n";
12
13$server eq 'servicename' && die "\n\ngreat, you have just copypasted the parametername. But the testscript wants you to pass a servername for test if getting a GSSAPI token works.\n\n";
14
15
16#-----------------------------------------------------------------
17TRY: {
18     my ($target, $tname, $ttl );
19     $status = GSSAPI::Name->import( $target,
20                                     $server,
21                                     GSSAPI::OID::gss_nt_hostbased_service)
22               or last;
23     $status = $target->display($tname) or last;
24     print "\n using Name $tname";
25
26     my $ctx = GSSAPI::Context->new();
27     my $imech = GSSAPI::OID::gss_mech_krb5;
28     my $iflags = 0 ;
29     my $bindings = GSS_C_NO_CHANNEL_BINDINGS;
30     my $creds = GSS_C_NO_CREDENTIAL;
31     my $itime = 0;
32     my $itoken = q{};
33     my $otoken;
34
35     $status = $ctx->init($creds,$target,
36                          $imech,$iflags,$itime,$bindings,$itoken,
37                          undef, $otoken,undef,undef) or last;
38     $status = $ctx->valid_time_left($ttl) or last;
39     print "\n Security context's time to live $ttl secs";
40}
41
42unless ($status->major == GSS_S_COMPLETE  ) {
43   print "\nErrors: ", $status;
44} else {
45   print "\n seems everything is fine, type klist to see the ticket\n";
46}