Check subversion writable access for user

旧城冷巷雨未停 提交于 2020-01-06 20:07:08

问题


Is there any way to check whether user have writable access to some repository path? What I do now is trying to create directory and then delete it to check whether user has writable access:

svn mkdir --username username --password password --message "check whether user username has repository writable access" "svn://localhost:3129/test"
svn delete --username username --password password --message "check whether user username has repository writable access" "svn://localhost:3129/test"

The problem is that those operations are performed too often as a part of application source code. And, as a result, repository get too many needless commits in case user has writable access.

Is there any command similar to svn checkaccess --username username --password password svn://localhost:3129/test or any other workarounds so that I would not need to create temporary directory all the time?


回答1:


I can propose a hacky way, but I'm not sure it will work for all protocols (I tested with DAV --- it worked, with file:/// all paths are writable).

Subversion has several APIs. Some languages (at least C (libsvn_ra), Java (SVNKit), Perl (AlienSVN)) provide remote API that allows to create a commit with editor calls (I don't know if PHP does). If you perform the following calls on the URL you want to check writability:

openRoot -1
changeDirProperty customPropertyName custromPropertyValue
closeDir
abortEdit

This sequence performs no changes because of abortEdit() call, if the directory is writable. But for DAV this fails with error code RA_NOT_AUTHORIZED (E170001) if not writable.

There's an article that shows how to use commit with SVN remote API in Java. I think PHP code would look similar.

Hope it helps (if not you then at least Java/C/Perl developers).



来源:https://stackoverflow.com/questions/11593587/check-subversion-writable-access-for-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!