3 * Implement CVS ACLs based on FusionForge roles
5 * Copyright 2004 GForge, LLC
6 * Copyright 2010, Franck Villaume
7 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
9 * This file is part of FusionForge.
11 * FusionForge 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 * FusionForge 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 along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../../../www/env.inc.php';
27 require_once $gfcommon.'include/escapingUtils.php';
28 require_once $gfcommon.'include/pre.php';
30 if (!forge_get_config('use_scm')) {
31 exit_disabled('home');
34 $env_group = getStringFromPost('group');
35 $env_user = getStringFromPost('user');
36 # Group must contain 3 - 15 alphanumeric chars or -
37 preg_match("/^([[:alnum:]-]{3,15})$/", $env_group, $matches);
39 # 1. Must only contain alphanumeric chars or _ or -
40 # 2. Must be 3 - 15 chars
41 preg_match("/[[:alnum:]_-]{3,15}/", $env_user, $matches2);
43 if (empty($matches)) {
44 exit_error(_('Invalid CVS repository: ').$env_group,'home');
46 if (empty($matches2)) {
47 exit_error(_('Invalid username: ').$env_user,'home');
50 $userName = $matches2[count($matches2)-1];
51 $User = user_get_object_by_name($userName);
52 if (!$User || !is_object($User)) {
53 exit_error(_('User not found')._(': ').$userName, 'home');
55 session_set_new($User->getID());
57 $projectName = $matches[count($matches)-1];
58 $Group = group_get_object_by_name($projectName);
59 if (!$Group || !is_object($Group) || $Group->isError()) {
63 if (! forge_check_perm_for_user ($User, 'scm', $Group->getID(), 'write')) {
64 exit_permission_denied('','home');
72 // c-file-style: "bsd"