backport to buster
[hcoop/debian/openafs.git] / src / tests / OpenAFS / Auth-Heimdal.pm
CommitLineData
805e021f
CE
1# This is -*- perl -*-
2
3package OpenAFS::Auth;
4use OpenAFS::Dirpath;
5
6use strict;
7#use vars qw( @ISA @EXPORT );
8#@ISA = qw(Exporter);
9#require Exporter;
10#@EXPORT = qw($openafs-authadmin $openafs-authuser);
11
12sub getcell {
13 my($cell);
14 open(CELL, "$openafsdirpath->{'afsconfdir'}/ThisCell")
15 or die "Cannot open $openafsdirpath->{'afsconfdir'}/ThisCell: $!\n";
16 $cell = <CELL>;
17 chomp $cell;
18 close CELL;
19 return $cell;
20}
21
22sub getrealm {
23 my($cell);
24 open(CELL, "$openafsdirpath->{'afsconfdir'}/ThisCell")
25 or die "Cannot open $openafsdirpath->{'afsconfdir'}/ThisCell: $!\n";
26 $cell = <CELL>;
27 chomp $cell;
28 close CELL;
29 $cell =~ tr/a-z/A-Z/;
30 return $cell;
31}
32
33sub authadmin {
34 my $cell = &getrealm;
35 my $cmd = "kinit -k -t /usr/afs/etc/krb5.keytab admin\@${cell} ; afslog";
36 system($cmd);
37}
38sub authuser {
39 my $cell = &getrealm;
40 my $cmd = "kinit -k -t /usr/afs/etc/krb5.keytab user\@${cell} ; afslog";
41 system($cmd);
42}
43
441;