【问题标题】:Need Subversion pre-commit hook to block check-ins by a specific user需要 Subversion 预提交挂钩来阻止特定用户的签入
【发布时间】:2018-04-23 03:19:39
【问题描述】:

我在 Windows Server 2008 上安装了 Subversion。我想将代码添加到 pre-commit.bat 以阻止域用户 jdoe 在域 foo 上的提交。该代码是什么样的?我假设它将使用 C:\Program Files (x86)\VisualSVN Server\bin\svnlook。

【问题讨论】:

    标签: windows svn visualsvn-server pre-commit-hook


    【解决方案1】:

    svnlook author,但不要从事这种废话 - 重新阅读有关基于路径的授权并撤销所需用户在所需区域的写入权限。期间。

    【讨论】:

    • 我尝试在根存储库的 conf 文件夹中的 authz 文件中添加一个条目,但无法使其正常工作。我认为预提交挂钩可能更容易,因为我目前正在使用一个来阻止缺少签入注释的提交。
    【解决方案2】:

    这是我的 pre-commit.bat。这很丑陋,但它有效。第一个检查会阻止缺少注释的提交。第二个检查阻止用户 jdoe 的提交。

    @echo off
    ::    
    :: Stops commits that have empty log messages.
    ::
    
    @echo off
    
    setlocal
    
    rem Subversion sends through the path to the repository and transaction id
    set REPOS=%1
    set TXN=%2
    
    rem check for an empty log message
    "C:\Program Files (x86)\VisualSVN Server\bin\svnlook" log %REPOS% -t %TXN% | findstr . > nul
    if %errorlevel% gtr 0 (goto err) else (goto nextcheck)
    
    rem block commits by user jdoe
    :nextcheck
    "C:\Program Files (x86)\VisualSVN Server\bin\svnlook" author %REPOS% -t %TXN% > c:\windows\temp\author.txt
    set /p authorcommitting=<c:\windows\temp\author.txt
    if %authorcommitting%==jdoe (goto err1) else exit 0
    
    :err
    echo. 1>&2
    echo Your commit has been blocked because you didn't supply a log message  1>&2
    echo. 1>&2
    echo Please add a log message describing the reason for your changes and 1>&2
    echo then commit. 1>&2
    echo. 1>&2
    exit 1
    
    :err1
    echo. 1>&2
    echo Commits are blocked for this user 1>&2
    echo. 1>&2
    exit 1
    

    【讨论】:

    【解决方案3】:

    请阅读VisualSVN Server Getting Started 指南和Configuring User Permissions 部分。

    VisualSVN 服务器提供了一个 UI 来管理用户权限。您可以使用VisualSVN Server Manager MMC consolePowerShellRepoCfg 来管理权限。

    不要忘记,SVN 服务器管理员和存储库管理员必须了解 Subversion 中的访问控制原则。阅读文章KB33: Understanding VisualSVN Server authorization 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多