mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
git-srv-admin.sh: Only allow manipulating own repos
Disallow attempts to manipulate other user's repositories. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
8d40d2c18e
commit
d504aa21cd
1 changed files with 12 additions and 3 deletions
|
|
@ -53,6 +53,11 @@ md()
|
|||
}
|
||||
}
|
||||
|
||||
check_user_is_self()
|
||||
{
|
||||
[ "$id" != "$user" ] && fatal "User $id is not allowed to do this to user $user's repositories."
|
||||
}
|
||||
|
||||
# ----------------- commands
|
||||
md_p()
|
||||
{
|
||||
|
|
@ -90,8 +95,9 @@ create_personal_project()
|
|||
|
||||
list_personal_projects()
|
||||
{
|
||||
cd $pdir
|
||||
cd $pdir || return 1
|
||||
ls */HEAD | sed 's%/HEAD%%' 2>/dev/null
|
||||
return $?
|
||||
}
|
||||
|
||||
# ----------------- here we go
|
||||
|
|
@ -123,10 +129,11 @@ shift $(($OPTIND - 1))
|
|||
if [ "$user" ]; then
|
||||
id=$user
|
||||
else
|
||||
[ "$SUDO_UID" ] && {
|
||||
if [ "$SUDO_UID" ]; then
|
||||
id=`/opt/ytools/bin/getpwuid $SUDO_UID | sed '/^name *=/ !d; s/^name *= *//'`
|
||||
[ "$id" ] || fatal "failed to find uid $SUDO_UID in user database"
|
||||
}
|
||||
fi
|
||||
user=$id
|
||||
fi
|
||||
|
||||
git_home=/srv/git/$id
|
||||
|
|
@ -141,6 +148,7 @@ dir=$pdir/$p
|
|||
|
||||
case $cmd in
|
||||
create-personal-project)
|
||||
check_user_is_self
|
||||
create_personal_project "$@"
|
||||
;;
|
||||
list-personal-projects)
|
||||
|
|
@ -148,6 +156,7 @@ list-personal-projects)
|
|||
;;
|
||||
create-project-dir)
|
||||
dir=$1 # this is all a horrible variable and usage mess
|
||||
check_user_is_self
|
||||
create_project_dir "$@"
|
||||
;;
|
||||
*)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue