source: LATMOS-Accounts/bin/la-qacls @ 591

Last change on this file since 591 was 483, checked in by nanardon, 15 years ago
  • document la-qacls
  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8use Term::ReadKey;
9
10=head1 NAME
11
12    la-qacls - Tools to check ACL
13
14=head1 SYNOPSIS
15
16Show a list of attributes with permission allowed to a given user
17
18    la-config [option] [objectname]
19
20If objectname is specified, the acls are checked over this object.
21
22=cut
23
24GetOptions(
25    'c|config=s' => \my $config,
26    'base=s'     => \my $base,
27    'o|object=s' => \my $otype,
28    'u|user=s'   => \my $user,
29    'help'       => sub { pod2usage(0) },
30) or pod2usage();
31
32$otype ||= 'user';
33
34=head1 OPTIONS
35
36=item -c|--config configfile
37
38Use this configuration file instead default
39
40=item -b|--base basename
41
42Perform query on this base
43
44=item -o|object type
45
46Check acls for this object type
47
48=item u|user username
49
50Check acls as this username were really login. If unset, anonymous is used.
51
52=cut
53
54my $LA = LATMOS::Accounts->new($config, noacl => 0);
55
56my $labase = $base ? $LA->base($base) : $LA->default_base;
57
58if ($user) {
59    $labase->{_user} = $user;
60}
61
62my $obj = $ARGV[0] ? $labase->get_object($otype, $ARGV[0]) : $otype
63    or die "No object $otype $ARGV[0]";
64
65
66printf(" %s %s\n",
67    ($labase->check_acl($obj, $_, 'w') ? 'w' : ' '),
68    $_,
69) foreach(qw(@CREATE @DELETE));
70
71printf("%s%s %s\n",
72    ($labase->check_acl($obj, $_, 'r') ? 'r' : ' '),
73    ($labase->check_acl($obj, $_, 'w') ? 'w' : ' '),
74    $_,
75) foreach($labase->list_canonical_fields($otype, 'a'));
Note: See TracBrowser for help on using the repository browser.