Commit | Line | Data |
---|---|---|
805e021f CE |
1 | # This is -*- perl -*- |
2 | ||
3 | package OpenAFS::Auth; | |
4 | use OpenAFS::Dirpath; | |
5 | ||
6 | use strict; | |
7 | #use vars qw( @ISA @EXPORT ); | |
8 | #@ISA = qw(Exporter); | |
9 | #require Exporter; | |
10 | #@EXPORT = qw($openafs-authadmin $openafs-authuser); | |
11 | ||
12 | sub 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 | ||
22 | sub 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 | ||
33 | sub authadmin { | |
34 | my $cell = &getrealm; | |
35 | my $cmd = "kinit -k -t /usr/afs/etc/krb5.keytab admin\@${cell} ; afslog"; | |
36 | system($cmd); | |
37 | } | |
38 | sub authuser { | |
39 | my $cell = &getrealm; | |
40 | my $cmd = "kinit -k -t /usr/afs/etc/krb5.keytab user\@${cell} ; afslog"; | |
41 | system($cmd); | |
42 | } | |
43 | ||
44 | 1; |