5 * Fabio Bertagnin nov 2005
6 * fbertatnin@mail.transiciel.com
8 * @version $Id: 06_IMPROVSFTP_80_ftp_improvement.dpatch,v 1.1 2006/01/11 17:02:45 fabio Exp $
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require ('squal_pre.php');
28 require ('common/include/cron_utils.php');
33 $chroot_dir = $sys_chroot;
34 $ftp_dir = $sys_ftp_upload_dir."/pub/";
35 $home_dir = $chroot_dir.$homedir_prefix."/";
38 $SQL = "SELECT groups.group_id, group_name, unix_group_name, ";
39 $SQL .= "user_group.user_id, ";
40 $SQL .= "users.user_name ";
41 $SQL .= "FROM groups ";
42 $SQL .= "JOIN user_group ON user_group.group_id = groups.group_id ";
43 $SQL .= "JOIN users ON users.user_id = user_group.user_id ";
44 $SQL .= "ORDER BY group_id ";
45 $res_db = db_query($SQL);
48 while($e = db_fetch_array($res_db))
50 $users["$e[user_id]"]["user_name"] = "$e[user_name]";
51 $users["$e[user_id]"]["user_groups"][] = "$e[unix_group_name]";
54 foreach ($users as $u)
56 $dir = "$home_dir"."$u[user_name]"."/pub";
58 //$res = execute($cmd);
59 if (is_dir("$home_dir"."$u[user_name]"))
61 foreach ($u["user_groups"] as $g)
63 if (is_dir("$ftp_dir"."$g"))
65 if (is_dir("$dir/$g"))
67 $cmd = "/bin/umount $dir/$g";
69 $cmd = "/bin/rmdir $dir/$g";
74 $cmd = "/bin/mkdir $dir";
77 $cmd = "/bin/mkdir $dir/$g";
79 $cmd = "/bin/mount --bind $ftp_dir"."$g $dir/$g";
81 echo "allow $u[user_name] to access at $dir/$g\n";
87 function print_debug($text)
92 function execute($cmd)
94 // print_debug ("cmd= ".$cmd);
95 $res = shell_exec($cmd);
96 // print_debug ("res= ".$res);