5 * Fabio Bertagnin nov 2005
6 * fbertatnin@mail.transiciel.com
8 * This file is part of GForge.
10 * GForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * GForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with GForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 require_once $gfwww.'include/pre.php';
26 require $gfcommon.'include/cron_utils.php';
31 $chroot_dir = forge_get_config('chroot');
32 $ftp_dir = forge_get_config('ftp_upload_dir')."/pub/";
33 $home_dir = $chroot_dir.forge_get_config('homedir_prefix')."/";
36 $res_db = db_query_params ('SELECT groups.group_id, group_name, unix_group_name,
40 JOIN user_group ON user_group.group_id = groups.group_id
41 JOIN users ON users.user_id = user_group.user_id
46 while($e = db_fetch_array($res_db))
48 $users["$e[user_id]"]["user_name"] = "$e[user_name]";
49 $users["$e[user_id]"]["user_groups"][] = "$e[unix_group_name]";
52 foreach ($users as $u)
54 $dir = "$home_dir"."$u[user_name]"."/pub";
56 //$res = execute($cmd);
57 if (is_dir("$home_dir"."$u[user_name]"))
59 foreach ($u["user_groups"] as $g)
61 if (is_dir("$ftp_dir"."$g"))
63 if (is_dir("$dir/$g"))
65 $cmd = "/bin/umount $dir/$g";
67 $cmd = "/bin/rmdir $dir/$g";
72 $cmd = "/bin/mkdir $dir";
75 $cmd = "/bin/mkdir $dir/$g";
77 $cmd = "/bin/mount --bind $ftp_dir"."$g $dir/$g";
79 echo "allow $u[user_name] to access at $dir/$g\n";
85 function print_debug($text)
90 function execute($cmd)
92 // print_debug ("cmd= ".$cmd);
93 $res = shell_exec($cmd);
94 // print_debug ("res= ".$res);