示例#1
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require dirname(__FILE__) . '/../../env.inc.php';
require_once $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
$err = '';
$res = db_query("SELECT user_name,user_id,authorized_keys \n\tFROM users \n\tWHERE authorized_keys != ''\n\tAND status='A'");
for ($i = 0; $i < db_numrows($res); $i++) {
    $ssh_key = db_result($res, $i, 'authorized_keys');
    $username = db_result($res, $i, 'user_name');
    $dir = $homedir_prefix . '/' . $username;
    if (util_is_root_dir($dir)) {
        $err .= "Error! homedir_prefix/username Points To Root Directory!";
        continue;
    }
    $uid = db_result($res, $i, 'user_id');
    $ssh_key = str_replace('###', "\n", $ssh_key);
    $uid += 1000;
    $ssh_dir = "{$homedir_prefix}/{$username}/.ssh";
    if (!is_dir($ssh_dir)) {
        mkdir($ssh_dir, 0755);
    }
    $h8 = fopen("{$ssh_dir}/authorized_keys", "w");
    fwrite($h8, '# This file is automatically generated from your account settings.' . "\n");
    fwrite($h8, $ssh_key);
    fclose($h8);
    system("chown {$username}:users {$homedir_prefix}/{$username}");
示例#2
0
 /**
  *  delete - delete this package and all its related data.
  *
  *  @param  bool	I'm Sure.
  *  @param  bool	I'm REALLY sure.
  *  @return   bool true/false;
  */
 function delete($sure, $really_sure)
 {
     if (!$sure || !$really_sure) {
         $this->setMissingParamsError();
         return false;
     }
     $perm =& $this->Group->getPermission(session_get_user());
     if (!$perm || !is_object($perm) || !$perm->isReleaseTechnician()) {
         $this->setPermissionDeniedError();
         return false;
     }
     $r =& $this->getReleases();
     for ($i = 0; $i < count($r); $i++) {
         if (!is_object($r[$i]) || $r[$i]->isError() || !$r[$i]->delete($sure, $really_sure)) {
             $this->setError('Release Error: ' . $r[$i]->getName() . ':' . $r[$i]->getErrorMessage());
             return false;
         }
     }
     $dir = $GLOBALS['sys_upload_dir'] . '/' . $this->Group->getUnixName() . '/' . $this->getFileName() . '/';
     // double-check we're not trying to remove root dir
     if (util_is_root_dir($dir)) {
         $this->setError('Package::delete error: trying to delete root dir');
         return false;
     }
     exec('rm -rf ' . $dir);
     db_query("DELETE FROM frs_package WHERE package_id='" . $this->getID() . "'\n\t\t\tAND group_id='" . $this->Group->getID() . "'");
     return true;
 }
示例#3
0
/**
 * release_cvs_file - Remove the file that was checked out from cvs
 * @see checkout_cvs_file
 */
function release_cvs_file($file)
{
    global $scmcvs_proper_commit_loginfo;
    if (!$scmcvs_proper_commit_loginfo) {
        return true;
    }
    // $file is something like /tmp/(tmp_dir)/path/to/file
    // we must delete /tmp/tmp_dir
    if (!preg_match("/^(\\/tmp\\/[^\\/]*)\\/.* /", $file, $result)) {
        // Make sure the dir is under /tmp
        echo "Trying to release a directory not in /tmp. Skipping...";
        return;
    }
    $dir = $result[1];
    // this shouldn't happen... but add it as a security checke
    if (util_is_root_dir($dir)) {
        echo "Trying to delete root dir. Skipping...";
        return;
    }
    $dir = escapeshellarg($dir);
    system("rm -rf " . $dir);
}
示例#4
0
//$repos_type = ' --fs-type fsfs ';
$repos_type = '';
//the name of the access_file
$access_file = $sys_var_path . '/svnroot-access';
$password_file = $sys_var_path . '/svnroot-authfile';
/*
	This script create the gforge dav/svn/docman repositories
*/
$err = "Creating Groups at " . $svn . "\n";
if (empty($sys_apache_user) || empty($sys_apache_group)) {
    $err .= "Error! sys_apache_user Is Not Set Or sys_apache_group Is Not Set!";
    echo $err;
    cron_entry(21, $err);
    exit;
}
if (empty($svn) || util_is_root_dir($svn)) {
    $err .= "Error! svndir_prefix Is Not Set Or Points To The Root Directory!";
    echo $err;
    cron_entry(21, $err);
    exit;
}
$res = db_query("SELECT is_public,enable_anonscm,unix_group_name,groups.group_id \n\tFROM groups, plugins, group_plugin \n\tWHERE groups.status != 'P' \n\tAND groups.group_id=group_plugin.group_id\n\tAND group_plugin.plugin_id=plugins.plugin_id\n\tAND plugins.plugin_name='scmsvn'");
if (!$res) {
    $err .= "Error! Database Query Failed: " . db_error();
    echo $err;
    cron_entry(21, $err);
    exit;
}
//
//	If using a single large repository, create the checkout if necessary
//
示例#5
0
$err = '';
if ($sys_use_ftpuploads) {
    //
    //	Add the groups from the gforge database
    //
    $res = db_query("SELECT group_id,unix_group_name FROM groups WHERE status='A' AND type_id='1'");
    for ($i = 0; $i < db_numrows($res); $i++) {
        $groups[] = db_result($res, $i, 'unix_group_name');
    }
    //
    //	Create home dir for groups
    //
    foreach ($groups as $group) {
        //create an FTP upload dir for this project
        $destdir = $sys_ftp_upload_dir . '/' . $group;
        if (util_is_root_dir($destdir)) {
            $err .= "Trying to access root directory\n";
            continue;
        }
        if (!is_dir($destdir)) {
            if (!@mkdir($destdir)) {
                $err .= 'Could not create dir: ' . $destdir . "\n";
                continue;
            }
            // Unfortunately some versions of PHP don't set the mode properly when
            // specified on the mkdir command, so we need to do it here
            if (!@chmod($destdir, 0770)) {
                $err .= 'Could not chmod dir: ' . $destdir . "\n";
                continue;
            }
            if (!@chown($destdir, $sys_apache_user)) {
示例#6
0
require $gfcommon . 'include/cron_utils.php';
$database = $sys_dbname;
//Database name from local.inc
$username = $sys_dbuser;
//Username used to log on to data base
$password = $sys_dbpasswd;
//Db Password
$datetime = date('Y-m-d');
//we will use this to concatenate it with the tar filename
if (!isset($sys_path_to_backup) || strcmp($sys_path_to_backup, "/") == 0) {
    //	cron_entry(23,'Variable $sys_path_to_backup was not set or it was equal to /.');
    //	exit;
    // Default value
    $sys_path_to_backup = '/gforge-backups/';
}
if (util_is_root_dir($sys_path_to_backup)) {
    $sys_path_to_backup = $sys_path_to_backup . '/';
}
if (!is_dir($sys_path_to_backup)) {
    // try to recursively create it
    $subdirs = explode('/', $sys_path_to_backup);
    $path = '';
    foreach ($subdirs as $subdir) {
        $subdir = trim($subdir);
        if (empty($subdir)) {
            continue;
        }
        $path .= '/' . $subdir;
        if (!file_exists($path)) {
            if (!mkdir($path)) {
                cron_entry(23, 'Couldn\'t create directory ' . $path . ' for backups');
示例#7
0
This file creates user / group permissions by editing 
the /etc/passwd /etc/shadow and /etc/group files
*/
require_once dirname(__FILE__) . '/../../env.inc.php';
require_once $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
//error variable
$err = '';
//
//	Default values for the script
//
define('DEFAULT_SHELL', '/bin/cvssh.pl');
//use /bin/grap for cvs-only
define('FILE_EXTENSION', '.new');
// use .new when testing
if (util_is_root_dir($groupdir_prefix)) {
    $err .= "Error! groupdir_prefix Points To Root Directory!";
    echo $err;
    cron_entry(16, $err);
    exit;
}
//
//	Get the users' unix_name and password out of the database
//   ONLY USERS WITH CVS READ AND COMMIT PRIVS ARE ADDED
//
$res = db_query("SELECT distinct users.user_name,users.unix_pw,users.unix_uid,users.unix_gid,users.user_id\n\tFROM users,user_group,groups\n\tWHERE users.user_id=user_group.user_id \n\tAND user_group.group_id=groups.group_id\n\tAND groups.status='A'\n\tAND user_group.cvs_flags IN ('0','1')\n\tAND users.status='A'\n\tORDER BY users.user_id ASC");
$err .= db_error();
$gforge_users =& util_result_column_to_array($res, 'user_name');
$user_unix_uids =& util_result_column_to_array($res, 'unix_uid');
$user_unix_gids =& util_result_column_to_array($res, 'unix_gid');
$user_pws =& util_result_column_to_array($res, 'unix_pw');