50 lines
1.9 KiB
Bash
Executable File
50 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (C) 2002 Vivek Venugopalan. All Rights Reserved.
|
|
#
|
|
# This is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This software is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this software; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
# USA.
|
|
#
|
|
|
|
# This is the core script that verifies file permission when a user checks
|
|
# in a file in CVS. This script should called when a file is committed to
|
|
# CVS. This can be achieved by deploying this script in the commitinfo file
|
|
# of the repository.
|
|
|
|
#Assumptions
|
|
#------------
|
|
#The command line will contain the name of the path that should be verified (typically the $1 in commitinfo script)
|
|
#The CVS server uses OS user as the authentication mechanism (SystemAuth=yes)
|
|
#We are being called during commit time.
|
|
|
|
|
|
grep "^$USER\$" $CVSROOT/CVSROOT/users.restricted >/dev/null
|
|
#if this is a restricted user then check further. Otherwise dont bother.
|
|
if [ $? -eq 0 ];then
|
|
#This person we have to check
|
|
echo $1 | grep -f `echo $CVSROOT/CVSROOT/$USER.permission` >/dev/null 2>&1
|
|
RESULT=$?
|
|
if [ $RESULT -eq 0 ];then
|
|
#Has permission - It is OK to allow him to commit the file.
|
|
exit 0;
|
|
elif [ $RESULT -eq 2 ];then
|
|
echo $USER you are not setup correctly for CVS permissions. Please contact the CVS Admin.
|
|
exit 1;
|
|
else
|
|
echo "sorry! $USER does not have permission to commit file(s) $1"
|
|
exit 1;
|
|
fi
|
|
fi
|