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

Last change on this file since 849 was 849, checked in by nanardon, 14 years ago
  • make unxported mode options more explicit
  • fix POD according behavior
  • Property svn:executable set to *
  • Property svn:keywords set to Id Rev
File size: 1.9 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-qacls [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    'b|base=s'          => \my $base,
27    'o|object=s'        => \my $otype,
28    'u|user=s'          => \my $user,
29    'no-unexp|wo-unexp' => \my $nounexp,
30    'exp'               => \my $unexp,
31    'help'              => sub { pod2usage(0) },
32) or pod2usage();
33
34$otype ||= 'user';
35
36=head1 OPTIONS
37
38=item -c|--config configfile
39
40Use this configuration file instead of the default one.
41
42=item -b|--base basename
43
44Query this specific base instead of the default one.
45
46=item --with-unexp
47
48Take into account all objects (even non propagated ones, with attribute 'exported'=0)
49
50=item --wo-unexp
51
52Take into account only propagated objects (attribute 'exported'=1) (default)
53
54=item -o|object object_type
55
56Query will be performed on this object. Default is the 'User' object.
57
58=item u|user username
59
60Check acls from the point of view of "username". If unset, anonymous is used.
61
62=cut
63
64my $LA = LATMOS::Accounts->new($config, noacl => 0);
65
66my $labase = $base ? $LA->base($base) : $LA->default_base;
67
68$labase->unexported($unexp ? 1 : 0);
69
70if ($user) {
71    $labase->{_user} = $user;
72}
73
74my $obj = $ARGV[0] ? $labase->get_object($otype, $ARGV[0]) : $otype
75    or die "No object $otype $ARGV[0]";
76
77
78printf(" %s %s\n",
79    ($labase->check_acl($obj, $_, 'w') ? 'w' : ' '),
80    $_,
81) foreach(qw(@CREATE @DELETE));
82
83printf("%s%s %s\n",
84    ($labase->check_acl($obj, $_, 'r') ? 'r' : ' '),
85    ($labase->check_acl($obj, $_, 'w') ? 'w' : ' '),
86    $_,
87) foreach($labase->list_canonical_fields($otype, 'a'));
Note: See TracBrowser for help on using the repository browser.