aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitaram Chamarty <sitaram@atc.tcs.com>2015-05-23 08:59:20 +0530
committerSitaram Chamarty <sitaram@atc.tcs.com>2015-05-27 05:48:43 +0530
commit4ed15ad8e5d82995b3d55cd17446fc90a3c2b7ec (patch)
tree03c6f1595a64c808b05260a39e85b51b17035736
parentmake single quotes around reponame optional... (diff)
downloadgitolite-gentoo-4ed15ad8e5d82995b3d55cd17446fc90a3c2b7ec.tar.gz
gitolite-gentoo-4ed15ad8e5d82995b3d55cd17446fc90a3c2b7ec.tar.bz2
gitolite-gentoo-4ed15ad8e5d82995b3d55cd17446fc90a3c2b7ec.zip
create command: remove race condition...
Because of the pipe in the create command, 'gitolite git-config' and 'perms -c' would run simultaneously. The problem was, if git-config ran between these two statements in new_wild_repo() in Store.pm: new_repo($repo); # 'gitolite git-config' runs here _print( "$repo.git/gl-creator", $user ); *and* the repo pattern had CREATOR in it, it would not return the correct values for the default.roles options, since the repo pattern would not be deemed to match the actual repo (between creator() and generic_name()). Thanks to Ronald Wirth for catching this; see [1] for details. [1]: https://groups.google.com/forum/#!topic/gitolite/5Dv6ViDmfF4 ---- ...and while we're about it, I changed it to use /bin/sh and smoke tested it using "dash", which I believe is close enough.
-rwxr-xr-xsrc/commands/create7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/commands/create b/src/commands/create
index 7d2a3a3..d35c4a8 100755
--- a/src/commands/create
+++ b/src/commands/create
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Usage: ssh git@host create <repo>
#
@@ -12,5 +12,6 @@ usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
[ -z "$GL_USER" ] && die GL_USER not set
# ----------------------------------------------------------------------
-gitolite git-config -r $1 gitolite-options.default.roles | sort | cut -f3 |
- perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$1/' | $GL_BINDIR/commands/perms -c "$@"
+perms=$(gitolite git-config -r $1 gitolite-options.default.roles | sort | cut -f3 |
+ perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$1/')
+echo "$perms" | $GL_BINDIR/commands/perms -c "$@"