<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>intuitive engineering &#187; tools</title>
	<atom:link href="http://dougmunsinger.com/category/tools/feed" rel="self" type="application/rss+xml" />
	<link>http://dougmunsinger.com</link>
	<description>doug munsinger</description>
	<lastBuildDate>Fri, 13 Jan 2012 17:08:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>another tool for SVN &#8211; list_repositories.pl</title>
		<link>http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html</link>
		<comments>http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html#comments</comments>
		<pubDate>Mon, 11 May 2009 15:28:14 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[apache2]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[move2]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[websphere]]></category>
		<category><![CDATA[CGI.pm]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://dougmunsinger.com/?p=762</guid>
		<description><![CDATA[&#160; &#160; One of the features of subversion + apache2 is the ability to list repositories &#8211; natively.&#160; SVNParentPath /apps/repos SVNListParentPath on Unfortunately, once you restrict the httpd.conf to individual repositories and start handling permissions separately you lose that.&#160; Both of these permissions, set at the top level, at the parent path to the repositories, [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>&nbsp;</p>
<p>One of the features of subversion + apache2 is the ability to list repositories &#8211; natively.&nbsp;</p>
<p>SVNParentPath /apps/repos<br />
SVNListParentPath on</p>
<p>Unfortunately, once you restrict the httpd.conf to individual repositories and start handling permissions separately you lose that.&nbsp; Both of these permissions, set at the top level, at the parent path to the repositories, have to be commented out to have the individual permissions on the directories below take effect.</p>
<p>And listing just the repositories wasn&#8217;t enough for what I had in mind &#8211; I wanted a read-only table showing an individual developer or a team lead for a project who has what permissions for the subversion repositories. All the users, all the repositories.</p>
<p>Just your basic cgi.</p>
<p>&nbsp;</p>
<p><a href="http://dougmunsinger.com/images/posts/2009/repos_1.png" rel="shadowbox[sbpost-762];player=img;" title="repository listing cgi"><img src="http://dougmunsinger.com/images/posts/2009/repos_1_420.png" title="repos" alt="repos" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;and the script:</p>
<p><a href="http://dougmunsinger.com/images/posts/2009/list_repositories.pl.txt" title="list_repositories.pl"><br />
</a><code>#! /bin/perl -w</p>
<p>
# script to parse and display users and repositories and rights (R, RW)</p>
<p>use strict;<br />
use CGI qw(:standard);<br />
use CGI::Carp qw(fatalsToBrowser);</p>
<p>
##----------------------------<br />
## Variables<br />
##----------------------------</p>
<p>
#debug<br />
my $debug = 0; #set to 0 to turn off, 1 (true) to turn on </p>
<p># title for page<br />
my $PageTitle = &quot;List of SVN Repositories&quot;;</p>
<p>## repository directory<br />
my $SVN = &quot;/apps/repos&quot;;<br />
## location for htpasswd files<br />
my $HTDIR = &quot;/apps/apache2/conf/htpasswd&quot;;<br />
## Set untainted path<br />
$ENV{PATH} = '/apps/apache2/bin:/bin:/usr/bin:/usr/local/bin';<br />
$ENV{IFS} = &quot;&quot; if $ENV{IFS} ne &quot;&quot;;</p>
<p># css <br />
my $css = &quot;http://&lt;your server name&gt;/css/main.css&quot;;<br />
my $headerimg = &quot;http://&lt;your server name&gt;/css/roger_rabbit_120.jpg&quot;;</p>
<p>
##------------------------------<br />
## MAIN<br />
##------------------------------</p>
<p>&amp;standard_header;<br />
my ($ref_repos, $ref_tabledata, $ref_users) = &amp;CreateTableSpace;<br />
&amp;DisplayTable ($ref_repos, $ref_tabledata, $ref_users);<br />
&amp;standard_footer;<br />
exit;</p>
<p>##------------------------------<br />
## subs<br />
##------------------------------</p>
<p>sub standard_header {<br />
&nbsp;&nbsp;&nbsp; print header();<br />
&nbsp;&nbsp;&nbsp; print start_html(-Title =&gt; &quot;$PageTitle&quot;, -BGCOLOR=&gt;&quot;White&quot;, <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -style =&gt; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -src =&gt; &quot;${css}&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; );<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;div id=\&quot;header\&quot;&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; print p(&quot;&lt;img src=\&quot;${headerimg}\&quot; title=\&quot;Wells logo\&quot; alt=\&quot;wells logo\&quot;/&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;/div&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;div id=\&quot;headertitle\&quot;&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; print h3(&quot;Repositories&lt;br/&gt;\nusers | read (R) | read &amp; write (RW)\n&quot;); # start_multipart_form() if file upload<br />
}</p>
<p>
sub standard_footer { <br />
&nbsp;&nbsp;&nbsp; print end_html(); <br />
}</p>
<p>
sub CreateTableSpace {<br />
&nbsp;&nbsp;&nbsp; my $ref_repos = &amp;GetBlankRepos;<br />
&nbsp;&nbsp;&nbsp; my @repos = @$ref_repos; # dereference<br />
&nbsp;&nbsp;&nbsp; my %tabledata = (); # hash to hold table data<br />
&nbsp;&nbsp;&nbsp; my @users = (); # list of users<br />
&nbsp;&nbsp;&nbsp; my %seen = (); <br />
&nbsp;&nbsp;&nbsp; foreach my $rep (@repos) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open(FILE, &quot;$HTDIR/${rep}_read&quot;) || croak &quot;Failed to open $HTDIR/${rep}_read for reading...&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @filelines = &lt;FILE&gt;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close FILE;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $line (@filelines) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # lines are user:passwd<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($user, $pass) = split (&quot;:&quot;, $line);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unless ($seen{$user}) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $seen{$user} = 1; # save as seen<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push (@users, $user); # save the user to a list<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tabledata{$rep}{$user} = &quot;read&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open (FILE, &quot;$HTDIR/${rep}_write&quot;) || croak &quot;Failed to open $HTDIR/${rep}_write for reading&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my @file_lines = &lt;FILE&gt;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close FILE;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $line (@file_lines) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # lines are user:passwd<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($user, $pass) = split (&quot;:&quot;, $line);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unless ($seen{$user}) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $seen{$user} = 1; # save as seen<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push (@users, $user); # save the user to a list<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $tabledata{$rep}{$user} = &quot;readwrite&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; return (\@repos, \%tabledata, \@users);<br />
}</p>
<p>
sub GetBlankRepos {<br />
&nbsp;&nbsp;&nbsp; my @repos = ();<br />
&nbsp;&nbsp;&nbsp; # list $SVN<br />
&nbsp;&nbsp;&nbsp; opendir (DIR, $SVN) || croak &quot;Failed to open directory $SVN for reading...&quot;;<br />
&nbsp;&nbsp;&nbsp; while (defined(my $file = readdir(DIR))) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # skip &quot;.&quot;, &quot;..&quot; and .&lt;hidden&gt; files...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($file =~ /^\./) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; push(@repos, $file);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; return (\@repos);<br />
}</p>
<p>sub DisplayTable {<br />
&nbsp;&nbsp;&nbsp; my $ref_repos = shift;&nbsp; #@repos<br />
&nbsp;&nbsp;&nbsp; my $ref_tabledata = shift; # %tabledata<br />
&nbsp;&nbsp;&nbsp; my $ref_users = shift; # @users<br />
&nbsp;&nbsp;&nbsp; # dereference<br />
&nbsp;&nbsp;&nbsp; my @repos = @$ref_repos;<br />
&nbsp;&nbsp;&nbsp; my %tabledata = %$ref_tabledata;<br />
&nbsp;&nbsp;&nbsp; my @users = @$ref_users;<br />
&nbsp;&nbsp;&nbsp; # repos across the top, users down, R or RW for permissions<br />
&nbsp;&nbsp;&nbsp; # $tabledata{$rep}{$user} = &quot;readwrite&quot;;<br />
&nbsp;&nbsp;&nbsp; # start table<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;table&gt;\n&lt;tbody&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; # table header<br />
&nbsp;&nbsp;&nbsp; my $cols = ($#repos + 1);<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;tr&gt;&lt;td&gt;Users&lt;/td&gt;&lt;td colspan=\&quot;$cols\&quot;&gt;Repositories&lt;/td&gt;&lt;/tr&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;div id=\&quot;repotitles\&quot;&gt;&lt;tr&gt;\n&lt;td&gt;&amp;nbsp;&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp; foreach my $rep (@repos) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;&lt;td&gt;$rep&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; print (&quot;\n&lt;/tr&gt;\n&lt;/div&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; foreach my $user (@users) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;&lt;tr&gt;\n&lt;td&gt;$user&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach my $repo (@repos) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($tabledata{$repo}{$user}) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($tabledata{$repo}{$user} eq &quot;read&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;&lt;td&gt;R&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } elsif ($tabledata{$repo}{$user} eq &quot;readwrite&quot;) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;&lt;td&gt;RW&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;&lt;td&gt;&amp;nbsp; - &amp;nbsp;&lt;/td&gt;&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;\n&lt;/tr&gt;\n&quot;);<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; # finish table<br />
&nbsp;&nbsp;&nbsp; print (&quot;&lt;/tbody&gt;\n&lt;/table&gt;\n&quot;);<br />
}</code></p>
<div class="addtothis"><p>
				<table cellspacing="0" cellpadding="0" border="0" style="width: 180px; height: 30px; text-align: left; margin-left: 0px; ">
				<tbody>
				<tr>
				<td style="text-align: center;">
				<a href="http://www.stumbleupon.com/submit?url=http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html&title=another tool for SVN &#8211; list_repositories.pl" rel="nofollow">
                                <img src="http://dougmunsinger.com/wp-content/plugins/addtothis/stumble.png" title="Add to Stumble Upon" alt="Stumble It!" style="border: 0px solid ; width: 28px; height: 28px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://del.icio.us/post?url=http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html&title=another tool for SVN &#8211; list_repositories.pl" rel="nofollow">
				<img src="http://dougmunsinger.com/wp-content/plugins/addtothis/delicious.png" title="Add to Del.icio.us" alt="Add to Del.cio.us" style="border: 0px solid ; width: 28px; height: 28px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://technorati.com/faves?add=http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html" rel="nofollow">
				<img src="http://dougmunsinger.com/wp-content/plugins/addtothis/technorati.png" title="Add to Technorati" alt="Add to Technorati Favorites" style="border: 0px solid ; width: 28px; height: 28px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://digg.com/submit?phase=2&url=http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html" rel="nofollow">
				<img src="http://dougmunsinger.com/wp-content/plugins/addtothis/digg.png" title="Add to Digg" alt="Digg It!" style="border: 0px solid ; width: 28px; height: 28px;"/>
				</a>
				</td>
				<td style="text-align: center;">
				<a href="http://dougmunsinger.com/feed/rss" rel="nofollow">
				<img src="http://dougmunsinger.com/wp-content/plugins/addtothis/feeds.png" title="Add Feed to Bookmarks" alt="RSS Feed" style="border: 0px solid ; width: 28px; height: 28px;"/>
				</a>
				</td>
				</tr>
				</tbody>
				</table>

                
		
				</p></div>]]></content:encoded>
			<wfw:commentRss>http://dougmunsinger.com/2009/05/subversion-cg-tool-list-repositories.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

