我可以阻止用户使用 TortoiseSVN 和 RapidSVN 从服务器删除文件吗?

发布于 2024-07-29 03:01:48 字数 164 浏览 5 评论 0原文

当用户使用 TortoiseSVN 和 RapidSVN 时,他会看到服务器上的文件,因此能够删除它们。 我想阻止这种情况发生。 也许阻止删除选项?

为了澄清,我希望从服务器删除文件的唯一方法是用户从本地驱动器删除它,然后将其提交到服务器。 我想限制任何用户直接从服务器删除的能力。

When a user is using TortoiseSVN and RapidSVN, he sees the files as they are on the server, and thus has the ability to delete them. I want to prevent that. Maybe to block the option to delete?

To clarify, I want the only way a file will be deleted from a server is that a user deletes it from his local drive, and then commits it to the server. I want to restrict the ability of any user to delete directly from the server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无语# 2024-08-05 03:01:48

一如既往,试图阻止客户端发生任何事情本质上是不安全的。 您的用户始终可以使用不同的客户端。

因此,您需要管理服务器端(在存储库本身)的访问权限。 不幸的是,据我所知,SVN 本身仅支持“读”和“写”访问级别。 授予某人“写”访问权限意味着用户不仅能够修改现有文件,还可以添加新文件和删除现有文件。

您也许可以通过预提交挂钩添加此功能。

Trying to prevent anything on the client side is, as always, inherently insecure. Your users could always use a different client.

So you need to manage the access rights on the server side (in the repository itself). Unfortunately, as far as I know, SVN natively supports only "read" and "write" access levels. Giving someone "write" access means that the user is not only able to modify existing files, but also to add new files and to delete existing ones.

You might be able to add this functionality via a pre-commit hook.

囍孤女 2024-08-05 03:01:48

通过添加预提交挂钩来防止删除。
在 Windows 中,可以通过在“Your_SVN_repository\hooks\”中添加“pre-commit.bat”来完成,其内容如下。

@echo off
::
:: Stops commits that have deleted/renamed/moved files/folders.
::

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an delete command in commit
svnlook changed %REPOS% -t %TXN% | findstr /i /m /b D > nul

if %errorlevel% gtr 0  exit 0 else (goto err)

:err
echo. 1>&2
echo Your commit includes files/folder deleted or renamed from repository 1>&2
echo Deletion/Rename is not allowed from repository>&2
echo Please revert the deletion/rename changes 1>&2
exit 1

Prevent deletions by adding pre-commit hook.
In windows this can be done by adding "pre-commit.bat" in "Your_SVN_repository\hooks\" with content as follows.

@echo off
::
:: Stops commits that have deleted/renamed/moved files/folders.
::

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an delete command in commit
svnlook changed %REPOS% -t %TXN% | findstr /i /m /b D > nul

if %errorlevel% gtr 0  exit 0 else (goto err)

:err
echo. 1>&2
echo Your commit includes files/folder deleted or renamed from repository 1>&2
echo Deletion/Rename is not allowed from repository>&2
echo Please revert the deletion/rename changes 1>&2
exit 1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文