The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl

use blib;
use strict;
use warnings;

use AFS::KTC_TOKEN;
use AFS::KTC_PRINCIPAL;
use AFS::KTC_EKEY;
use AFS::Utils qw(setpag);

die "Usage: $0 user\n" if ($#ARGV != 0);

my $princ = shift;

setpag;
system "tokens";

my $user = AFS::KTC_PRINCIPAL->new($princ);
my $password = AFS::KTC_EKEY->UserReadPassword("Password:");
my $pw;
my $reason = '';
my $ok = AFS::KTC_TOKEN->UserAuthenticateGeneral($user, $password, 300,
          &AFS::KA_USERAUTH_VERSION | &AFS::KA_USERAUTH_DOSETPAG,
          $pw, $reason);

print "AFS::CODE = $AFS::CODE\n";
print "pwexpires = $pw\n";
print "reason = $reason\n";

system "tokens";