>
> Has anyone done some work on an AFS C++ class library? I'm looking at
> building a small one - if anyone has done something similar and would
> like to share - please contact me.
>
I think even a nice C library would do wonders for programming with AFS :-)
In working on my Perl 5 module I've found I can't use a lot of the
Transarc supplied convenience routines because they print stuff to stderr,
don't allow multiple connections at the same time (cleanly, at least), etc.
I've finished the basic fs/kas/pts functions. Unless I find time I might
ask for a volunteer to do the vos/bos functions :-) I'll finish up the docs
on what I have and post them.
Here is the tokens command using the AFS module:
#!/usr/local/bin/perl
require 'ctime.pl';
use AFS;
print "\nTokens held by the Cache Manager:\n\n";
$context =0;
while( $server = ktc_ListTokens($context)) {
if ( ($token,$client) = ktc_GetToken($server)) {
$user = $client->name;
$user .= "." . $client->instance if ($client->instance);
if ($user eq '' || $user =~ /UNIX ID/) { printf("Tokens"); }
elsif ($user =~ /AFS ID/) { printf("User's (%s) tokens",$user); }
print " for ", $server->principal," ";
if ($token -> endTime <= time) { print "[>> Expired <<]\n"; }
else {
chop($expire = substr(&ctime($token->endTime),4,13));
print "[Expires $expire]\n";
}
}
}
print" --End of list--\n";
And here is a simple "kpasswd":
#!/usr/local/bin/perl
die "Usage: user \n" if ($#ARGV != 0);
use AFS;
AFS::raise_exception(1); # raise an exception on an error so we can be
# lazy and not check every error code
$user = ktc_principal(shift);
$user->cell(localcell) if ($user->cell eq '');
$oldkey = ka_ReadPassword("Old Password:",0,$user->cell);
$newkey = ka_ReadPassword("New Password:",1,$user->cell);
$token = ka_GetAdminToken($user, $oldkey, 300);
$kas = ka_AuthServerConn($token, &AFS::KA_MAINTENANCE_SERVICE,$user->cell);
$ok = $kas->ka_ChangePassword($user->name, $user->instance, $oldkey, $newkey);
Roland
--
Roland J. Schemers III | 414 Sweet Hall +1 (415) 723-6740
Authentication Services Programmer | Stanford, CA 94305-3090
Distributed Computing Operations | [EMAIL PROTECTED]
Stanford University | http://www-leland.stanford.edu/~schemers/