Commit 7279754d authored by Kirill Smelkov's avatar Kirill Smelkov

gitlab-backup/restore: Don't allow ln ambiguity (which can lead to failures)

ln has several syntaxes. man ln 1 ln:

   SYNOPSIS
          ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
          ln [OPTION]... TARGET                  (2nd form)
          ln [OPTION]... TARGET... DIRECTORY     (3rd form)
          ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

so without -T or -t what is target and what is link name is ambiguous and
ln tries to guess. Now imagine:

    ln -sf /path/to/new/hook    $H

and let us consider that $H is already a symlink, pointing to some place
which _exists_, but current user do not have access to. Then ln will
complain:

    ln: accessing `$H': Permission denied

and abort.

Fix it by specifying ln form we use explicitly with -T.
parent b770b689
...@@ -284,7 +284,7 @@ backup_restore() { ...@@ -284,7 +284,7 @@ backup_restore() {
# adjust hooks links to point to current gitlab-shell location # adjust hooks links to point to current gitlab-shell location
find "$reposX" -type l -path "*.git/hooks" | \ find "$reposX" -type l -path "*.git/hooks" | \
while read H; do while read H; do
ln -sf "$GITLAB_HOOKS_PATH" "$H" ln -sfT "$GITLAB_HOOKS_PATH" "$H"
done done
# extraction complete - now proceed with actual backup restore # extraction complete - now proceed with actual backup restore
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment