| SVN-Access documentation | view source | Contained in the SVN-Access distribution. |
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(
name => 'stooges',
members => [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(
name => '/free_car_giver_awayer/branches/prod_1.21-sammy_hagar',
authorized => {
'@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.
Example:
$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.
Example:
$acl->remove_resource('/');
returns an array of resource objects, takes no arguments.
Example:
for($acl->resources) {
print $_->name . "\n";
}
resolves a resource name to its SVN::Access::Resource object.
Example:
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.
Example:
$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.
Example:
$acl->remove_group('stooges');
returns an array of group objects, takes no arguments.
Example:
for($acl->groups) {
print $_->name . "\n";
}
resolves a group name to its SVN::Access::Group object.
Example:
$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.
Example:
$acl->write_acl;
the same as write_acl, but does it with extra whitespace to line things up.
Example:
$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 $@.
Example:
if (my $error = $acl->verify_acl) {
print "Problem found in your ACL: $error\n";
} else {
$acl->write_acl;
}
subversion (http://subversion.tigris.org/), SVN::ACL, svnserve.conf
Michael Gregorowicz, <mike@mg2.org>
Copyright (C) 2010 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.
| SVN-Access documentation | view source | Contained in the SVN-Access distribution. |