You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Don Caprio <Do...@Sun.COM> on 2006/09/29 17:57:35 UTC
Pre-commit hook to restrict mkdir
I'm new to subversion so I appoligize in advance for any stupid newbie questions.
I'd like to restrict my users from creating top-level directories. After looking
through the docs and FAQ's it appears that the best way would be to create a
pre-commit hook. Am I on the right path or is there a better way? The Apache
mod_dav_svn module would fit the bill but clients will be using command-line.
I've done some poking around with the pre-commit script however I'm having some
trouble figuring it all out.
The command 'svn mkdir file:///repos/projectA -m "make initial project dir"
generates the following hook variables:
***START pre-commit script. TXN=y REPOS=/repos
author: caprio
changed: A projectA/
dirs-changed: /
proplist:
propget:
***END pre-commit script
If dirs-changed = "/" and changed: = "A" would I be correct in interpreting that
user wishes to create 'projectA' in the repos root dir?
Any help/pointers would be greatly appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Pre-commit hook to restrict mkdir
Posted by Ryan Schmidt <su...@ryandesign.com>.
On Sep 29, 2006, at 12:57, Don Caprio wrote:
> I'm new to subversion so I appoligize in advance for any stupid
> newbie questions.
>
> I'd like to restrict my users from creating top-level directories.
> After looking through the docs and FAQ's it appears that the best
> way would be to create a pre-commit hook. Am I on the right path or
> is there a better way? The Apache mod_dav_svn module would fit the
> bill but clients will be using command-line.
The method by which the repository is served (apache mod_dav_svn,
svnserve, svn+ssh, direct file access) has little to do with the
client used to access it (command-line client, TortoiseSVN, WebSVN,
Trac, SmartSVN, etc.). In other words, you can certainly serve a
repository with mod_dav_svn and access it with the command-line svn
client.
The question then is: what feature of mod_dav_svn do you think will
help you in this scenario? I think there are ways to make this work
regardless of how you serve the repository.
Yes, a pre-commit script sounds like the right way to approach this
problem:
> I've done some poking around with the pre-commit script however I'm
> having some trouble figuring it all out.
>
> The command 'svn mkdir file:///repos/projectA -m "make initial
> project dir"
> generates the following hook variables:
>
> ***START pre-commit script. TXN=y REPOS=/repos
> author: caprio
> changed: A projectA/
> dirs-changed: /
> proplist:
> propget:
> ***END pre-commit script
>
> If dirs-changed = "/" and changed: = "A" would I be correct in
> interpreting that user wishes to create 'projectA' in the repos
> root dir?
The way it's implemented internally is that adding a file or
directory (any item) to a repository means that its containing
directory gets modified. So, the directory getting modified is "/"
and the modification being made is that the directory "projectA" is
being added to it. You know it's being added because the line says
"A projectA/" -- "A" means "added", "projectA" is of course the
name of the item being added, and the "/" at the end of "projectA"
tells you it's a directory.
So if you want to prevent directories from being added to the root,
run "svnlook dirs-changed" as you do, and if it's "/", then run
"svnlook changed", and if any line starts with "A" and ends with "/"
then you exit the hook with a nonzero status and print an appropriate
error message to inform the user.
If you want to prevent both files and directories from being added to
"/" then just search for lines output from "svnlook changed" starting
with "A".
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
RE: Pre-commit hook to restrict mkdir
Posted by "Reedick, Andrew" <An...@BellSouth.com>.
> -----Original Message-----
> From: Donald.Caprio@Sun.COM [mailto:Donald.Caprio@Sun.COM]
> Sent: Friday, September 29, 2006 1:58 PM
> To: users@subversion.tigris.org
> Subject: Pre-commit hook to restrict mkdir
>
> I'm new to subversion so I appoligize in advance for any
> stupid newbie questions.
>
> I'd like to restrict my users from creating top-level
> directories. After looking
> through the docs and FAQ's it appears that the best way would
> be to create a
> pre-commit hook. Am I on the right path or is there a better
> way? The Apache
> mod_dav_svn module would fit the bill but clients will be
> using command-line.
>
> I've done some poking around with the pre-commit script
> however I'm having some
> trouble figuring it all out.
>
> The command 'svn mkdir file:///repos/projectA -m "make
> initial project dir"
> generates the following hook variables:
>
> ***START pre-commit script. TXN=y REPOS=/repos
> author: caprio
> changed: A projectA/
> dirs-changed: /
> proplist:
> propget:
> ***END pre-commit script
>
> If dirs-changed = "/" and changed: = "A" would I be correct
> in interpreting that
> user wishes to create 'projectA' in the repos root dir?
>
> Any help/pointers would be greatly appreciated.
>
>
Use 'svnlook changed --transaction'
http://svnbook.red-bean.com/nightly/en/svn.ref.svnlook.c.changed.html
*****
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA624
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org