SECURITY: Avoid attacks with symbolic or hard links that could lead to
privilege escalation (CVE-2013-1423).  Thanks to Helmut Grohne for the
initial report and help in preparing the fix.
Fixed syntax of permissions for chmod
handle case where $main_repo already exists but is no git repo

(there’s still two things: mktemp -d might fail, in which case
we regress to the previous behaviour, and after the check the
$main_repo can come to exist before the mv, with the same outcome,
but since we do check the return value of the mv…)
Merge branch 'Branch_5_1' of git+ssh://scm.fusionforge.org//var/lib/gforge/chroot/scmrepos/git/fusionforge/fusionforge into Branch_5_1
I think is_file("$main_repo/HEAD") gives a warning if !is_dir($main_repo)
missing return value in non-void function
Obtain user's extra groups so as to be able to chgrp
Fixed logic
use posix_initgroups() to get the user’s group vector

calling 'su' inside createUserRepo() isn’t going to work because
that function is already run with reduced privilegues; instead,
if the old user is root use posix_initgroups() to switch the
group vector to the new user’s and restore root’s later (if the
old user is not root, we have no way to do that anyway as, in
my tests, posix_initgroups() only works if the current EUID is
0); posix_getgroups() can be used to save the old group list,
but there is no posix_setgroups(), so we need to use this way
use util_randbytes() to get six random bytes

it’s computationally, and on the kernel pool, much cheaper than
openssl_random_pseudo_bytes() which initialises the OpenSSL pool,
which eats more bytes from the kernel pool
Merged from 5.1
Marked the merge
Merged from 5.1
Marked the merge
Merged from 5.2