> Anyway... has someone more expert than me created perl5 modules for the AFS
> libraries? Is anyone planning to do so? Is Transarc planning to do so? I'd
> love to (re)write all my favourite system management scripts without firing
> off lots of vos, fs, and pts and then parsing their results. For that matter,
> I'd quite like to rewrite vos, fs and pts, since I've never been a fan of
> their syntax or output styles.
>
I started just such a project a while back. I basically finished the
fs, pts, and kas commands. I handed what I had finished over to some
CMU folks over 6 months ago, and haven't heard anything since. Although
my stuff needs some cleaning up, it would be a good place to start
for someone who wants to hack on it.
Source, docs, and (probably outdated) examples can all be found in my tar
file:
http://www-leland.stanford.edu/~schemers/dist/AFSperl.tar
/afs/ir.stanford.edu/users/s/schemers/WWW/dist/AFSperl.tar
It would nice if somoene picked up this stuff and finished it. Right
now everything is in one module, it might also be nice if you could
say things like "use AFS::PTS;", etc.
Some examples:
To list all the members in a group:
use AFS;
...
$pts = newpts;
@members = $pts ->members($name,$convert,$over);
To change a password:
$user = ktc_principal(shift);
$user->cell(localcell) if ($user->cell eq '');
$oldkey = ka_ReadPassword("Old Password:");
$newkey = ka_ReadPassword("New Password:",1,$user->cell);
$token = ka_GetAdminToken($user, $oldkey, 300);
$kas = ka_AuthServerConn($token, &AFS::KA_MAINTENANCE_SERVICE);
$ok = $kas->ka_ChangePassword($user->name, $user->instance, $oldkey, $newkey);
To emulate the tokens command:
#!/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";
To get an ACL on a directory:
$acl = getacl($path);
print "Access list for $path is\n";
print "Normal rights: \n" if ($acl->length);
foreach $key ($acl->keys) {
print " $key ",$acl->get($key),"\n";
}
print "Negative rights: \n" if ($acl->nlength);
foreach $key ($acl->nkeys) {
print " $key ",$acl->nget($key),"\n";
}
I was doing all my work (at the time) using Perl 5.000 and Solaris 2.3...
roland
--
Roland J. Schemers III | 2550 Garcia Avenue, MS MTV14-210
Member of Technical Staff, SunSoft | Mountain View, CA 94043-1100
[EMAIL PROTECTED] | (415) 336-1035 (phone)
[EMAIL PROTECTED] | (415) 336-3156 (fax)