[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: pre-lock.bat Failed in Repo browser

From: Michael Diers <mdiers_at_elego.de>
Date: Wed, 09 Mar 2011 11:47:12 +0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2011-03-08 09:46, Waseem Bokhari wrote:
> We are working in Windows Environment. Visual SVN on Server Side as administration Tool and Tortoise SVN of Client. We are using HTTPS as well.
>
> Repository URL looks as :-
>
> https://ServerMachine.Domain.com:8443/svn/MyRepository
>
> Thanks in advance
>
>
>
> Muchas gracias!
> Waseem Bokhari
>
>
> -----Original Message-----
> From: Michael Diers [mailto:mdiers_at_elego.de]
> Sent: Tuesday, March 08, 2011 2:39 PM
> To: Waseem Bokhari
> Cc: users_at_subversion.apache.org
> Subject: Re: pre-lock.bat Failed in Repo browser
>
> On 2011-03-08 06:51, Waseem Bokhari wrote:
>> Hi Experts!
>> Below is the "pre-lock.bat " Script ....
>
>> Only User who lock the file can unlock the file. Other users are
>> forbidden to Unlock file.
> [...]
>> *Issue/Problem!!*
>
>> This scenario failed in Repo Browser. Any one can Unlock File/Folder
>> through Repo Browser.
[...]

Waseem,

indeed, anyone can _unlock_ the file because the pre-lock hook script is
never triggered for an unlock operation. (The unlock operation is called
"Break lock" in TortoiseSVN's Repository Browser.)

You'd need to provide a pre-unlock hook script to handle this.

- --- snip snip ---
@echo off
set trc=C:\tmp\waseem\trace.txt
echo === BEGIN pre-unlock >> %trc%

:: Set all parameters
set repository=%1
set repopath=%2
set user=%3

:: Set path to svnlook
set svnlook=%VISUALSVN_SERVER%bin\svnlook.exe

echo repository = %repository% >> %trc%
echo repopath = %repopath% >> %trc%
echo user = %user% >> %trc%
echo svnlook = %svnlook% >> %trc%

echo --- >> %trc%

:: Check that the lock exists and has an owner.
echo 1 >> %trc%
"%svnlook%" lock "%repository%" %repopath% >> %trc% 2>&1
echo 2 >> %trc%
"%svnlook%" lock "%repository%" %repopath% | findstr /C:"Owner: %user%"
> nul 2>&1

:: If the person locking matches the lock's owner, allow unlocking.
set rc=%ERRORLEVEL%
echo 3 >> %trc%
if %rc% EQU 0 ^ echo "Info: %repopath% OK to unlock by %user%." >> %trc%
echo 4 >> %trc%
if %rc% EQU 0 exit 0

:: Otherwise, print notice to stderr and return failure.
echo 5 >> %trc%
echo "Error: %repopath% is locked by another user." >> %trc%
echo 6 >> %trc%
echo "Error: %repopath% is locked by another user." 1>&2
exit 1
- --- snip snip ---

- --
Michael Diers, elego Software Solutions GmbH, http://www.elego.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk13aL8ACgkQcEKlWnqVgz075gCgoDJbvDrNmFzcJgZDmUWn5x8O
AFAAoLIJ0o/9+iITNVjJXP+pLmSTmcFk
=K0Ae
-----END PGP SIGNATURE-----
Received on 2011-03-09 12:47:54 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.