| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # START-COMMIT HOOK |
|---|
| 4 | # |
|---|
| 5 | # The start-commit hook is invoked immediately after a Subversion txn is |
|---|
| 6 | # created and populated with initial revprops in the process of doing a |
|---|
| 7 | # commit. Subversion runs this hook by invoking a program (script, |
|---|
| 8 | # executable, binary, etc.) named 'start-commit' (for which this file |
|---|
| 9 | # is a template) with the following ordered arguments: |
|---|
| 10 | # |
|---|
| 11 | # [1] REPOS-PATH (the path to this repository) |
|---|
| 12 | # [2] USER (the authenticated user attempting to commit) |
|---|
| 13 | # [3] CAPABILITIES (a colon-separated list of capabilities reported |
|---|
| 14 | # by the client; see note below) |
|---|
| 15 | # [4] TXN-NAME (the name of the commit txn just created) |
|---|
| 16 | # |
|---|
| 17 | # Note: The CAPABILITIES parameter is new in Subversion 1.5, and 1.5 |
|---|
| 18 | # clients will typically report at least the "mergeinfo" capability. |
|---|
| 19 | # If there are other capabilities, then the list is colon-separated, |
|---|
| 20 | # e.g.: "mergeinfo:some-other-capability" (the order is undefined). |
|---|
| 21 | # |
|---|
| 22 | # The list is self-reported by the client. Therefore, you should not |
|---|
| 23 | # make security assumptions based on the capabilities list, nor should |
|---|
| 24 | # you assume that clients reliably report every capability they have. |
|---|
| 25 | # |
|---|
| 26 | # Note: The TXN-NAME parameter is new in Subversion 1.8. Prior to version |
|---|
| 27 | # 1.8, the start-commit hook was invoked before the commit txn was even |
|---|
| 28 | # created, so the ability to inspect the commit txn and its metadata from |
|---|
| 29 | # within the start-commit hook was not possible. |
|---|
| 30 | # |
|---|
| 31 | # If the hook program exits with success, the commit continues; but |
|---|
| 32 | # if it exits with failure (non-zero), the commit is stopped before |
|---|
| 33 | # a Subversion txn is created, and STDERR is returned to the client. |
|---|
| 34 | # |
|---|
| 35 | # The default working directory for the invocation is undefined, so |
|---|
| 36 | # the program should set one explicitly if it cares. |
|---|
| 37 | # |
|---|
| 38 | # On a Unix system, the normal procedure is to have 'start-commit' |
|---|
| 39 | # invoke other programs to do the real work, though it may do the |
|---|
| 40 | # work itself too. |
|---|
| 41 | # |
|---|
| 42 | # Note that 'start-commit' must be executable by the user(s) who will |
|---|
| 43 | # invoke it (typically the user httpd runs as), and that user must |
|---|
| 44 | # have filesystem-level permission to access the repository. |
|---|
| 45 | # |
|---|
| 46 | # On a Windows system, you should name the hook program |
|---|
| 47 | # 'start-commit.bat' or 'start-commit.exe', |
|---|
| 48 | # but the basic idea is the same. |
|---|
| 49 | # |
|---|
| 50 | # The hook program runs in an empty environment, unless the server is |
|---|
| 51 | # explicitly configured otherwise. For example, a common problem is for |
|---|
| 52 | # the PATH environment variable to not be set to its usual value, so |
|---|
| 53 | # that subprograms fail to launch unless invoked via absolute path. |
|---|
| 54 | # If you're having unexpected problems with a hook program, the |
|---|
| 55 | # culprit may be unusual (or missing) environment variables. |
|---|
| 56 | # |
|---|
| 57 | # CAUTION: |
|---|
| 58 | # For security reasons, you MUST always properly quote arguments when |
|---|
| 59 | # you use them, as those arguments could contain whitespace or other |
|---|
| 60 | # problematic characters. Additionally, you should delimit the list |
|---|
| 61 | # of options with "--" before passing the arguments, so malicious |
|---|
| 62 | # clients cannot bootleg unexpected options to the commands your |
|---|
| 63 | # script aims to execute. |
|---|
| 64 | # For similar reasons, you should also add a trailing @ to URLs which |
|---|
| 65 | # are passed to SVN commands accepting URLs with peg revisions. |
|---|
| 66 | # |
|---|
| 67 | # Here is an example hook script, for a Unix /bin/sh interpreter. |
|---|
| 68 | # For more examples and pre-written hooks, see those in |
|---|
| 69 | # the Subversion repository at |
|---|
| 70 | # http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and |
|---|
| 71 | # http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/ |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | REPOS="$1" |
|---|
| 75 | USER="$2" |
|---|
| 76 | |
|---|
| 77 | commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1 |
|---|
| 78 | special-auth-check.py --user "$USER" --auth-level 3 || exit 1 |
|---|
| 79 | |
|---|
| 80 | # All checks passed, so allow the commit. |
|---|
| 81 | exit 0 |
|---|