Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / tests / aclremoveuser.pl
1 #!/usr/bin/env perl
2 use OpenAFS::CMU_copyright;
3 use OpenAFS::util qw(:DEFAULT %AFS_Help);
4 use OpenAFS::afsconf;
5 use OpenAFS::fs;
6 use OpenAFS::pts;
7 use OpenAFS::vos;
8 use OpenAFS::bos;
9
10 my ($wscell, $path, @pos1, @pos2, @neg1, @neg2, $ret, @tmp, @tmp2, @tmp3, $found, $listref, $first);
11 &AFS_Init();
12 $wscell = &AFS_fs_wscell();
13 $found = 0;
14 $first = 0;
15
16 $path = "/afs/${wscell}/service/acltest";
17 mkdir $path, 0777;
18 ($pos1, $neg1) = &AFS_fs_getacl($path);
19 $listref = "[ ";
20 while ($ret = pop(@$pos1)) {
21 $first++;
22 @tmp2=@$ret;
23 if ($tmp2[0] eq "user1") {
24 $found++;
25 } else {
26 unshift @tmp, @$ret;
27 if ($first == 0 ) {
28 $listref = $listref . "[ @tmp2 ]";
29 } else {
30 $listref = $listref . ", [ @tmp2 ]";
31 }
32 }
33 }
34 $listref = $listref . " ]";
35
36 if ($found != 1) {
37 print "WARNING: Can't remove user not on ACL. This shouldn't happen.\n";
38 exit(1);
39 }
40
41 $ret = &AFS_fs_setacl([$path],$listref,,);
42 ($pos2, $neg2) = &AFS_fs_getacl($path);
43
44 @tmp2=();
45 while ($ret = pop(@$pos1)) {
46 unshift @tmp2, @$ret;
47 }
48
49 exit(0);
50
51
52