Archive

Posts Tagged ‘svn’

Format of SVN access file for Path Based Authorization

December 17, 2009 2 comments

Fine grained permissions on SVN repositories can be provided by creating an access file. Following is a sample access file explaining the basic format of the file. More details can be found by reading the SVN book.

#groups are defined here. simply list the names of members of the group delimited by comma
[groups]
admin = rudy, batman, admin

# to create access control for a repo, start with the directory that you are 
# defining the permissions for
# to define permissions for all directories within a repo, use /
# for example, to define permissions for all directories in the gui project
# i've used the following [gui:/]
# the syntax is [reponame:directorypath]
# to define permission for a specific directory within the repo, specify the path
# example: [gui:/branches/2.0/bug/140] defines the permissions for the 
# /gui/branches/2.0/bug/140 directory
# the syntax to define the permission itself is
# username = access
# where username is the username of the user you are writing permission for
# and access is one of r or rw, r meaning read permission and rw meaning read and
# write permission
# username could also be the name of a group. in that case, the group name is written
# as @groupname
# for example, to give the admin group rw permission on all directories in gui
# use,
# [gui:/]
# @admin = rw
# if you need to give all users permission on a directory, use the special
# character '*' to denote all users
# NOTE: The longest matching directory path permission is always applied first
# so if you have two permission rules like so,
# [gui: /]
# rudy = rw
#
# and
#
# [gui:/branches/2.0]
# nithin = r
# 
# then, nithin will only have read permission on the /gui/branches/2.0 directory
# because that is the longest matching path
# More examles below:

[/]
* = r

[gui:/]
@admin = rw
nithin = rw
#
[moregui:/]
@admin = rw
matt = rw
john = r
chuck = rw
#
[hardcore:/branches/2.1/broke]
@admin = rw
#
[test:/]
@admin = rw
* = rw
Advertisements
Tags:

Create SVN repositories using a standard folder structure

December 10, 2009 Leave a comment

This is shell script that you can use to create all of your repositories using the same standard folder structure. You need to replace the following variables for it to run:

  1. Replace [name] with the correct username of a user who will have permissions on the repository.
  2. Replace [password] with the correct password of the user
  3. Replace yourdomain.com with the path to where your svn repositories are stored

call the script: ./scriptname reponame and it will create a new repository with the name reponame.

Here’s what the script does:

  1. The script creates the new repository folder
  2. It gives apache permissions on the folder. If you are not using apache, uncomment the line.
  3. If you are using an access file to provide fine-tuned directory permissions, you may want to uncomment the two lines that refer to access.txt. Those two lines add the new repo to the access file and gives the admin group rw permissions on the repository.
  4. It then goes and creates the standard folder structure, ie, trunk, branches adn tags folder.
#!/bin/bash
svnadmin create $1;
chgrp -R apache $1;
chmod -R g+rw $1;
#echo "[$1:/]" >> access.txt
#echo "@admin = rw" >> access.txt
svn –username [name] –password [pass] mkdir "http://yourdomain.com/svn/"$1"/trunk" -m "ADD: /trunk";
svn –username [name] –password [pass] mkdir "http://yourdomain.com/svn/"$1"/branches" -m "ADD: /branches";
svn –username [name]—password [pass] mkdir "http://yourdomain.com/svn/"$1"/tags" -m "ADD: /tags";

echo "------------------------------------------";
echo "Standard Repo Layout Created";

Installing SVN server

November 25, 2009 Leave a comment
  1. Install latest Apache http server
  2. Install SVN
    1. Make sure to install mod_dav_svn and mod_authz_svn. mod_authz_svn is only needed if you plan on doing fine-grained directory permissions on your SVN repositories
    2. Load the mod_dav_svn and mod_authz_svn modules in httpd.conf. You may also need to load the mod_dav module if you don’t have it yet:
    LoadModule dav_module modules/mod_dav.so
    LoadModule dav_svn_module modules/mod_dav_svn.so 
    LoadModule authz_svn_module modules/mod_authz_svn.so 
    

    3. Modify apache httpd.conf to add the following:

     
    <Location svn> 
    DAV svn 
    SVNParentPath D:/svn 
    SVNListParentPath on 
    AuthType Basic 
    AuthName &quot;Subversion Repository&quot; 
    AuthUserFile passwd.txt 
    Require valid-user
    </Location>
    

    4. You should now be able to browse to your SVN repos at www.yourdomain.com/svn

    5. If you would like to enable anonymous checkouts, replace the Require valid-user above with the following. Check-ins will still require authentication.

     
    # For any operations other than these, require an authenticated user. 
    <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
    </LimitExcept>
    

    6. If you are not going to be using per-directory access control, you might as well turn off path authorization (it’s on by default). This improves performance of your server, since its not checking every single path requested to see if the user is authorized to access it. Add this line to turn it off:

    SVNPathAuthz off
    

    7. Install PHP

    8. Install an SVN browser, WebSVN is the best I’ve seen. It’s built on PHP and works well.

    9. Subclipse is the best SVN client for use with Eclipse IDE

    10. TortoiseSVN is a good SVN windows explorer client

Tags: , ,

Moving repositories/ Creating backups in SVN

August 1, 2009 Leave a comment

Recently, I needed to move some projects around in my SVN and it turned out to be very easy, although it took a bit of googling. This also gives you a way to take file backups of your repositories. Basically, what I needed to do was move one repository into a subfolder inside another repository. To do this, you just need two commands and you also need to do this on the SVN server. You can’t do it from an SVN client. Here are the two commands:

svnadmin dump /path/to/repository > filename.dmp
svnadmin load –-parent-dir path/to/subfolder repository-name < filename.dmp

So basically, the first command dumps your current repository including its previous revisions, branches and tags all to the standard output and you can redirect that into a file. You can use this command to take periodic backups of your repository which is really neat. I was actually searching for this feature as well and there might be other ways to take backups as well.

The second command then loads up the repository from the dump file into the subfolder. If you don’t specify the –-parent-dir, it will just load up the file into the new repository. The parent-dir path is relative to the root of your new repository.

Here are the links that helped me find this:

http://svnbook.red-bean.com/nightly/en/svn.ref.svnadmin.c.load.html

http://www.digitalmediaminute.com/article/2251/how-to-move-a-subversion-repository

Tags: ,
%d bloggers like this: