[evolvis-commits] r11236: Added cronjobs to meet Pluging Coding Sta?==?UTF-8?Q?ndards↵
mirabilos at evolvis.org
mirabilos at evolvis.org
Thu Feb 24 18:05:47 CET 2011
Author: mirabilos
Date: 2011-02-24 18:05:47 +0100 (Thu, 24 Feb 2011)
New Revision: 11236
Added:
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvs.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvscreate.sh
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvssh.pl
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/default_page.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ftp_create.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/grap.c
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/history_parse.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ssh_create.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/syncmail
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/usergroup.php
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/www/
trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/www/index.php
Log:
Added cronjobs to meet Pluging Coding Standards
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvs.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvs.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvs.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,242 @@
+#! /usr/bin/php4 -f
+<?php
+/**
+ * GForge Cron Job
+ *
+ * The rest Copyright 2002-2005 (c) GForge Team
+ * http://gforge.org/
+ *
+ * @version $Id$
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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 ('squal_pre.php');
+require ('common/include/cron_utils.php');
+
+require_once('common/include/SCM.class') ;
+
+setup_plugin_manager () ;
+
+$use_cvs_acl = false;
+$maincvsroot = "/cvsroot";
+
+/**
+* Retrieve a file into a temporary directory from a CVS server
+*
+* @param String $repos Repository Name
+* @param String $file File Name
+*
+* return String the FileName in the working repository
+*/
+function getCvsFile($repos,$file) {
+ $actual_dir = getcwd();
+ $tempdirname = tempnam("/tmp","cvstracker");
+ if (!$tempdirname)
+ return false;
+ if (!unlink($tempdirname))
+ return false;
+
+ // Create the temporary directory and returns its name.
+ if (!mkdir($tempdirname))
+ return false;
+
+ if (!chdir($tempdirname))
+ return false;
+ system("cvs -d ".$repos." co ".$file);
+
+ chdir($actual_dir);
+ return $tempdirname."/".$file;
+}
+
+/**
+* putCvsFile commit a file to the repository
+*
+* @param String $repos Repository
+* @param String $file to commit
+* @param String $message to commit
+*/
+function putCvsFile($repos,$file,$message="Automatic updated by cvstracker") {
+ $actual_dir = getcwd();
+ chdir(dirname($file));
+ system("cvs -d ".$repos." ci -m \"".$message."\" ".basename($file));
+ // unlink (basename($file));
+ chdir($actual_dir);
+}
+
+//the directory exists
+if(is_dir($maincvsroot)) {
+ addProjectRepositories();
+} else {
+ if(is_file($maincvsroot)) {
+ $err .= "$maincvsroot exists but is a file\n";
+ exit;
+ } else {
+ if (mkdir($maincvsroot)) {
+ //need to update group permissions using chmod
+ addProjectRepositories();
+ } else {
+ $err .= "unable to make $maincvsroot directory\n";
+ exit;
+ }
+ }
+}
+
+function writeFile($filePath, $content) {
+ $file = fopen($filePath, 'a');
+ flock($file, LOCK_EX);
+ ftruncate($file, 0);
+ rewind($file);
+ if(!empty($content)) {
+ fwrite($file, $content);
+ }
+ flock($file, LOCK_UN);
+ fclose($file);
+}
+
+/**
+*addsyncmail
+*Copyright GForge 2004
+*addsyncmail write to /CVSROOT/loginfo unix_name-commits at lists.gforge.company.com
+*
+*@autor Luis A. Hurtado A. luis at gforgegroup.com
+*@param $unix_group_name Name Group
+*@return void
+*@date 2004-10-25
+*/
+function addsyncmail($unix_group_name) {
+
+ global $sys_lists_host;
+ global $maincvsroot;
+ $loginfo_file=getCvsFile($maincvsroot."/".$unix_group_name,'CVSROOT/loginfo');
+ $pathsyncmail = "ALL ".
+ dirname(__FILE__)."/syncmail -u %p %{sVv} ".
+ $unix_group_name."-commits@".$sys_lists_host."\n";
+ $content = file_get_contents ($loginfo_file);
+ if ( strstr($content, "syncmail") == FALSE) {
+ echo $unix_group_name.":Syncmail not found in loginfo.Adding\n";
+ $content .= "\n#BEGIN Added by cvs.php script\n".
+ $pathsyncmail. "\n#END Added by cvs.php script\n";
+ if(is_file($loginfo_file)){
+ echo $unix_group_name.":About to write the lines\n";
+ writeFile($loginfo_file, $content);
+ }
+ putCvsFile($maincvsroot."/".$unix_group_name,$loginfo_file);
+ } else {
+ echo "Syncmail Found!\n";
+ }
+
+}
+
+function addProjectRepositories() {
+ global $maincvsroot;
+ global $use_cvs_acl;
+
+ $res = db_query("select groups.group_id,groups.unix_group_name,groups.enable_anonscm,groups.enable_pserver".
+ " FROM groups, plugins, group_plugin".
+ " WHERE groups.status != 'P' ".
+ " AND groups.group_id=group_plugin.group_id ".
+ " AND group_plugin.plugin_id=plugins.plugin_id ".
+ " AND plugins.plugin_name='scmcvs'");
+
+ for($i = 0; $i < db_numrows($res); $i++) {
+ /*
+ Simply call cvscreate.sh
+ */
+
+ $project = &group_get_object(db_result($res,$i,'group_id')); // get the group object for the current group
+
+ if ( (!$project) || (!is_object($project)) ) {
+ echo "Error Getting Group." . " Id : " . db_result($res,$i,'group_id') . " , Name : " . db_result($res,$i,'unix_group_name');
+ break; // continue to the next project
+ }
+
+ $repositoryPath = $maincvsroot."/".$project->getUnixName();
+ if (is_dir($repositoryPath)) {
+ $writersContent = '';
+ $readersContent = '';
+ $passwdContent = '';
+ if($project->enableAnonSCM()) {
+ $repositoryMode = 02775;
+ if ($project->enablePserver()) {
+ $readersContent = 'anonymous';
+ $passwdContent = 'anonymous:8Z8wlZezt48mY';
+ }
+ } else {
+ $repositoryMode = 02770;
+ }
+ chmod($repositoryPath, $repositoryMode);
+ writeFile($repositoryPath.'/CVSROOT/writers', $writersContent);
+ writeFile($repositoryPath.'/CVSROOT/readers', $readersContent);
+ writeFile($repositoryPath.'/CVSROOT/passwd', $passwdContent);
+ addsyncmail($project->getUnixName());
+ $hookParams['group_id']=$project->getID();
+ $hookParams['file_name']=$repositoryPath;
+ plugin_hook("update_cvs_repository",$hookParams);
+ } elseif (is_file($repositoryPath)) {
+ $err .= $repositoryPath.' already exists as a file';
+ } else {
+ system('./cvscreate.sh '.
+ $project->getUnixName().
+ ' '.($project->getID()+50000).
+ ' '.$project->enableAnonSCM().
+ ' '.$project->enablePserver());
+ addsyncmail($project->getUnixName());
+ $hookParams['group_id']=$project->getID();
+ $hookParams['file_name']=$repositoryPath;
+ plugin_hook("update_cvs_repository",$hookParams);
+ if ($use_cvs_acl == true) {
+ system ("cp ".dirname($_SERVER['_']).
+ "/aclconfig.default ".$repositoryPath.'/CVSROOT/aclconfig');
+ $res_admins = db_query("SELECT users.user_name FROM users,user_group ".
+ "WHERE users.user_id=user_group.user_id AND ".
+ "user_group.group_id='".$project->getID()."'");
+ $useradmin_group = db_result($res_admins,0,'user_name');
+ system("cvs -d ".$repositoryPath." racl ".$useradmin_group.":p -r ALL -d ALL");
+ }
+ }
+ }
+}
+
+// return's true if it's ok to write the file
+function checkLoginfo($file_name) {
+ if (!file_exists($file_name)) {
+ // files does't exist, it's ok to write it
+ return true;
+ } else { // check if file is empty or commented out
+ $file = @fopen($file_name, 'r');
+ if (!$file) { // couldn't open file
+ return false;
+ }
+
+ while (!feof($file)) {
+ $content = trim(fgets($file, 4096));
+ if (strlen($content) > 1) {
+ if ($content{0} != '#') { // it's not a comment
+ fclose($file);
+ return false;
+ }
+ }
+ }
+ fclose($file);
+ return true;
+ }
+}
+
+cron_entry(13,$err);
+
+?>
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvs.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvscreate.sh
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvscreate.sh (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvscreate.sh 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,63 @@
+#!/bin/sh
+echo ""
+echo "CVS Repository Tool"
+echo "Portions (c)1999 SourceForge Development Team"
+echo "The rest (c)2004 Guillaume Smet"
+echo "Released under the GPL, 1999"
+echo ""
+
+# if no arguments, print out help screen
+if test $# -lt 4; then
+ echo "usage:"
+ echo " cvscreate.sh [repositoryname] [groupid] [isanonymousenabled] [ispserverenabled]"
+ echo ""
+ exit 1
+fi
+
+repositoryname=$1
+repositorypath=/cvsroot/$1
+groupid=$2
+isanonymousenabled=$3
+ispserverenabled=$4
+
+function setPserverAccess() {
+ writers=""
+ readers=""
+ passwd=""
+ if [[ $isanonymousenabled -eq 1 && $ispserverenabled -eq 1 ]] ; then
+ readers="anonymous::anonymous"
+ passwd="anonymous:\$1\$0H\$2/LSjjwDfsSA0gaDYY5Df/:anonymous"
+ fi
+ echo $writers > $repositorypath/CVSROOT/writers
+ echo $readers > $repositorypath/CVSROOT/readers
+ echo $passwd > $repositorypath/CVSROOT/passwd
+}
+
+function setRepositoryAccess() {
+ if [ $isanonymousenabled -eq 1 ] ; then
+ # make the repository user and group writable and world readable
+ chmod 2775 $repositorypath
+ else
+ # make the repository user and group writable but not accessible to other users
+ chmod 2770 $repositorypath
+ fi
+}
+
+function createRepository() {
+ mkdir $repositorypath
+ setRepositoryAccess
+ cvs -d$repositorypath init
+ setPserverAccess
+ echo "" > $repositorypath/CVSROOT/val-tags
+ chmod 664 $repositorypath/CVSROOT/val-tags
+ chown -R nobody:$groupid $repositorypath
+}
+
+if [ -d $repositorypath ] ; then
+ echo "$repositoryname already exists."
+ setRepositoryAccess
+ setPserverAccess
+ echo ""
+else
+ createRepository
+fi
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvscreate.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvssh.pl
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvssh.pl (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvssh.pl 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,50 @@
+#! /usr/bin/perl -w
+#
+# $Id$
+#
+# "Shell" for a restricted account, limiting the available commands
+# Roland Mas, debian-sf (Sourceforge for Debian)
+#
+# Inspired from the grap.c file in Sourceforge 2.5
+
+use strict ;
+use vars qw/ @allowed_options @allowed_commands $errmsg @cmd / ;
+use subs qw/ &reject / ;
+no locale ;
+
+ at allowed_options = ('-c', '-e') ;
+ at allowed_commands = ('cvs') ;
+
+# Clean up our environment
+delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
+
+if ($#ARGV != 1) {
+ if ($#ARGV < 1) {
+ $errmsg = "Not enough arguments." ;
+ } else {
+ $errmsg = "Too many arguments." ;
+ }
+ &reject ;
+}
+
+if (scalar (grep { $_ eq $ARGV[0] } @allowed_options) == 0) {
+ $errmsg = "Option not allowed." ;
+ &reject ;
+}
+
+ at cmd = split (/ +/, $ARGV[1]) ;
+
+if (scalar (grep { $_ eq $cmd[0] } @allowed_commands) == 0) {
+ $errmsg = "Command not allowed." ;
+ &reject ;
+}
+
+exec @cmd ;
+
+sub reject {
+ print "This is a restricted account.\n" .
+ "You cannot execute anything here.\n" .
+ # $errmsg . "\n" .
+ "Goodbye.\n" ;
+ exit 1 ;
+}
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/cvssh.pl
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/default_page.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/default_page.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/default_page.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,197 @@
+<?php
+
+$domain=ereg_replace('[^\.]*\.(.*)$','\1',$_SERVER['HTTP_HOST']);
+$group_name=ereg_replace('([^\.]*)\..*$','\1',$_SERVER['HTTP_HOST']);
+
+echo '<?xml version="1.0" encoding="UTF-8"?>';
+?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en ">
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title><?php echo $project_name; ?></title>
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ function help_window(helpurl) {
+ HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
+ }
+ // -->
+ </script>
+
+<style type="text/css">
+ <!--
+ BODY {
+ margin-top: 3;
+ margin-left: 3;
+ margin-right: 3;
+ margin-bottom: 3;
+ background: #01004e;
+ }
+ ol,ul,p,body,td,tr,th,form { font-family: verdana,arial,helvetica,sans-serif; font-size:small;
+ color: #333333; }
+
+ h1 { font-size: x-large; font-family: verdana,arial,helvetica,sans-serif; }
+ h2 { font-size: large; font-family: verdana,arial,helvetica,sans-serif; }
+ h3 { font-size: medium; font-family: verdana,arial,helvetica,sans-serif; }
+ h4 { font-size: small; font-family: verdana,arial,helvetica,sans-serif; }
+ h5 { font-size: x-small; font-family: verdana,arial,helvetica,sans-serif; }
+ h6 { font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; }
+
+ pre,tt { font-family: courier,sans-serif }
+
+ a:link { text-decoration:none }
+ a:visited { text-decoration:none }
+ a:active { text-decoration:none }
+ a:hover { text-decoration:underline; color:red }
+
+ .titlebar { color: black; text-decoration: none; font-weight: bold; }
+ a.tablink { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tablink:visited { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tablink:hover { text-decoration: none; color: black; font-weight: bold; font-size: x-small; }
+ a.tabsellink { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tabsellink:visited { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tabsellink:hover { text-decoration: none; color: black; font-weight: bold; font-size: x-small; }
+ -->
+</style>
+
+</head>
+
+<body>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="0">
+
+ <tr>
+ <td><a href="/"><img src="http://<?php echo $domain; ?>/themes/gforge/images/logo.png" border="0" alt="" width="198" height="52" /></a></td>
+ </tr>
+
+</table>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="0">
+
+ <tr>
+ <td> </td>
+ <td colspan="3">
+
+
+
+ <!-- start tabs -->
+
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/topleft.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#E0E0E0" width="30"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="30" height="1" alt="" /></td>
+ <td bgcolor="#E0E0E0"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="1" height="1" alt="" /></td>
+ <td bgcolor="#E0E0E0" width="30"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="30" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/topright.png" height="9" width="9" alt="" /></td>
+ </tr>
+
+ <tr>
+
+ <!-- Outer body row -->
+
+ <td bgcolor="#E0E0E0"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="10" height="1" alt="" /></td>
+ <td valign="top" width="99%" bgcolor="#E0E0E0" colspan="3">
+
+ <!-- Inner Tabs / Shell -->
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="0">
+ <tr>
+ <td align="left" bgcolor="#ffffff" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#ffffff"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#ffffff" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/topright-inner.png" height="9" width="9" alt="" /></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="#ffffff"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="10" height="1" alt="" /></td>
+ <td valign="top" width="99%" bgcolor="white">
+
+ <!-- whole page table -->
+<table width="100%" cellpadding="5" cellspacing="0" border="0">
+<tr><td width="65%" valign="top">
+<?php if ($handle=fopen('http://'.$domain.'/export/projtitl.php?group_name='.$group_name,'r')){
+$contents = '';
+while (!feof($handle)) {
+ $contents .= fread($handle, 8192);
+}
+fclose($handle);
+echo $contents; } ?>
+
+<?php if ($handle=fopen('http://'.$domain.'/export/projnews.php?group_name='.$group_name,'r')){
+$contents = '';
+while (!feof($handle)) {
+ $contents .= fread($handle, 8192);
+}
+fclose($handle);
+$contents=str_replace('href="/','href="http://'.$domain.'/',$contents);
+echo $contents; } ?>
+
+</td>
+
+<td width="35%" valign="top">
+
+ <table cellspacing="0" cellpadding="1" width="100%" border="0" bgcolor="#d5d5d7">
+ <tr><td>
+ <table cellspacing="0" cellpadding="2" width="100%" border="0" bgcolor="#eaecef">
+ <tr style="background-color:#d5d5d7" align="center">
+ <td colspan="2"><span class="titlebar">Project Summary</span></td>
+ </tr>
+ <tr align="left">
+ <td colspan="2">
+
+<?php if($handle=fopen('http://'.$domain.'/export/projhtml.php?group_name='.$group_name,'r')){
+$contents = '';
+while (!feof($handle)) {
+ $contents .= fread($handle, 8192);
+}
+fclose($handle);
+$contents=str_replace('href="/','href="http://'.$domain.'/',$contents);
+$contents=str_replace('src="/','src="http://'.$domain.'/',$contents);
+echo $contents; } ?>
+
+ </td>
+ </tr>
+ </table>
+ </td></tr>
+ </table><p> </p>
+</td></tr></table>
+ <p>
+ <center>
+ <a href="http://gforgegroup.com/"><img src="http://gforge.org/pro/gforgebanner.jpg" height="60" width="468" border="0" alt="GForge Group Professional Services" /></a><br /><br />
+ </center>
+ <!-- end main body row -->
+
+
+ </td>
+ <td width="10" bgcolor="#ffffff"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="2" height="1" alt="" /></td>
+ </tr>
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
+ <td bgcolor="#ffffff"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
+ </tr>
+ </table>
+
+ <!-- end inner body row -->
+
+ </td>
+ <td width="10" bgcolor="#E0E0E0"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="2" height="1" alt="" /></td>
+ </tr>
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/bottomleft.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#E0E0E0" colspan="3"><img src="http://<?php echo $domain; ?>/themes/gforge/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="http://<?php echo $domain; ?>/themes/gforge/images/tabs/bottomright.png" height="9" width="9" alt="" /></td>
+ </tr>
+</table>
+
+<!-- PLEASE LEAVE "Powered By GForge" on your site -->
+<br />
+<center>
+<a href="http://gforge.org/"><img src="http://gforge.org/images/pow-gforge.png" alt="Powered By GForge Collaborative Development Environment" border="0" /></a>
+</center>
+
+
+</body>
+</html>
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/default_page.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ftp_create.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ftp_create.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ftp_create.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,79 @@
+#! /usr/bin/php4 -f
+<?php
+/**
+ * GForge Cron Job
+ *
+ * The rest Copyright 2002-2005 (c) GForge Team
+ * http://gforge.org/
+ *
+ * @version $Id$
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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
+ */
+
+/*
+ This file creates the root directories for the FTP
+*/
+require_once('squal_pre.php');
+require ('common/include/cron_utils.php');
+
+$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)) {
+ $err .= 'Could not chown dir: '.$destdir."\n";
+ continue;
+ }
+ if (!@chgrp($destdir, $sys_apache_group)) {
+ $err .= 'Could not chgrp dir: '.$destdir."\n";
+ continue;
+ }
+ }
+ }
+}
+?>
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/grap.c
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/grap.c (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/grap.c 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,168 @@
+/* graplite - General execution wRAPper LITE!
+ * Copyright (C) 1999 Lion Templin <lion at leonine.com>
+ * FILE: graplite.c
+ * VERSION : 0.1 (991111)
+ *
+ * $Id$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * GOTO FOREVER!
+ *
+ * Coded on Northwest Airlines Flight 1065, CHI to MSP
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* grap is a wrapper designed to verify commands before passing them to system()
+ or just reporting the accepted command. grap will report an error if the
+ input is invalid. It checks for string lengths (prevent overflows),
+ specific sets of options and commands.
+
+ grap, in full force, is called as: <grap> <option> "<command> <arguments
+ list ... >" Where <grap> is this program, <option> is an optional trap
+ for a single option (like "-e" or "-c" used by programs that call shells,
+ subject to the approval list below), <command> is the command wished to
+ be run (subject to the approval list below), and <arguments list .. > is
+ the list of args passed to <command>. All are optional, allowing for
+ forms such as:
+ graplite -e "foo" graplite "foo bar" graplite -e "foo -c foo -f bar"
+ <g ><o ><cmd> <g > <cmd/args> <g ><o> <cmd/ args >
+
+ <options> and <command> need to be exact matched to those in the
+ acceptance list.
+*/
+
+/* Define the locations of <option> <command> and <arguements list .. >
+ on the command line. 0 is this program, begin at 1. Note that
+ ARGS_ARGC takes everything FROM that position to the end of the
+ arguments.
+
+ Undefine any of these to not use them.
+*/
+
+#define OPTION_ARGC 1
+#define ARGS_ARGC 2
+
+#define ARGS_ARE_SINGLE_STRING
+
+/* Define how the <arguements list .. > is checked.
+ define ARGS_ALNUMOK for A-Za-z0-9 to be OK
+ define any other chars in the string ARGS_CHAROK
+
+ Turn both these off to accept everything.
+ WARNING, might be able to bad things with
+ shell special chars such as & ; , etc.
+*/
+
+#define MAXSTRLEN 256 /* maximum single string length
+ (no max on final command) */
+/* Define what strings are acceptable in <option> */
+char *options[] = { "-c", "-e", NULL };
+
+/* Define what strings are acceptable in <command>
+ define an optional execution path CMD_PATH if desired */
+char *commands[] = { "cvs", "server", "svnserve", NULL };
+
+#define MAXARGS 256
+
+/* NO USER SERVICEABLE PARTS BELOW --------------------------------- */
+
+
+#define GRAP_TRUE 1
+#define GRAP_FALSE 0
+#define CMD_POS 0
+
+int main(int argc, char *argv[]) {
+
+ int i, j, n, argslen, flag;
+ char *buf;
+ char **args[MAXARGS];
+
+
+ if(argc < 3) {
+ /* printf("FATAL: %s bailed because not enough options.\n", argv[0]); */
+
+ printf("\nWelcome to GForge SCM\n\n");
+ printf("This is a restricted Shell Account\n");
+ printf("You cannot execute anything here.\n\n");
+
+ exit(1);
+ }
+
+
+ /* process the initial option (see options array) */
+
+ i = -1;
+ while((options[++i] != NULL) && strncmp(options[i], argv[OPTION_ARGC], MAXSTRLEN));
+ if(options[i] == NULL || strlen(argv[OPTION_ARGC]) > MAXSTRLEN) {
+ /* printf("FATAL: %s bailed because options didn't qualify.\n", argv[0]); */
+
+ printf("\nWelcome to GForge SCM\n\n");
+ printf("This is a restricted Shell Account\n");
+ printf("You cannot execute anything here.\n\n");
+
+ exit(1);
+ }
+
+ /* break single command and args string into seperate strings
+ in a char** for execvp() to use */
+
+ i = 0;
+ flag = GRAP_TRUE;
+ buf = argv[ARGS_ARGC];
+
+ j = CMD_POS;
+ n = 0;
+
+ while(buf[i] != 0 && j < MAXARGS) {
+ if(buf[i] == ' ') {
+ buf[i] = 0;
+ flag = GRAP_TRUE;
+ } else
+ if(flag) {
+ args[j++] = (char **)&buf[i];
+ flag = GRAP_FALSE;
+ args[j] = NULL;
+ n++;
+ }
+ i++;
+ }
+
+ /* check the command to insure it's in the acceptance list */
+
+ i = -1;
+ while((options[++i] != NULL) && strncmp(commands[i], args[CMD_POS], MAXSTRLEN));
+ if(options[i] == NULL || strlen((char *)args[CMD_POS]) > MAXSTRLEN) {
+
+ /* printf("FATAL: %s bailed because command didn't qualify.\n", args[CMD_POS]); */
+
+ printf("\nWelcome to GForge SCM\n\n");
+ printf("This is a restricted Shell Account\n");
+ printf("You cannot execute anything here.\n\n");
+
+ exit(1);
+ }
+
+
+ /* ok, the command is clear, exec() it */
+
+ execvp((char *)args[CMD_POS], (char **)args);
+
+}
+
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/grap.c
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/history_parse.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/history_parse.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/history_parse.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,299 @@
+#!/usr/bin/php -q
+<?php
+
+require_once('squal_pre.php');
+require ('common/include/cron_utils.php');
+
+/**
+ *
+ * Recurses through the /cvsroot directory tree and parses each projects
+ * '~/CVSROOT/history' file, building agregate stats on the number of
+ * checkouts, commits, and adds to each project over the past 24 hours.
+ *
+ * @version $Id$
+ */
+
+$ARGV = $GLOBALS['argv'];
+$err = '';
+$verbose = 1;
+$debug = 1;
+$cvsroot = "/cvsroot";
+
+function debug($message) {
+ global $debug, $err;
+ if($debug) {
+ $err .= $message."\n";
+ }
+}
+
+
+function get_all_days(){
+
+ global $cvsroot;
+ global $err;
+ global $verbose;
+ global $debug;
+
+ $all_days = array();
+ $root_dir =& opendir( $cvsroot );
+ while ( $group = readdir( $root_dir ) ) {
+ if ( $group == '.' || $group == '..' )
+ continue;
+ if ( ! is_dir( "$cvsroot/$group" ) )
+ continue;
+
+ // opening CVSROOT/history file for the current repository
+ $hist_file_path = $cvsroot.'/'.$group.'/CVSROOT/history';
+ if( !file_exists($hist_file_path) || !is_readable($hist_file_path) || filesize($hist_file_path) == 0) {
+ debug('History file for group '.$group.' does not exist or is not readable');
+ continue;
+ }
+ $hist_file =& fopen( $hist_file_path, 'r' );
+ if ( ! $hist_file ) {
+ debug('Cannot open history file');
+ continue;
+ }
+ $hist_cont = fread( $hist_file, filesize( $hist_file_path ) );
+ fclose( $hist_file );
+ $hist_lines = explode( "\n", $hist_cont );
+
+ // analyzing history file
+ foreach ( $hist_lines as $hist_line ) {
+ if ( preg_match( '/^\s*$/', $hist_line ) ) {
+ continue;
+ }
+ list( $cvstime,$user,$curdir,$module,$rev,$file ) = explode( '|', $hist_line );
+
+ $time_parsed = hexdec( substr($cvstime, 1, 8) );
+
+ $day = gmmktime( 0, 0, 0, gmstrftime("%m", $time_parsed ), gmstrftime("%d", $time_parsed ), gmstrftime("%Y", $time_parsed ) );
+
+ if(!in_array($day, $all_days))
+ array_push($all_days, $day);
+
+ }
+
+ }
+
+ return $all_days;
+}
+
+function process_day($day_begin, $day_end){
+
+ global $cvsroot;
+ global $err;
+ global $verbose;
+ global $debug;
+
+
+ $year = gmstrftime("%Y", $day_begin );
+ $month = gmstrftime("%m", $day_begin );
+ $day = gmstrftime("%d", $day_begin );
+
+ $month_string = sprintf( "%04d%02d", $year, $month );
+
+ if($verbose) {
+ $err .= "Parsing cvs logs looking for traffic on day $day, " .
+ "month $month, year $year.\n";
+ }
+
+ $rollback = false;
+
+ $root_dir =& opendir( $cvsroot );
+ while ( $group = readdir( $root_dir ) ) {
+ if ( $group == '.' || $group == '..' )
+ continue;
+ if ( ! is_dir( "$cvsroot/$group" ) )
+ continue;
+
+ debug('Working on group '.$group);
+
+ // trying to find the id of the group matching current repository name
+ $group_res = db_query( "SELECT group_id FROM groups WHERE
+ unix_group_name='$group' AND
+ status='A'" );
+ $group_id_row_count = db_numrows($group_res);
+ if ( $group_id_row = db_fetch_array($group_res) ) {
+ $group_id = $group_id_row[0];
+ } else {
+ $err .= "Group $group does not appear to be active... skipping.\n";
+ continue;
+ }
+ if ( $group_id_row_count > 1 ) {
+ $err .= "Group results are ambiguous... using group_id $group_id.\n";
+ }
+
+ $cvs_co = 0;
+ $cvs_commit = 0;
+ $cvs_add = 0;
+ $usr_commit = array();
+ $usr_add = array();
+
+ // opening CVSROOT/history file for the current repository
+ $hist_file_path = $cvsroot.'/'.$group.'/CVSROOT/history';
+ if( !file_exists($hist_file_path) || !is_readable($hist_file_path) || filesize($hist_file_path) == 0) {
+ debug('History file for group '.$group.' does not exist or is not readable');
+ continue;
+ }
+ $hist_file =& fopen( $hist_file_path, 'r' );
+ if ( ! $hist_file ) {
+ debug('Cannot open history file');
+ continue;
+ }
+ $hist_cont = fread( $hist_file, filesize( $hist_file_path ) );
+ fclose( $hist_file );
+ $hist_lines = explode( "\n", $hist_cont );
+
+ // cleaning stats_cvs_* table for the current day to avoid conflicting index problem
+ $sql = "DELETE FROM stats_cvs_group
+ WHERE month = '$month_string'
+ AND day = '$day'
+ AND group_id = '$group_id'";
+ $res = db_query($sql);
+ if(!$res) {
+ $err .= 'Error cleaning stats_cvs_group for current day and current group: '.db_error();
+ }
+
+ $sql = "DELETE FROM stats_cvs_user
+ WHERE month = '$month_string'
+ AND day = '$day'
+ AND group_id = '$group_id'";
+ $res = db_query($sql);
+ if(!$res) {
+ $err .= 'Error cleaning stats_cvs_user for current day and current group: '.db_error();
+ }
+
+ // analyzing history file
+ foreach ( $hist_lines as $hist_line ) {
+ if ( preg_match( '/^\s*$/', $hist_line ) ) {
+ continue;
+ }
+ list( $cvstime,$user,$curdir,$module,$rev,$file ) = explode( '|', $hist_line );
+
+ $type = substr($cvstime, 0, 1);
+ $time_parsed = hexdec( substr($cvstime, 1, 8) );
+
+ if ( ($time_parsed > $day_begin) && ($time_parsed < $day_end) ) {
+ if ( $type == 'M' ) {
+ $cvs_commit++;
+ $usr_commit[$user]++;
+ } elseif ( $type == 'A' ) {
+ $cvs_add++;
+ $usr_add[$user]++;
+ } elseif ( $type == 'O' ) {
+ $cvs_co++;
+ // ignoring checkouts on a per-user
+ }
+ } elseif ( $time_parsed > $day_end ) {
+ if ( $verbose >= 2 ) {
+ $err .= "Short circuting execution, parsed date " .
+ "exceeded current threshold.\n";
+ }
+ break;
+ }
+ }
+
+ // if we don't have any stats, skipping to next project
+ if($cvs_co == 0 && $cvs_add == 0 && $cvs_commit == 0) {
+ $err .= "No CVS stats for group ".$group.", skipping to next project";
+ continue;
+ }
+
+ // inserting group results in stats_cvs_groups
+ $sql = "INSERT INTO stats_cvs_group
+ (month,day,group_id,checkouts,commits,adds)
+ VALUES
+ ('$month_string',
+ '$day',
+ '$group_id',
+ '$cvs_co',
+ '$cvs_commit',
+ '$cvs_add')";
+
+ debug($sql);
+ if ( !db_query( $sql ) ) {
+ $err .= 'Insertion in stats_cvs_group failed: '.$sql.' - '.db_error();
+ $rollback = true;
+ break;
+ }
+
+ // building the user list
+ $user_list = array_unique( array_merge( array_keys( $usr_add ), array_keys( $usr_commit ) ) );
+
+ foreach ( $user_list as $user ) {
+ // trying to get user id from user name
+ $user_res = db_query( "SELECT user_id FROM users WHERE
+ user_name='$user'" );
+ if ( $user_row = db_fetch_array($user_res) ) {
+ $user_id = $user_row[0];
+ } else {
+ $err .= "User $user was not found... skipping.\n";
+ continue;
+ }
+
+ $sql = "INSERT INTO stats_cvs_user
+ (month,day,group_id,user_id,commits,adds) VALUES
+ ('$month_string',
+ '$day',
+ '$group_id',
+ '$user_id',
+ '" . ($usr_commit{$user}?$usr_commit{$user}:0) . "',
+ '" . ($usr_add{$user}?$usr_add{$user}:0) . "')";
+
+ debug($sql);
+ if ( !db_query( $sql )) {
+ $err .= 'Insertion in stats_cvs_user failed: '.$sql.' - '.db_error();
+ $rollback = true;
+ break 2;
+ }
+
+ }
+ }
+ return $rollback;
+}
+
+db_begin();
+
+if ( $ARGV[1] && $ARGV[2] && $ARGV[3] ) {
+
+ $day_begin = gmmktime( 0, 0, 0, $ARGV[2], $ARGV[3], $ARGV[1] );
+ // $day_begin = timegm( 0, 0, 0, $ARGV[2], $ARGV[1] - 1, $ARGV[0] - 1900 );
+ $day_end = $day_begin + 86400;
+
+ $rollback = process_day($day_begin, $day_end);
+} else if($ARGV[1]=='all' && !$ARGV[2] && !$ARGV[3]) {
+
+ $all_days = &get_all_days();
+ foreach ( $all_days as $day ) {
+ echo $day;
+ $rollback = process_day($day, $day + 86400);
+
+ if($rollback)
+ break;
+
+ }
+
+} else {
+
+ $local_time = localtime();
+ ## Start at midnight last night.
+ $day_end = gmmktime( 0, 0, 0, $local_time[4] + 1, $local_time[3], $local_time[5] );
+
+ // $day_end = gmmktime( 0, 0, 0, (gmtime( time() ))[3,4,5] );
+ ## go until midnight yesterday.
+ $day_begin = $day_end - 86400;
+ // $day_begin = timegm( 0, 0, 0, (gmtime( time() - 86400 ))[3,4,5] );
+
+ $rollback = process_day($day_begin, $day_end);
+
+}
+
+if ( $rollback ) {
+ db_rollback();
+} else {
+ db_commit();
+}
+
+cron_entry(14,$err);
+
+?>
\ No newline at end of file
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/history_parse.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ssh_create.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ssh_create.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ssh_create.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,70 @@
+#! /usr/bin/php4 -f
+<?php
+/**
+ * GForge Cron Job
+ *
+ * The rest Copyright 2002-2005 (c) GForge Team
+ * http://gforge.org/
+ *
+ * @version $Id$
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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_once('squal_pre.php');
+require ('common/include/cron_utils.php');
+
+$res=db_query("SELECT user_name,user_id,authorized_keys
+ FROM users
+ WHERE authorized_keys != ''
+ AND 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");
+ system("chown $username:users $ssh_dir");
+ system("chmod 0644 $ssh_dir/authorized_keys");
+ system("chown $username:users $ssh_dir/authorized_keys");
+
+}
+
+cron_entry(15,$err);
+
+?>
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/ssh_create.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/syncmail
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/syncmail (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/syncmail 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,434 @@
+#! /usr/bin/python
+
+# Copyright (c) 2002, 2003, 2004 Barry Warsaw, Fred Drake, and contributors
+# All rights reserved.
+# See the accompanying LICENSE file for details.
+
+# NOTE: SourceForge currently runs Python 2.2.3, so we need to remain
+# compatible with the Python 2.2 line.
+
+"""Complicated notification for CVS checkins.
+
+This script is used to provide email notifications of changes to the CVS
+repository. These email changes will include context diffs of the changes.
+Really big diffs will be trimmed.
+
+This script is run from a CVS loginfo file (see $CVSROOT/CVSROOT/loginfo). To
+set this up, create a loginfo entry that looks something like this:
+
+ mymodule /path/to/this/script %%s some-email-addr at your.domain
+
+In this example, whenever a checkin that matches `mymodule' is made, this
+script is invoked, which will generate the diff containing email, and send it
+to some-email-addr at your.domain.
+
+ Note: This module used to also do repository synchronizations via
+ rsync-over-ssh, but since the repository has been moved to SourceForge,
+ this is no longer necessary. The syncing functionality has been ripped
+ out in the 3.0, which simplifies it considerably. Access the 2.x versions
+ to refer to this functionality. Because of this, the script is misnamed.
+
+It no longer makes sense to run this script from the command line. Doing so
+will only print out this usage information.
+
+Usage:
+
+ %(PROGRAM)s [options] <%%S> email-addr [email-addr ...]
+
+Where options are:
+
+ --cvsroot=<path>
+ Use <path> as the environment variable CVSROOT. Otherwise this
+ variable must exist in the environment.
+
+ --context=#
+ -C #
+ Include # lines of context around lines that differ (default: 2).
+
+ -c
+ Produce a context diff (default).
+
+ -m hostname
+ --mailhost hostname
+ The hostname of an available SMTP server. The default is
+ 'localhost'.
+
+ -u
+ Produce a unified diff (smaller).
+
+ -S TEXT
+ --subject-prefix=TEXT
+ Prepend TEXT to the email subject line.
+
+ -R ADDR
+ --reply-to=ADDR
+ Add a "Reply-To: ADDR" header to the email message.
+
+ --quiet / -q
+ Don't print as much status to stdout.
+
+ --fromhost=hostname
+ -f hostname
+ The hostname that email messages appear to be coming from. The From:
+ header of the outgoing message will look like user at hostname. By
+ default, hostname is the machine's fully qualified domain name.
+
+ --help / -h
+ Print this text.
+
+The rest of the command line arguments are:
+
+ <%%S>
+ CVS %%s loginfo expansion. When invoked by CVS, this will be a single
+ string containing the directory the checkin is being made in, relative
+ to $CVSROOT, followed by the list of files that are changing. If the
+ %%s in the loginfo file is %%{sVv}, context diffs for each of the
+ modified files are included in any email messages that are generated.
+
+ email-addrs
+ At least one email address.
+"""
+__version__ = '$Revision$'
+
+import os
+import re
+import pwd
+import sys
+import time
+import getopt
+import socket
+import smtplib
+
+from cStringIO import StringIO
+from email.Utils import formataddr
+
+# Which SMTP server to do we connect to?
+MAILHOST = 'localhost'
+MAILPORT = 25
+
+# Diff trimming stuff
+DIFF_HEAD_LINES = 20
+DIFF_TAIL_LINES = 20
+DIFF_TRUNCATE_IF_LARGER = 1000
+
+COMMASPACE = ', '
+
+PROGRAM = sys.argv[0]
+
+BINARY_EXPLANATION_LINES = [
+ "(This appears to be a binary file; contents omitted.)\n"
+ ]
+
+NOVERSION = "Couldn't generate diff; no version number found for file: %s"
+BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s"
+
+
+
+def usage(code, msg=''):
+ print __doc__ % globals()
+ if msg:
+ print msg
+ sys.exit(code)
+
+
+
+def calculate_diff(entry, contextlines):
+ file = entry.name
+ oldrev = entry.revision
+ newrev = entry.new_revision
+
+ # Make sure we can find a CVS version number
+ if oldrev is None and newrev is None:
+ return NOVERSION % file
+
+ if file.find("'") <> -1:
+ # Those crazy users put single-quotes in their file names! Now we
+ # have to escape everything that is meaningful inside double-quotes.
+ filestr = filestr.replace('\\', '\\\\')
+ filestr = filestr.replace('`', '\`')
+ filestr = filestr.replace('"', '\"')
+ filestr = filestr.replace('$', '\$')
+ # and quote it with double-quotes.
+ filestr = '"' + filestr + '"'
+ else:
+ # quote it with single-quotes.
+ filestr = "'" + file + "'"
+ if oldrev is None:
+ # File is being added.
+ try:
+ if os.path.exists(file):
+ fp = open(file)
+ else:
+ update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr)
+ fp = os.popen(update_cmd)
+ lines = fp.readlines()
+ fp.close()
+ # Is this a binary file? Let's look at the first few
+ # lines to figure it out:
+ for line in lines[:5]:
+ for c in line.rstrip():
+ if c.isspace():
+ continue
+ if c < ' ' or c > chr(127):
+ lines = BINARY_EXPLANATION_LINES[:]
+ break
+ lines.insert(0, '--- NEW FILE: %s ---\n' % file)
+ except IOError, e:
+ lines = ['***** Error reading new file: ',
+ str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()]
+ elif newrev is None:
+ lines = ['--- %s DELETED ---\n' % file]
+ else:
+ # File has been changed.
+ # This /has/ to happen in the background, otherwise we'll run into CVS
+ # lock contention. What a crock.
+ if contextlines > 0:
+ difftype = "-C " + str(contextlines)
+ else:
+ difftype = "-u"
+ diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \
+ % (difftype, oldrev, newrev, filestr)
+ fp = os.popen(diffcmd)
+ lines = fp.readlines()
+ # ignore the error code, it always seems to be 1 :(
+ fp.close()
+ if len(lines) > DIFF_TRUNCATE_IF_LARGER:
+ removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES
+ del lines[DIFF_HEAD_LINES:-DIFF_TAIL_LINES]
+ lines.insert(DIFF_HEAD_LINES,
+ '[...%d lines suppressed...]\n' % removedlines)
+ return ''.join(lines)
+
+
+
+rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]')
+
+def quotename(name):
+ if name and rfc822_specials_re.search(name):
+ return '"%s"' % name.replace('"', '\\"')
+ else:
+ return name
+
+
+
+def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
+ # cannot wait for child process or that will cause parent to retain cvs
+ # lock for too long. Urg!
+ if not os.fork():
+ # in the child
+ # give up the lock you cvs thang!
+ time.sleep(2)
+ # Create the smtp connection to the localhost
+ conn = smtplib.SMTP()
+ conn.connect(MAILHOST, MAILPORT)
+ pwinfo = pwd.getpwuid(os.getuid())
+ user = pwinfo[0]
+ name = pwinfo[4]
+ domain = fromhost or socket.getfqdn()
+ address = '%s@%s' % (user, domain)
+ s = StringIO()
+ datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000',
+ time.gmtime(time.time()))
+ vars = {'author' : formataddr((name, address)),
+ 'people' : COMMASPACE.join(people),
+ 'subject' : subject,
+ 'version' : __version__,
+ 'date' : datestamp,
+ }
+ print >> s, '''\
+From: %(author)s
+To: %(people)s''' % vars
+ if replyto:
+ print >> s, 'Reply-To: %s' % replyto
+ print >>s, '''\
+Subject: %(subject)s
+Date: %(date)s
+X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail>
+''' % vars
+ s.write(sys.stdin.read())
+ # append the diffs if available
+ print >> s
+ for entry in entries:
+ print >> s, calculate_diff(entry, contextlines)
+ resp = conn.sendmail(address, people, s.getvalue())
+ conn.close()
+ os._exit(0)
+
+
+
+class CVSEntry:
+ def __init__(self, name, revision, timestamp, conflict, options, tagdate):
+ self.name = name
+ self.revision = revision
+ self.timestamp = timestamp
+ self.conflict = conflict
+ self.options = options
+ self.tagdate = tagdate
+
+def get_entry(prefix, mapping, line, filename):
+ line = line.strip()
+ parts = line.split("/")
+ _, name, revision, timestamp, options, tagdate = parts
+ key = namekey(prefix, name)
+ try:
+ entry = mapping[key]
+ except KeyError:
+ if revision == "0":
+ revision = None
+ if timestamp.find("+") != -1:
+ timestamp, conflict = tuple(timestamp.split("+"))
+ else:
+ conflict = None
+ entry = CVSEntry(key, revision, timestamp, conflict,
+ options, tagdate)
+ mapping[key] = entry
+ return entry
+
+def namekey(prefix, name):
+ if prefix:
+ return os.path.join(prefix, name)
+ else:
+ return name
+
+def load_change_info(prefix=None):
+ if prefix is not None:
+ entries_fn = os.path.join(prefix, "CVS", "Entries")
+ else:
+ entries_fn = os.path.join("CVS", "Entries")
+ entries_log_fn = entries_fn + ".Log"
+ mapping = {}
+ f = open(entries_fn)
+ while 1:
+ line = f.readline()
+ if not line:
+ break
+## if line.strip() == "D":
+## continue
+ # we could recurse down subdirs, except the Entries.Log files
+ # we need haven't been written to the subdirs yet, so it
+ # doesn't do us any good
+## if line[0] == "D":
+## name = line.split("/")[1]
+## dirname = namekey(prefix, name)
+## if os.path.isdir(dirname):
+## m = load_change_info(dirname)
+## mapping.update(m)
+ if line[0] == "/":
+ # normal file
+ get_entry(prefix, mapping, line, entries_fn)
+ # else: bogus Entries line
+ f.close()
+ if os.path.isfile(entries_log_fn):
+ f = open(entries_log_fn)
+ while 1:
+ line = f.readline()
+ if not line:
+ break
+ if line[1:2] != ' ':
+ # really old version of CVS
+ break
+ entry = get_entry(prefix, mapping, line[2:], entries_log_fn)
+ parts = line.split("/")[1:]
+ if line[0] == "A":
+ # adding a file
+ entry.new_revision = parts[1]
+ elif line[0] == "R":
+ # removing a file
+ entry.new_revision = None
+ f.close()
+ for entry in mapping.values():
+ if not hasattr(entry, "new_revision"):
+ print 'confused about file', entry.name, '-- ignoring'
+ del mapping[entry.name]
+ return mapping
+
+def load_branch_name():
+ tag_fn = os.path.join("CVS", "Tag")
+ if os.path.isfile(tag_fn):
+ f = open(tag_fn)
+ line = f.readline().strip()
+ f.close()
+ if line[:1] == "T":
+ return line[1:]
+ return None
+
+# scan args for options
+def main():
+ # XXX Should really move all the options to an object, just to
+ # avoid threading so many positional args through everything.
+ try:
+ opts, args = getopt.getopt(
+ sys.argv[1:], 'hC:cuS:R:qf:m:',
+ ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
+ 'subject-prefix=', 'reply-to=',
+ 'help', 'quiet'])
+ except getopt.error, msg:
+ usage(1, msg)
+
+ # parse the options
+ contextlines = 2
+ verbose = 1
+ subject_prefix = ""
+ replyto = None
+ fromhost = None
+ for opt, arg in opts:
+ if opt in ('-h', '--help'):
+ usage(0)
+ elif opt == '--cvsroot':
+ os.environ['CVSROOT'] = arg
+ elif opt in ('-C', '--context'):
+ contextlines = int(arg)
+ elif opt == '-c':
+ if contextlines <= 0:
+ contextlines = 2
+ elif opt == '-u':
+ contextlines = 0
+ elif opt in ('-S', '--subject-prefix'):
+ subject_prefix = arg
+ elif opt in ('-R', '--reply-to'):
+ replyto = arg
+ elif opt in ('-q', '--quiet'):
+ verbose = 0
+ elif opt in ('-f', '--fromhost'):
+ fromhost = arg
+ elif opt in ('-m', '--mailhost'):
+ global MAILHOST
+ MAILHOST = arg
+
+ # What follows is the specification containing the files that were
+ # modified. The argument actually must be split, with the first component
+ # containing the directory the checkin is being made in, relative to
+ # $CVSROOT, followed by the list of files that are changing.
+ if not args:
+ usage(1, 'No CVS module specified')
+ subject = subject_prefix + args[0]
+ specs = args[0].split()
+ del args[0]
+
+ # The remaining args should be the email addresses
+ if not args:
+ usage(1, 'No recipients specified')
+
+ # Now do the mail command
+ people = args
+
+ if specs[-3:] == ['-', 'Imported', 'sources']:
+ print 'Not sending email for imported sources.'
+ return
+
+ branch = load_branch_name()
+ changes = load_change_info()
+
+ if verbose:
+ print 'Mailing %s...' % COMMASPACE.join(people)
+ print 'Generating notification message...'
+ blast_mail(subject, people, changes.values(),
+ contextlines, fromhost, replyto)
+ if verbose:
+ print 'Generating notification message... done.'
+
+
+
+if __name__ == '__main__':
+ main()
+ sys.exit(0)
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/syncmail
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/usergroup.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/usergroup.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/usergroup.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,400 @@
+#! /usr/bin/php4 -f
+<?php
+/**
+ * GForge Cron Job
+ *
+ * The rest Copyright 2002-2005 (c) GForge Team
+ * http://gforge.org/
+ *
+ * @version $Id$
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * 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
+ */
+
+/*
+
+NOTE - THIS SQL CAN BE USED ON A SEPARATED CVS SERVER TO GRANT ONLY THE NECESSARY PERMS
+
+
+CREATE USER cvsuser WITH ENCRYPTED PASSWORD 'password';
+
+GRANT SELECT ON groups, plugins, group_plugin, users, user_group, deleted_groups TO cvsuser;
+GRANT INSERT, UPDATE ON deleted_groups TO cvsuser;
+GRANT ALL ON stats_cvs_group, stats_cvs_user TO cvsuser;
+
+*/
+
+/*
+
+This file creates user / group permissions by editing
+the /etc/passwd /etc/shadow and /etc/group files
+
+It also creates blank user home directories and
+creates a group home directory with a template in it.
+
+#
+# * hosts
+#
+<VirtualHost 192.168.1.5>
+ServerName gforge.company.com
+ServerAlias *.gforge.company.com
+VirtualDocumentRoot /home/groups/%1/htdocs
+VirtualScriptAlias /home/groups/%1/cgi-bin
+<Directory /home/groups>
+Options Indexes FollowSymlinks
+AllowOverride All
+order allow,deny
+allow from all
+</Directory>
+LogFormat "%h %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" gforge
+CustomLog "|/usr/local/sbin/cronolog /home/groups/%1/logs/%Y/%m/%d/gforge.log" gforge
+# Ensure that we don't try to use SSL on SSL Servers
+ <IfModule apache_ssl.c>
+ SSLDisable
+ </IfModule>
+</VirtualHost>
+*/
+require_once('squal_pre.php');
+require ('common/include/cron_utils.php');
+
+//
+// Default values for the script
+//
+define('DEFAULT_SHELL','/bin/cvssh.pl'); //use /bin/grap for cvs-only
+define('USER_ID_ADD',10000);
+define('GROUP_ID_ADD',50000);
+define('USER_DEFAULT_GROUP','users');
+define('FILE_EXTENSION','.new'); // use .new when testing
+
+if (!file_exists('/etc/passwd.org')) {
+ echo "passwd.org missing";
+ exit;
+}
+
+if (!file_exists('/etc/shadow.org')) {
+ echo "shadow.org missing";
+ exit;
+}
+
+if (!file_exists('/etc/group.org')) {
+ echo "group.org missing";
+ exit;
+}
+
+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 COMMIT PRIVS ARE ADDED
+//
+$res = db_query("SELECT distinct users.user_name,users.unix_pw,users.user_id
+ FROM users,user_group,groups
+ WHERE users.user_id=user_group.user_id
+ AND user_group.group_id=groups.group_id
+ AND groups.status='A'
+ AND user_group.cvs_flags='1'
+ AND users.status='A'
+ ORDER BY user_id ASC");
+
+$users =& util_result_column_to_array($res,'user_name');
+$user_ids =& util_result_column_to_array($res,'user_id');
+$user_pws =& util_result_column_to_array($res,'unix_pw');
+
+//
+// Get anonymous pserver users
+//
+$res7=db_query("SELECT unix_group_name FROM groups WHERE status='A' AND is_public='1' AND enable_anonscm='1' AND type_id='1';");
+$err .= db_error();
+$rows = db_numrows($res7);
+for($k = 0; $k < $rows; $k++) {
+ $pserver_anon[db_result($res7,$k,'unix_group_name')]=',anonymous';
+}
+
+//
+// Read in the "default" users
+//
+$h = fopen("/etc/passwd.org","r");
+$passwdcontents = fread($h,filesize("/etc/passwd.org"));
+fclose($h);
+$passwdlines = explode("\n",$passwdcontents);
+
+//
+// Write the "default" users to a temp file
+//
+$h2 = fopen("/etc/passwd".FILE_EXTENSION,"w");
+for($k = 0; $k < count($passwdlines); $k++) {
+ $passwdline = explode(":",$passwdlines[$k]);
+ $def_users[$passwdline[0]]=1;
+ fwrite($h2,$passwdlines[$k]."\n");
+}
+
+//
+// Now append the users from the gforge database
+//
+for($i = 0; $i < count($users); $i++) {
+
+ if ($def_users[$users[$i]]) {
+
+ //this username was already existing in the "default" file
+
+ } else {
+
+ $line = $users[$i] . ":x:" . ($user_ids[$i] + USER_ID_ADD) . ":" .
+ ($user_ids[$i] + USER_ID_ADD) . "::/home/$users[$i]:".DEFAULT_SHELL."\n";
+ fwrite($h2,$line);
+
+ }
+
+}
+fclose($h2);
+
+
+
+//
+// this is where we add users to /etc/shadow
+//
+$h3 = fopen("/etc/shadow.org","r");
+$shadowcontents = fread($h3,filesize("/etc/shadow.org"));
+fclose($h3);
+$shadowlines = explode("\n",$shadowcontents);
+
+//
+// Write the "default" shadow to a temp file
+//
+$h4 = fopen("/etc/shadow".FILE_EXTENSION,"w");
+for($k = 0; $k < count($shadowlines); $k++) {
+ $shadowline = explode(":",$shadowlines[$k]);
+ $def_shadow[$shadowline[0]]=1;
+ fwrite($h4,$shadowlines[$k]."\n");
+}
+
+//
+// Now append the users from the gforge database
+//
+for($i = 0; $i < count($users); $i++) {
+
+ if ($def_shadow[$users[$i]]) {
+
+ //this username was already existing in the "default" file
+
+ } else {
+
+ $line = $users[$i] . ":" . $user_pws[$i] . ":12090:0:99999:7:::\n";
+ fwrite($h4,$line);
+
+ }
+
+}
+
+fclose($h4);
+
+//
+// Read the groups from the "default" file
+//
+$h5 = fopen("/etc/group.org","r");
+$groupcontents = fread($h5,filesize("/etc/group.org"));
+fclose($h5);
+$grouplines = explode("\n",$groupcontents);
+
+//
+// Write the "default" groups to a temp file
+//
+$h6 = fopen("/etc/group".FILE_EXTENSION,"w");
+for($k = 0; $k < count($grouplines); $k++) {
+ $groupline = explode(":",$grouplines[$k]);
+ $def_group[$groupline[0]]=1;
+ fwrite($h6,$grouplines[$k]."\n");
+}
+
+//
+// Add the groups from the gforge database
+//
+$group_res=db_query("SELECT group_id,unix_group_name FROM groups WHERE status='A' AND type_id='1'");
+for($i = 0; $i < db_numrows($group_res); $i++) {
+ $groups[] = db_result($group_res,$i,'unix_group_name');
+ $gids[db_result($group_res,$i,'unix_group_name')]=db_result($group_res,$i,'group_id')+GROUP_ID_ADD;
+}
+
+for($i = 0; $i < count($groups); $i++) {
+
+ if ($def_group[$groups[$i]]) {
+
+ //this groupname was already existing in the "default" file
+
+ } else {
+
+ $line = $groups[$i] . ":x:" . ($gids[$groups[$i]]) . ":";
+
+
+ /* we need to get the project object to check if a project
+ * has a private CVS repository - in which case we need to add
+ * the apache user to the group so that ViewCVS can be used
+ */
+
+ $gid = db_result($group_res, $i, 'group_id');
+ $project = &group_get_object($gid);
+
+ $resusers=db_query("SELECT user_name
+ FROM users,user_group,groups
+ WHERE groups.group_id=user_group.group_id
+ AND users.user_id=user_group.user_id
+ AND user_group.cvs_flags='1'
+ AND users.status='A'
+ AND groups.unix_group_name='$groups[$i]'");
+
+ $gmembers =& util_result_column_to_array($resusers,'user_name');
+
+ $group_name = $groups[$i];
+ if (!($project->enableAnonSCM())) {
+ if (!$gmembers) {
+ //if there´s not a user in $gmembers, remove the initial "," from pserver_anon
+ if ($pserver_anon[$groups[$i]]) {
+ $this_anon = ltrim($pserver_anon[$groups[$i]],",");
+ $line .= $this_anon . "," . $sys_apache_user . "\n";
+ } else {
+ $line .= $sys_apache_user . "\n"; // only the apache user then?
+ }
+ } else {
+ $line .= implode(',',$gmembers) . $pserver_anon[$groups[$i]] . "," . $sys_apache_user . "\n";
+ }
+ } else {
+ if (!$gmembers) {
+ //if there´s not a user in $gmembers, remove the initial "," from pserver_anon
+ if ($pserver_anon[$groups[$i]]) {
+ $this_anon = ltrim($pserver_anon[$groups[$i]],",");
+ $line .= $this_anon . "\n";
+ } else {
+ $line .= "\n"; //no users
+ }
+ } else {
+ $line .= implode(',',$gmembers) . $pserver_anon[$groups[$i]] . "\n";
+ }
+ }
+
+ fwrite($h6, $line);
+
+ }
+
+}
+
+fclose($h6);
+
+//
+// this is where we give a user a home
+//
+foreach($users as $user) {
+ if (is_dir("/home/".$user)) {
+
+ } else {
+ @mkdir("/home/".$user);
+// system("chown $user:".USER_DEFAULT_GROUP." /home/".$user);
+ }
+ system("chown $user:".USER_DEFAULT_GROUP." /home/".$user);
+}
+
+
+//
+// Create home dir for groups
+//
+foreach($groups as $group) {
+
+ //create an FTP upload dir for this project
+ if ($sys_use_ftpuploads) {
+ if (!is_dir($sys_ftp_upload_dir.'/'.$group)) {
+ @mkdir($sys_ftp_upload_dir.'/'.$group);
+ }
+ }
+
+ if (is_dir($groupdir_prefix."/".$group)) {
+
+ } else {
+ @mkdir($groupdir_prefix."/".$group);
+ @mkdir($groupdir_prefix."/".$group."/htdocs");
+ @mkdir($groupdir_prefix."/".$group."/cgi-bin");
+ $g =& group_get_object_by_name($group);
+
+
+ //
+ // Read in the template file
+ //
+ $fo=fopen('default_page.php','r');
+ $contents = '';
+ while (!feof($fo)) {
+ $contents .= fread($fo, 8192);
+ }
+ fclose($fo);
+ //
+ // Change some defaults in the template file
+ //
+ //$contents=str_replace('<domain>',$sys_default_domain,$contents);
+ //$contents=str_replace('<project_description>',$g->getDescription(),$contents);
+ //$contents=str_replace('<project_name>',$g->getPublicName(),$contents);
+ //$contents=str_replace('<group_id>',$g->getID(),$contents);
+ //$contents=str_replace('<group_name>',$g->getUnixName(),$contents);
+
+ //
+ // Write the file back out to the project home dir
+ //
+ $fw=fopen($groupdir_prefix."/".$group."/htdocs/index.php",'w');
+ fwrite($fw,$contents);
+ fclose($fw);
+
+ }
+ $resgroupadmin=db_query("SELECT u.user_name FROM users u,user_group ug,groups g
+ WHERE u.user_id=ug.user_id
+ AND ug.group_id=g.group_id
+ AND g.unix_group_name='$group'
+ AND ug.admin_flags='A'
+ AND u.status='A'");
+ if (!$resgroupadmin || db_numrows($resgroupadmin) < 1) {
+ //group has no members, so cannot create dir
+ } else {
+ $user=db_result($resgroupadmin,0,'user_name');
+ system("chown -R $user:$group $groupdir_prefix/$group");
+ }
+}
+
+//
+// Move CVS trees for deleted groups
+//
+$res8=db_query("SELECT unix_group_name FROM deleted_groups WHERE isdeleted = 0;");
+$err .= db_error();
+$rows = db_numrows($res8);
+for($k = 0; $k < $rows; $k++) {
+ $deleted_group_name = db_result($res8,$k,'unix_group_name');
+
+ if(!is_dir($sys_cvsroot."/deleted"))
+ system("mkdir ".$sys_cvsroot."/deleted");
+
+ if(!is_dir($sys_cvsroot."/deleted/".$deleted_group_name))
+ system("mkdir ".$sys_cvsroot."/deleted/".$deleted_group_name);
+
+ system("mv -f $sys_cvsroot/$deleted_group_name/*.* $sys_cvsroot/.deleted/$deleted_group_name");
+
+
+ $res9 = db_query("UPDATE deleted_groups set isdeleted = 1 WHERE unix_group_name = '$deleted_group_name';" );
+ $err .= db_error();
+}
+
+cron_entry(16,$err);
+
+?>
Property changes on: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/usergroup.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/www/index.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/www/index.php (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge-plugin-scmcvs/cronjobs/www/index.php 2011-02-24 17:05:47 UTC (rev 11236)
@@ -0,0 +1,2 @@
+<h1> Welcome to CVS... </h1>
+
More information about the evolvis-commits
mailing list