SVN::Access - Perl extension to manipulate SVN Access files
use SVN::Access; my $acl = SVN::Access->new(acl_file => '/usr/local/svn/conf/my_first_dot_com.conf'); # add a group to the config $acl->add_group('stooges', qw/larry curly moe shemp/); # write out the acl (thanks Gil) $acl->write_acl; # give the stooges commit access to the production version of # our prized intellectual property, the free car giver-awayer.. # (thats how we get users to the site.) $acl->add_resource( # resource path '/free_car_giver_awayer/branches/prod_1.21-sammy_hagar', # permissions '@stooges' => 'rw', ); $acl->write_pretty; # with the equals signs all lined up.
SVN::Access includes both an object oriented interface for manipulating SVN access files (AuthzSVNAccessFile files), as well as a command line interface to that object oriented programming interface (svnaclmgr.pl) in the examples/ directory.
the constructor, takes key / value pairs. only one is required.. in fact only one is used right now. acl_file.
Example:
my $acl = SVN::Access->new(acl_file => '/path/to/my/acl.conf');
adds a resource to the current acl object structure. note: the changes are only to the object structure in memory, and one must call the write_acl method, or the write_pretty method to commit them.
$acl->add_resource('/', rick => 'rw', steve => 'rw', gibb => 'r', );
removes a resource from the current acl object structure. as with add_resource these changes are only to the object structure in memory, and must be commited with a write_ method.
$acl->remove_resource('/');
returns an array of resource objects, takes no arguments.
for($acl->resources) { print $_->name . "\n"; }
resolves a resource name to its SVN::Access::Resource object.
my $resource = $acl->resource('/');
adds a group to the current acl object structure. these changes are only to the object structure in memory, and must be written out with write_acl or write_pretty.
$acl->add_group('stooges', 'larry', 'curly', 'moe', 'shemp');
removes a group from the current acl object structure. these changes are only to the object structure in memory, and must be written out with write_acl or write_pretty.
$acl->remove_group('stooges');
returns an array of group objects, takes no arguments.
for($acl->groups) { print $_->name . "\n"; }
resolves a group name to its SVN::Access::Group object.
$acl->group('pants_wearers')->add_member('ralph');
takes no arguments, writes out the current acl object structure to the acl_file specified in the constructor.
$acl->write_acl;
the same as write_acl, but does it with extra whitespace to line things up.
$acl->write_pretty;
does a pre-flight check of the acl, and returns any errors found delimited by new lines. this routine is called by write_acl and write_pretty, where these errors will be considered fatal. be sure to either call this before $acl->write_*, OR use eval { } to capture the return of verify_acl into $@.
if (my $error = $acl->verify_acl) { print "Problem found in your ACL: $error\n"; } else { $acl->write_acl; }
adds an alias to [aliases], takes 2 arguments: the alias name and the aliased user.
Example: $acl->add_alias('mikey', 'uid=mgregorowicz,ou=people,dc=mg2,dc=org');
removes an alias by name, takes the alias name as an argument.
Example: $acl->remove_alias('mikey');
returns the value of an alias, uses exists() first so it will not autovivify the key in the hash.
Example: print $acl->alias('mikey') . "\n";
returns a hashref that contains the aliases. editing this hashref will edit the data inside the $acl object.
Example: foreach my $alias (keys %{$acl->aliases}) { print "$alias: " . $acl->aliases->{$alias} . "\n"; }
subversion (http://subversion.tigris.org/), SVN::ACL, svnserve.conf
Michael Gregorowicz, <mike@mg2.org>
Copyright (C) 2012 by Michael Gregorowicz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install SVN::Access, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVN::Access
CPAN shell
perl -MCPAN -e shell install SVN::Access
For more information on module installation, please visit the detailed CPAN module installation guide.