Reputation: 73
I have a Collabnet Subversion Edge v3.3.1 installation on Windows. I already have basic access restriction enabled but this does not give me the flexibility to do the following: 1. Abandon file/folder delete by users 2. Use of wild cards for specifying file level permissions in a repository
Hence, I googled and found svnperms.py to suit my requirement. I followed the instructions on the internet and configured the svnperms.py for access restrictions.
My pre-commit hook looks as below:
set REPOS=%1
set TXN=%2
REM "C:\csvn\Python25\python.exe" "C:\csvn\data\repositories\repos\hooks\svnperms.py" -r "%repos%" -t "%txn%" - f "C:\csvn\data\repositories\repos\hooks\svnperms.conf"
"C:\csvn\Python25\python.exe" "C:\csvn\data\repositories\repos\hooks\svnperms.py" - f "C:\csvn\data\repositories\repos\hooks\svnperms.conf" -r "%REPOS%" -t "%TXN%"||exit 1;
exit 0;
My configuration file looks like
[groups]
group1 = sowmya.dass
group2 = m.b
[repos]
a/.* = @group1(update)
a/.* = @group2(delete)
I tried testing this by making user m.b delete a file under folder a in the repository. Since the user has access he should be able to do it but then i get the below error when he tries to commit :
Command: Commit
Deleting: C:\m_ws_edge\a\pom.xml
Error: Commit failed (details follow):
Error: Commit blocked by pre-commit hook (exit code 1) with output:
Error: svnlook author C:\csvn\data\repositories\repos -t 5-c
Error: '{' is not recognized as an internal or external command,
Error: operable program or batch file.error: command failed: svnlook author
Error: C:\csvn\data\repositories\repos -t 5-c
Error: '{' is not recognized as an internal or external command,
Error: operable program or batch file.
Completed!:
The same error comes up when any user tries to do any operation irrespective of whether a user has access granted or not.
I looked at an earlier post at How to control changes to tags in SVN server on Windows where in a similar issue was discussed. But the solution does not suit my requirement. And it also mentions that svnperms.py does not work on windows due to the underlying svnlook commands which only work on unix. I also happened to see other posts on the internet which mentioned similar issues but I could not find any solution to getting svnperms.py work on windows.
Can anybody help me with : 1. Fix the above error and to get svnperms.py work on windows or/and 2. Alternative solution to suit my above mentioned requirements of being able to abandon user delete on files/folders and being able to use wildcards in file based access restrictions.
Thanks !
Regards
Sowmya Dass
Upvotes: 0
Views: 668
Reputation: 107040
I don' believe the hook isn't finding the executable. You got an exit code of 1
and not 255
.
Here's the error output your hook is passing back to you:
svnlook author C:\csvn\data\repositories\repos -t 5-c
'{' is not recognized as an internal or external command,
operable program or batch file.error: command failed: svnlook author
C:\csvn\data\repositories\repos -t 5-c
'{' is not recognized as an internal or external command,
operable program or batch file.
I see the output command failed: svnlook author
as being generated in line 187 of your Python script.
The operation looks pretty straight forward. A SVNLook
class is created to execute the svnlook
commands. This is defined on line #174. There's a author
method for this class defined on line #233. Line #243 is executing this line and finding the author.
If the svnlook author
doesn't return a non-zero status, (Line #183), The command string is written:
svnlook author C:\csvn\data\repositories\repos -t 5-c
Then the returned error string:
'{' is not recognized as an internal or external command,
operable program or batch file.error:
And finally,
command failed: svnlook author
I'm not 100% sure where the last three lines came from.
The svn author C:\csvn\data\repositories\repos -t 5-c
looks correct to me. The '{' is not recognized as an internal or external command
string shouldn't be the response to the svnlook
command.
I wonder if there's a Perl version of svnlook
lurking somewhere on your system. I believe on Windows systems, the %PATH%
and %PATHEXEC%
environment variables are not zeroed out.
See if you can get the %PATH% to print out when you execute your pre-commit.bat
script. I think all you need to do is to add:
PATH 1>&2
or something similar to the precommit.bat
script. Then, see if there's another svnlook.bat
on your system that might be getting executed before the svnlook
command in C:\csvn
.
You can also try my pre-commit hook script. It's written in Perl, but also uses a control file to define permissions and can do all of the things you requested. My script requires you to specify where svnlook
is located, and that will eliminate the possibility that you're executing a bad svnlook
command somewhere on your system.
Upvotes: 1
Reputation: 7807
The problem doesn't look to be in your hook. It looks more like it is in svnperms.py.
It's possible that the path to one of the programs cannot be found. Hooks start with a bare environment. (Not even path is set)
This also doesn't appear to be related to Subversion Edge. Hooks are handled by the underlying Subversion "engine".
-Edit-
You might want to look a the article here. It is a .Net port of svnperms.
Here's something else to check (related to the bare environment) Set up svnperms pre-commit hook
Upvotes: 0