3 * Implement CVS ACLs based on GForge roles
5 * Copyright 2004 GForge, LLC
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
26 require_once $gfcommon.'include/escapingUtils.php';
27 require_once $gfwww.'include/squal_pre.php';
33 $env_group = getStringFromPost('group');
34 $env_user = getStringFromPost('user');
35 # Group must contain 3 - 15 alphanumeric chars or -
36 preg_match("/^([[:alnum:]-]{3,15})$/", $env_group, $matches);
38 # 1. Must only contain alphanumeric chars
39 # 2. Must be 3 - 15 chars
40 preg_match("/[[:alnum:]_]{3,15}/", $env_user, $matches2);
42 if (count($matches) == 0) {
43 exit_error('','Invalid CVS repository');
45 if (count($matches2) == 0) {
46 exit_error('','Invalid username');
49 $userName = $matches2[count($matches2)-1];
50 $User =& user_get_object_by_name($userName);
51 if (!$User || !is_object($User)) {
52 exit_error('','User not found');
54 session_set_new($User->getID());
56 $projectName = $matches[count($matches)-1];
57 $Group =& group_get_object_by_name($projectName);
58 if (!$Group || !is_object($Group) || $Group->isError()) {
62 $perm =& permission_get_object($Group, $User);
63 if (!$perm || !is_object($perm) || !$perm->isCVSWriter()) {
64 exit_permission_denied();
72 // c-file-style: "bsd"