Пример #1
0
function OCSWEB_PACKAGE_FRAGS()
{
    $sourcefile = base64_decode($_GET["filesource"]);
    $unix = new unix();
    $userwww = $unix->APACHE_GROUPWARE_ACCOUNT();
    if (trim($sourcefile) == null) {
        writelogs_framework("OCS-PACKAGES:: base64_decode({$_GET["filesource"]})=\"NULL\" aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $FILEID = $_GET["FILEID"];
    if (trim($FILEID) == null) {
        writelogs_framework("OCS-PACKAGES:: FILEID=\"NULL\" aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $nbfrags = $_GET["nbfrags"];
    if (trim($nbfrags) == null) {
        writelogs_framework("OCS-PACKAGES:: nbfrags=\"NULL\" aborting", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $TMP = $unix->FILE_TEMP();
    shell_exec("/bin/cp {$sourcefile} {$TMP}");
    $document_root = "/var/lib/ocsinventory-reports";
    writelogs_framework("OCS-PACKAGES:: nbfrags=\"{$nbfrags}\"", __FUNCTION__, __FILE__, __LINE__);
    writelogs_framework("OCS-PACKAGES:: SOURCE=\"{$sourcefile}\"", __FUNCTION__, __FILE__, __LINE__);
    writelogs_framework("OCS-PACKAGES:: DEST=\"{$TMP}\"", __FUNCTION__, __FILE__, __LINE__);
    @mkdir("{$document_root}/download/{$FILEID}", 0755, true);
    @chmod("{$document_root}/download/{$FILEID}", 0755);
    @chown("{$document_root}/download/{$FILEID}", $userwww);
    $fname = $TMP;
    if ($size = @filesize($fname)) {
        writelogs_framework("OCS-PACKAGES:: SIZE=\"{$size}\"", __FUNCTION__, __FILE__, __LINE__);
        $handle = fopen($fname, "rb");
        $read = 0;
        for ($i = 1; $i < $nbfrags; $i++) {
            $contents = fread($handle, $size / $nbfrags);
            $read += strlen($contents);
            writelogs_framework("OCS-PACKAGES:: OPEN=\"{$document_root}/download/{$FILEID}/{$FILEID}-{$i}\"", __FUNCTION__, __FILE__, __LINE__);
            $handfrag = fopen("{$document_root}/download/{$FILEID}/{$FILEID}-{$i}", "w+b");
            fwrite($handfrag, $contents);
            fclose($handfrag);
            @chown("{$document_root}/download/{$FILEID}/{$FILEID}-{$i}", $userwww);
        }
        $contents = fread($handle, $size - $read);
        $read += strlen($contents);
        $handfrag = fopen("{$document_root}/download/{$FILEID}/{$FILEID}-{$i}", "w+b");
        fwrite($handfrag, $contents);
        fclose($handfrag);
        fclose($handle);
        @chown("{$document_root}/download/{$FILEID}/{$FILEID}-{$i}", $userwww);
        unlink($TMP);
    }
    exec("/bin/chown -R {$userwww} {$document_root}/download/{$FILEID}", $results);
    while (list($num, $ligne) = each($results)) {
        writelogs_framework("OCS-PACKAGES:: chown: {$ligne}", __FUNCTION__, __FILE__, __LINE__);
    }
}
Пример #2
0
function CheckHomeFor($uid,$homeDirectory=null){
	$ct=new user($uid);
	if($homeDirectory==null){$homeDirectory=$ct->homeDirectory;}
	
	echo "Starting......: Home $uid checking home: $homeDirectory\n";
	
	if($GLOBALS["profile_path"]==null){
		$sock=new sockets();
		$profile_path=$sock->GET_INFO('SambaProfilePath');
		$GLOBALS["profile_path"]=$profile_path;
	}
	if($ct->ou==null){writelogs("$uid: OU=NULL, No a standard user...SKIP",__FUNCTION__,__FILE__,__LINE__);return;}
	$ou=$ct->ou;
	$uid=strtolower($uid);
	$newdir=trim(getStorageEnabled($ou,$uid));
	if($newdir<>null){
		$newdir="$newdir/$uid";
		writelogs("LVM: [$ou]:: storage=$newdir;homeDirectory=$homeDirectory",__FUNCTION__,__FILE__,__LINE__);
		if($newdir<>$homeDirectory){
			writelogs("$uid:: change $homeDirectory to $newdir",__FUNCTION__,__FILE__,__LINE__);
			$ct->homeDirectory=$newdir;
			$ct->edit_system();
			$homeDirectory=$newdir;
		}
	}
	
if($homeDirectory==null){
	$homeDirectory="/home/$uid";
	writelogs("$uid:: change $homeDirectory",__FUNCTION__,__FILE__,__LINE__);
	$ct->homeDirectory=$homeDirectory;
	$ct->edit_system();
	}
	
	if($GLOBALS["profile_path"]<>null){
		$export="$profile_path/$uid";
		writelogs("Checking export:$export",__FUNCTION__,__FILE__,__LINE__);
		@mkdir($export);
		@chmod($export,0775);
		@chown($export,$uid);
	}
	
	
	writelogs("Checking home:$homeDirectory",__FUNCTION__,__FILE__,__LINE__);
	@mkdir($homeDirectory);
	@chmod($homeDirectory,0775);
	@chown($homeDirectory,$uid);
	
	if($ct->WebDavUser==1){
		$unix=new unix();
		$find=$unix->find_program("find");
		$apacheuser=$unix->APACHE_GROUPWARE_ACCOUNT();
		if(preg_match("#(.+?):#",$apacheuser,$re)){$apacheuser=$re[1];}
		$internet_folder="$homeDirectory/Internet Folder";
		@mkdir($internet_folder);
		@chmod($internet_folder,0775);
		$internet_folder=$unix->shellEscapeChars($internet_folder);
		echo "Starting......: Home $uid checking home: $internet_folder\n";
		writelogs("Checking $ct->uid:$apacheuser :$internet_folder",__FUNCTION__,__FILE__,__LINE__);
		shell_exec("/bin/chown -R $ct->uid:$apacheuser $internet_folder >/dev/null 2>&1 &");
		shell_exec("$find $internet_folder -type d -exec chmod 755 {} \; >/dev/null 2>&1 &");
	}
	
	
	
}
Пример #3
0
function GROUPOFFICE_INSTALL($servername, $root, $hash = array())
{
    $srcfolder = "/usr/local/share/artica/group-office";
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    $sql_file = "/usr/share/artica-postfix/bin/install/opengoo/group-office.sql";
    $sql_datas = "/usr/share/artica-postfix/bin/install/opengoo/group-office-datas.sql";
    if ($root == null) {
        events("Starting install GroupOffice Unable to stat root dir");
        return false;
    }
    if (!is_dir($srcfolder)) {
        events("Starting install GroupOffice Unable to stat SRC");
        return false;
    }
    $user = $hash["wwwmysqluser"][0];
    $mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
    $appli_user = $hash["wwwappliuser"][0];
    $appli_password = $hash["wwwapplipassword"][0];
    $wwwsslmode = $hash["wwwsslmode"][0];
    $ou = $hash["OU"][0];
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace(" ", "_", $server_database);
    $server_database = str_replace("-", "_", $server_database);
    events("Starting install GroupOffice sub-system mysql database {$server_database}...");
    if ($user == null) {
        events("Starting install GroupOffice Unable to stat Mysql username");
        return false;
    }
    if ($mysql_password == null) {
        events("Starting install GroupOffice Unable to stat Mysql password");
        return false;
    }
    @mkdir($root, 0755, true);
    events("Starting install GroupOffice sub-system mysql database {$server_database}...");
    $q = new mysql();
    if (!$q->DATABASE_EXISTS($server_database)) {
        $q->CREATE_DATABASE($server_database);
    }
    if (!$q->DATABASE_EXISTS($server_database)) {
        events("Starting install GroupOffice unable to create MYSQL Database");
        return false;
    }
    events("Starting setting permissions on Database with user {$user}");
    $q->PRIVILEGES($user, $mysql_password, $server_database);
    if (!GROUPOFFICE_TEST_FILES($root)) {
        events("Starting install GroupOffice installing source code");
        shell_exec("/bin/cp -rf {$srcfolder}/* {$root}/");
        @mkdir("/home/groupoffice/{$servername}", 0777, true);
    }
    @mkdir("/home/groupoffice/{$servername}", 0777, true);
    $unix = new unix();
    $apacheuser = $unix->APACHE_GROUPWARE_ACCOUNT();
    events("chown /home/groupoffice has {$apacheuser}");
    shell_exec("/bin/chown -R {$apacheuser} /home/groupoffice");
    if ($q->mysql_password != null) {
        $password = "******";
    } else {
        events("Starting install GroupOffice installing tables datas with null password");
    }
    $cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
    $cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$sql_file}";
    shell_exec($cmd);
    $sock = new sockets();
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    events("Starting install opengo SSL={$wwwsslmode}");
    if ($wwwsslmode == "TRUE") {
        $ROOT_URL = "https://{$servername}";
    } else {
        $ROOT_URL = "http://{$servername}:{$ApacheGroupWarePort}";
    }
    $q = new mysql();
    $conf[] = "<?php";
    $conf[] = "\$config['enabled']=true;";
    $conf[] = "\$config['id']=\"groupoffice\";";
    $conf[] = "\$config['debug']=false;";
    $conf[] = "\$config['log']=false;";
    $conf[] = "\$config['language']=\"en\";";
    $conf[] = "\$config['default_country']=\"FR\";";
    $conf[] = "\$config['default_timezone']=\"Europe/Amsterdam\";";
    $conf[] = "\$config['default_currency']=\"€\";";
    $conf[] = "\$config['default_date_format']=\"dmY\";";
    $conf[] = "\$config['default_date_separator']=\"-\";";
    $conf[] = "\$config['default_time_format']=\"G:i\";";
    $conf[] = "\$config['default_first_weekday']=\"1\";";
    $conf[] = "\$config['default_decimal_separator']=\",\";";
    $conf[] = "\$config['default_thousands_separator']=\".\";";
    $conf[] = "\$config['theme']=\"Default\";";
    $conf[] = "\$config['allow_themes']=true;";
    $conf[] = "\$config['allow_password_change']=false;";
    $conf[] = "\$config['allow_profile_edit']=true;";
    $conf[] = "\$config['allow_registration']=false;";
    $conf[] = "\$config['registration_fields']=\"title_initials,sex,birthday,address,home_phone,fax,cellular,company,department,function,work_address,work_phone,work_fax,homepage\";";
    $conf[] = "\$config['required_registration_fields']=\"company,address\";";
    $conf[] = "\$config['allow_duplicate_email']=false;";
    $conf[] = "\$config['auto_activate_accounts']=false;";
    $conf[] = "\$config['notify_admin_of_registration']=true;";
    $conf[] = "\$config['register_modules_read']=\"summary,email,calendar,tasks,addressbook,files,notes,links,tools,comments\";";
    $conf[] = "\$config['register_modules_write']=\"\";";
    $conf[] = "\$config['allowed_modules']=\"\";";
    $conf[] = "\$config['register_user_groups']=\"\";";
    $conf[] = "\$config['register_visible_user_groups']=\",\";";
    $conf[] = "\$config['host']=\"/\";";
    $conf[] = "\$config['force_login_url']=false;";
    $conf[] = "\$config['full_url']=\"{$ROOT_URL}/\";";
    $conf[] = "\$config['title']=\"Group-Office\";";
    $conf[] = "\$config['webmaster_email']=\"webmaster@example.com\";";
    $conf[] = "\$config['root_path']=\"{$root}/\";";
    $conf[] = "\$config['tmpdir']=\"/tmp/\";";
    $conf[] = "\$config['max_users']=\"0\";";
    $conf[] = "\$config['quota']=\"0\";";
    $conf[] = "\$config['db_type']=\"mysql\";";
    $conf[] = "\$config['db_host']=\"{$q->mysql_server}\";";
    $conf[] = "\$config['db_name']=\"{$server_database}\";";
    $conf[] = "\$config['db_user']=\"{$user}\";";
    $conf[] = "\$config['db_pass']=\"{$mysql_password}\";";
    $conf[] = "\$config['db_port']=\"{$q->mysql_port}\";";
    $conf[] = "\$config['db_socket']=\"\";";
    $conf[] = "\$config['file_storage_path']=\"/home/groupoffice/{$servername}/\";";
    $conf[] = "\$config['max_file_size']=\"10000000\";";
    $conf[] = "\$config['smtp_server']=\"127.0.0.1\";";
    $conf[] = "\$config['smtp_port']=\"25\";";
    $conf[] = "\$config['smtp_username']=\"\";";
    $conf[] = "\$config['smtp_password']=\"\";";
    $conf[] = "\$config['smtp_encryption']=\"\";";
    $conf[] = "\$config['smtp_local_domain']=\"\";";
    $conf[] = "\$config['restrict_smtp_hosts']=\"\";";
    $conf[] = "\$config['max_attachment_size']=\"10000000\";";
    $unix = new unix();
    $ldap = new clladp();
    $zip = $unix->find_program("zip");
    $unzip = $unix->find_program("unzip");
    $xml2wbxml = $unix->find_program("xml2wbxml");
    $conf[] = "\$config['cmd_zip']=\"{$zip}\";";
    $conf[] = "\$config['cmd_unzip']=\"{$unzip}\";";
    $conf[] = "\$config['cmd_tar']=\"/bin/tar\";";
    $conf[] = "\$config['cmd_chpasswd']=\"/usr/sbin/chpasswd\";";
    $conf[] = "\$config['cmd_sudo']=\"/usr/bin/sudo\";";
    $conf[] = "\$config['cmd_xml2wbxml']=\"{$xml2wbxml}\";";
    $conf[] = "\$config['cmd_wbxml2xml']=\"/usr/bin/wbxml2xml\";";
    $conf[] = "\$config['cmd_tnef']=\"/usr/bin/tnef\";";
    $conf[] = "\$config['cmd_php']=\"php\";";
    $conf[] = "\$config['phpMyAdminUrl']=\"\";";
    $conf[] = "\$config['allow_unsafe_scripts']=\"\";";
    $conf[] = "\$config['default_password_length']=\"6\";";
    $conf[] = "\$config['session_inactivity_timeout']=\"0\"";
    //$conf[]="\$config['ldap_host']='$ldap->ldap_host';";
    //$conf[]="\$config['ldap_user']='******';";
    //$conf[]="\$config['ldap_pass']='******';";
    //$conf[]="\$config['ldap_basedn']='ou=$ou,dc=organizations,$ldap->suffix';";
    //$conf[]="\$config['ldap_peopledn']='ou=users,ou=$ou,dc=organizations,$ldap->suffix';";
    //$conf[]="\$config['ldap_groupsdn']='ou=groups,ou=$ou,dc=organizations,$ldap->suffix';";
    $conf[] = "?>";
    @file_put_contents("{$root}/config.php", implode("\n", $conf));
    $sql = "UPDATE go_users SET password='******',username='******' WHERE id='1'";
    $q = new mysql();
    $q->QUERY_SQL($sql, $server_database);
    events("Starting install GroupOffice {$root}/config.php done...");
}
Пример #4
0
function vhosts()
{
    $sock = new sockets();
    $unix = new unix();
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    $user = $unix->APACHE_GROUPWARE_ACCOUNT();
    $conf[] = "\n# Joomla personal web sites\n";
    $sql = "SELECT * FROM joomla_users WHERE install=1";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $vhost = $ligne["servername"];
        echo "Starting Apache..............: Joomla personal website: {$vhost}\n";
        $uid = $ligne["uid"];
        $u = new user($uid);
        $root = $u->homeDirectory . "/www/{$ligne["servername"]}";
        if (is_dir($root)) {
            $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort}>";
            $conf[] = "\tServerName {$vhost}";
            $conf[] = "\tServerAdmin {$u->mail}";
            $conf[] = "\tDocumentRoot {$root}";
            $conf[] = "\tphp_value  error_log  \"{$root}/logs/php.log\"";
            $conf[] = "\tphp_value open_basedir \"{$root}\"";
            //$conf[]="\tphp_value magic_quotes_gpc off";
            $conf[] = "\t<Directory \"{$root}\">";
            $conf[] = "\t\tDirectoryIndex index.php";
            $conf[] = "\t\tOptions Indexes FollowSymLinks MultiViews";
            $conf[] = "\t\tAllowOverride all";
            $conf[] = "\t\tOrder allow,deny";
            $conf[] = "\tAllow from all";
            $conf[] = "\t</Directory>";
            $conf[] = "\tCustomLog {$root}/logs/access.log \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %V\"\n";
            $conf[] = "\tErrorLog {$root}/logs/webserver.errors.log";
            $conf[] = "</VirtualHost>\n";
            shell_exec("/bin/chown -R {$user} {$root}");
        }
    }
    @file_put_contents("/usr/local/apache-groupware/conf/joomla-vhosts.conf", @implode("\n", $conf));
}
Пример #5
0
function buildconfig()
{
    $unix = new unix();
    $sock = new sockets();
    $array = unserialize(base64_decode($sock->GET_INFO("BackupPCGeneralConfig")));
    $configfile = locate_config_pl();
    $users = new usersMenus();
    $wwuser = $unix->APACHE_GROUPWARE_ACCOUNT();
    if (preg_match("#(.+?):#", $wwuser, $re)) {
        $wwuser = $re[1];
    }
    if ($array["Language"] == null) {
        $array["Language"] = "en";
    }
    if ($array["MaxBackups"] == null) {
        $array["MaxBackups"] = "4";
    }
    if ($array["MaxBackupPCNightlyJobs"] == null) {
        $array["MaxBackupPCNightlyJobs"] = "2";
    }
    if ($array["BackupPCNightlyPeriod"] == null) {
        $array["BackupPCNightlyPeriod"] = "1";
    }
    if ($array["MaxOldLogFiles"] == null) {
        $array["MaxOldLogFiles"] = "14";
    }
    $ConfDir = dirname($configfile);
    $InstallDir = locate_backuppc_share();
    if (trim($array["TopDir"]) == null) {
        $array["TopDir"] = locate_backuppc_TopDir();
    }
    $hostname = $users->hostname;
    echo "Starting......:  Backup-PC config dir: {$ConfDir}\n";
    echo "Starting......:  Backup-PC www user..: {$wwuser}\n";
    echo "Starting......:  Backup-PC Top dir...: {$array["TopDir"]}\n";
    @mkdir($ConfDir, 0755, true);
    @mkdir($array["TopDir"], 0750, true);
    //system("/bin/chown -R backuppc:backuppc {$array["TopDir"]} &");
    //system("/bin/chown -R backuppc:$wwuser $ConfDir &");
    $par = $unix->find_program("par2");
    if ($par == null) {
        $par = "undef";
    } else {
        $par = "'{$par}'";
    }
    $conf[] = "\$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin/:user/sbin:/usr/local/sbin:/sbin';";
    $conf[] = "delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};";
    $conf[] = "\$Conf{ServerHost} = '127.0.0.1';";
    $conf[] = "chomp(\$Conf{ServerHost});";
    $conf[] = "\$Conf{ServerPort} = '9669';";
    $conf[] = "\$Conf{ServerMesgSecret} = '';";
    $conf[] = "\$Conf{MyPath} = '/bin';";
    $conf[] = "\$Conf{UmaskMode} = '23';";
    $conf[] = "\$Conf{Language} = '{$array["Language"]}';";
    $conf[] = "\$Conf{WakeupSchedule} = [";
    $conf[] = "  '1',";
    $conf[] = "  '2',";
    $conf[] = "  '3',";
    $conf[] = "  '4',";
    $conf[] = "  '5',";
    $conf[] = "  '6',";
    $conf[] = "  '7',";
    $conf[] = "  '8',";
    $conf[] = "  '9',";
    $conf[] = "  '10',";
    $conf[] = "  '11',";
    $conf[] = "  '12',";
    $conf[] = "  '13',";
    $conf[] = "  '14',";
    $conf[] = "  '15',";
    $conf[] = "  '16',";
    $conf[] = "  '17',";
    $conf[] = "  '18',";
    $conf[] = "  '19',";
    $conf[] = "  '20',";
    $conf[] = "  '21',";
    $conf[] = "  '22',";
    $conf[] = "  '23'";
    $conf[] = "];";
    $conf[] = "\$Conf{MaxBackups} = '{$array["MaxBackups"]}';";
    $conf[] = "\$Conf{MaxUserBackups} = '4';";
    $conf[] = "\$Conf{MaxPendingCmds} = '10';";
    $conf[] = "\$Conf{MaxBackupPCNightlyJobs} = '{$array["MaxBackupPCNightlyJobs"]}';";
    $conf[] = "\$Conf{BackupPCNightlyPeriod} = '{$array["BackupPCNightlyPeriod"]}';";
    $conf[] = "\$Conf{MaxOldLogFiles} = '{$array["MaxOldLogFiles"]}';";
    $conf[] = "\$Conf{DfPath} = '/bin/df';";
    $conf[] = "\$Conf{DfCmd} = '\$dfPath \$topDir';";
    $conf[] = "\$Conf{SplitPath} = '/usr/bin/split';";
    $conf[] = "\$Conf{ParPath}   = {$par};";
    $conf[] = "\$Conf{CatPath}   = '/bin/cat';";
    $conf[] = "\$Conf{GzipPath}  = '/bin/gzip';";
    $conf[] = "\$Conf{Bzip2Path} = '/bin/bzip2';";
    $conf[] = "\$Conf{DfMaxUsagePct} = '95';";
    $conf[] = "\$Conf{TrashCleanSleepSec} = '300';";
    $conf[] = "\$Conf{DHCPAddressRanges} = [];";
    $conf[] = "\$Conf{BackupPCUser} = 'backuppc';";
    $conf[] = "\$Conf{TopDir}      = '{$array["TopDir"]}';";
    $conf[] = "\$Conf{ConfDir}     = '{$ConfDir}';";
    $conf[] = "\$Conf{LogDir}      = '';";
    $conf[] = "\$Conf{InstallDir}  = '{$InstallDir}';";
    $conf[] = "\$Conf{CgiDir}      = '{$InstallDir}/cgi-bin';";
    $conf[] = "\$Conf{BackupPCUserVerify} = '1';";
    $conf[] = "\$Conf{HardLinkMax} = '31999';";
    $conf[] = "\$Conf{PerlModuleLoad}     = undef;";
    $conf[] = "\$Conf{ServerInitdPath} = '';";
    $conf[] = "\$Conf{ServerInitdStartCmd} = '';";
    $conf[] = "\$Conf{FullPeriod} = '6.97';";
    $conf[] = "\$Conf{IncrPeriod} = '0.97';";
    $conf[] = "\$Conf{FullKeepCnt} =  [";
    $conf[] = "  '1'";
    $conf[] = "];";
    $conf[] = "\$Conf{FullKeepCntMin} ='1';";
    $conf[] = "\$Conf{FullAgeMax}     = '90';";
    $conf[] = "\$Conf{IncrKeepCnt} = '6';";
    $conf[] = "\$Conf{IncrKeepCntMin} ='1';";
    $conf[] = "\$Conf{IncrAgeMax}     = '30';";
    $conf[] = "\$Conf{IncrLevels} =  [";
    $conf[] = "  '1'";
    $conf[] = "];";
    $conf[] = "\$Conf{BackupsDisable} = '0';";
    $conf[] = "\$Conf{PartialAgeMax} = '3';";
    $conf[] = "\$Conf{IncrFill} = '0';";
    $conf[] = "\$Conf{RestoreInfoKeepCnt} = '10';";
    $conf[] = "\$Conf{ArchiveInfoKeepCnt} = '10';";
    $conf[] = "\$Conf{BackupFilesOnly} = undef;";
    $conf[] = "\$Conf{BackupFilesExclude} = undef;";
    $conf[] = "\$Conf{BlackoutBadPingLimit} = '3';";
    $conf[] = "\$Conf{BlackoutGoodCnt}      = '7';";
    $conf[] = "\$Conf{BlackoutPeriods} =[ { hourBegin => 7.0, hourEnd => 12.0, weekDays => [1, 2, 3, 4, 5], }];";
    $conf[] = "\$Conf{BackupZeroFilesIsFatal} = '1';";
    $conf[] = "\$Conf{XferMethod} = 'smb';";
    $conf[] = "\$Conf{XferLogLevel} = '1';";
    $conf[] = "\$Conf{ClientCharset} = '';";
    $conf[] = "\$Conf{ClientCharsetLegacy} = 'iso-8859-1';";
    $conf[] = "\$Conf{SmbShareName} = 'C\$';";
    $conf[] = "\$Conf{SmbShareUserName} = '';";
    $conf[] = "\$Conf{SmbSharePasswd} = '';";
    $conf[] = "\$Conf{SmbClientPath} = '/usr/bin/smbclient';";
    $conf[] = "\$Conf{SmbClientFullCmd} = '\$smbClientPath \\\\\\\\\$host\\\\\$shareName \$I_option -U \$userName -E -d 1 -c tarmode\\\\ full -Tc\$X_option - \$fileList';";
    $conf[] = "\$Conf{SmbClientIncrCmd} = '\$smbClientPath \\\\\\\\\$host\\\\\$shareName \$I_option -U \$userName -E -d 1 -c tarmode\\\\ full -TcN\$X_option \$timeStampFile - \$fileList';";
    $conf[] = "\$Conf{SmbClientRestoreCmd} = '\$smbClientPath \\\\\\\\\$host\\\\\$shareName \$I_option -U \$userName -E -d 1 -c tarmode\\\\ full -Tx -';";
    $conf[] = "";
    $conf[] = "\$Conf{TarShareName} = '/';";
    $conf[] = "\$Conf{TarClientCmd} = '\$sshPath -q -x -n -l root \$host env LC_ALL=C \$tarPath -c -v -f - -C \$shareName+ --totals';";
    $conf[] = "\$Conf{TarFullArgs} = '\$fileList+';";
    $conf[] = "\$Conf{TarIncrArgs} = '--newer=\$incrDate+ \$fileList+';";
    $conf[] = "\$Conf{TarClientRestoreCmd} = '\$sshPath -q -x -l root \$host env LC_ALL=C \$tarPath -x -p --numeric-owner --same-owner -v -f - -C \$shareName+';";
    $conf[] = "\$Conf{TarClientPath} = '/bin/tar';";
    $conf[] = "\$Conf{RsyncClientPath} = '/usr/bin/rsync';";
    $conf[] = "\$Conf{RsyncClientCmd} = '\$sshPath -q -x -l root \$host \$rsyncPath \$argList+';";
    $conf[] = "\$Conf{RsyncClientRestoreCmd} = '\$sshPath -q -x -l root \$host \$rsyncPath \$argList+';";
    $conf[] = "\$Conf{RsyncShareName} = '/';";
    $conf[] = "\$Conf{RsyncdClientPort} = '873';";
    $conf[] = "\$Conf{RsyncdUserName} = '';";
    $conf[] = "\$Conf{RsyncdPasswd} = '';";
    $conf[] = "\$Conf{RsyncdAuthRequired} = 1;";
    $conf[] = "\$Conf{RsyncCsumCacheVerifyProb} = '0.01';";
    $conf[] = "\$Conf{RsyncArgs} = [";
    $conf[] = "            '--numeric-ids',";
    $conf[] = "            '--perms',";
    $conf[] = "            '--owner',";
    $conf[] = "            '--group',";
    $conf[] = "            '-D',";
    $conf[] = "            '--links',";
    $conf[] = "            '--hard-links',";
    $conf[] = "            '--times',";
    $conf[] = "            '--block-size=2048',";
    $conf[] = "            '--recursive',";
    $conf[] = "];";
    $conf[] = "";
    $conf[] = "\$Conf{RsyncRestoreArgs} = [";
    $conf[] = "\t    '--numeric-ids',";
    $conf[] = "\t    '--perms',";
    $conf[] = "\t    '--owner',";
    $conf[] = "\t    '--group',";
    $conf[] = "\t    '-D',";
    $conf[] = "\t    '--links',";
    $conf[] = "            '--hard-links',";
    $conf[] = "\t    '--times',";
    $conf[] = "\t    '--block-size=2048',";
    $conf[] = "\t    '--relative',";
    $conf[] = "\t    '--ignore-times',";
    $conf[] = "\t    '--recursive',";
    $conf[] = "];";
    $conf[] = "";
    $conf[] = "\$Conf{BackupPCdShareName} = '/';";
    $conf[] = "\$Conf{BackupPCdPath} = '';";
    $conf[] = "\$Conf{BackupPCdCmd} = '\$bpcdPath \$host \$shareName \$poolDir XXXX \$poolCompress \$topDir/pc/\$client/new';";
    $conf[] = "\$Conf{BackupPCdRestoreCmd} = '\$bpcdPath TODO';";
    $conf[] = "\$Conf{ArchiveDest} = '/tmp';";
    $conf[] = "\$Conf{ArchiveComp} = 'gzip';";
    $conf[] = "\$Conf{ArchivePar} = 0;";
    $conf[] = "\$Conf{ArchiveSplit} = 0;";
    $conf[] = "\$Conf{ArchiveClientCmd} = '\$Installdir/bin/BackupPC_archiveHost \$tarCreatePath \$splitpath \$parpath \$host \$backupnumber \$compression \$compext \$splitsize \$archiveloc \$parfile *';";
    $conf[] = "\$Conf{SshPath} = '/usr/bin/ssh' if -x '/usr/bin/ssh';";
    $conf[] = "\$Conf{NmbLookupPath} = '/usr/bin/nmblookup';";
    $conf[] = "\$Conf{NmbLookupCmd} = '\$nmbLookupPath -A \$host';";
    $conf[] = "\$Conf{NmbLookupFindHostCmd} = '\$nmbLookupPath \$host';";
    $conf[] = "\$Conf{FixedIPNetBiosNameCheck} = 0;";
    $conf[] = "\$Conf{PingPath} = '/bin/ping';";
    $conf[] = "\$Conf{PingCmd} = '\$pingPath -c 1 \$host';";
    $conf[] = "\$Conf{PingMaxMsec} = 20;";
    $conf[] = "\$Conf{CompressLevel} = 3;";
    $conf[] = "\$Conf{ClientTimeout} = 72000;";
    $conf[] = "\$Conf{MaxOldPerPCLogFiles} = 12;";
    $conf[] = "\$Conf{DumpPreUserCmd}     = undef;";
    $conf[] = "\$Conf{DumpPostUserCmd}    = undef;";
    $conf[] = "\$Conf{DumpPreShareCmd}    = undef;";
    $conf[] = "\$Conf{DumpPostShareCmd}   = undef;";
    $conf[] = "\$Conf{RestorePreUserCmd}  = undef;";
    $conf[] = "\$Conf{RestorePostUserCmd} = undef;";
    $conf[] = "\$Conf{ArchivePreUserCmd}  = undef;";
    $conf[] = "\$Conf{ArchivePostUserCmd} = undef;";
    $conf[] = "\$Conf{UserCmdCheckStatus} = 0;";
    $conf[] = "\$Conf{ClientNameAlias} = undef;";
    $conf[] = "\$Conf{SendmailPath} = '/usr/sbin/sendmail';";
    $conf[] = "\$Conf{EMailNotifyMinDays} = 2.5;";
    $conf[] = "\$Conf{EMailFromUserName} = 'backuppc';";
    $conf[] = "\$Conf{EMailAdminUserName} = 'backuppc';";
    $conf[] = "\$Conf{EMailUserDestDomain} = '';";
    $conf[] = "\$Conf{EMailNoBackupEverSubj} = undef;";
    $conf[] = "\$Conf{EMailNoBackupEverMesg} = undef;";
    $conf[] = "\$Conf{EMailNotifyOldBackupDays} = 7.0;";
    $conf[] = "\$Conf{EMailNoBackupRecentSubj} = undef;";
    $conf[] = "\$Conf{EMailNoBackupRecentMesg} = undef;";
    $conf[] = "\$Conf{EMailNotifyOldOutlookDays} = 5.0;";
    $conf[] = "\$Conf{EMailOutlookBackupSubj} = undef;";
    $conf[] = "\$Conf{EMailOutlookBackupMesg} = undef;";
    $conf[] = "\$Conf{EMailHeaders} ='MIME-Version: 1.0";
    $conf[] = "Content-Type: text/plain; charset=\"iso-8859-1\"";
    $conf[] = "';";
    $conf[] = "\$Conf{CgiAdminUserGroup} = 'backuppc';";
    $conf[] = "\$Conf{CgiAdminUsers}     = 'backuppc';";
    $conf[] = "\$Conf{CgiURL} = 'http://{$hostname}/backuppc/index.cgi';";
    $conf[] = "\$Conf{CgiUserHomePageCheck} = '';";
    $conf[] = "\$Conf{CgiUserUrlCreate}     = 'mailto:%s';";
    $conf[] = "\$Conf{CgiDateFormatMMDD} = 1;";
    $conf[] = "\$Conf{CgiNavBarAdminAllHosts} = 1;";
    $conf[] = "\$Conf{CgiSearchBoxEnable} = 1;";
    $conf[] = "\$Conf{CgiNavBarLinks} = undef;";
    $conf[] = "";
    $conf[] = "\$Conf{CgiStatusHilightColor} = {";
    $conf[] = "    Reason_backup_failed           => '#ffcccc',";
    $conf[] = "    Reason_backup_done             => '#ccffcc',";
    $conf[] = "    Reason_no_ping                 => '#ffff99',";
    $conf[] = "    Reason_backup_canceled_by_user => '#ff9900',";
    $conf[] = "    Status_backup_in_progress      => '#66cc99',";
    $conf[] = "    Disabled_OnlyManualBackups     => '#d1d1d1',   ";
    $conf[] = "    Disabled_AllBackupsDisabled    => '#d1d1d1',          ";
    $conf[] = "};";
    $conf[] = "\$Conf{CgiHeaders} = '<meta http-equiv=\"pragma\" content=\"no-cache\">';";
    $conf[] = "\$Conf{CgiImageDir} = '/usr/share/backuppc/image';";
    $conf[] = "\$Conf{CgiExt2ContentType} = {};";
    $conf[] = "\$Conf{CgiImageDirURL} = '/backuppc/image';";
    $conf[] = "\$Conf{CgiCSSFile} = 'BackupPC_stnd.css';";
    $conf[] = "\$Conf{CgiUserConfigEditEnable} = '1';";
    $conf[] = "\$Conf{CgiUserConfigEdit} = {";
    $conf[] = "  'EMailOutlookBackupSubj' => '1',";
    $conf[] = "  'ClientCharset' => '1',";
    $conf[] = "  'TarFullArgs' => '1',";
    $conf[] = "  'RsyncdPasswd' => '1',";
    $conf[] = "  'IncrKeepCnt' => '1',";
    $conf[] = "  'PartialAgeMax' => '1',";
    $conf[] = "  'FixedIPNetBiosNameCheck' => '1',";
    $conf[] = "  'SmbShareUserName' => '1',";
    $conf[] = "  'EMailFromUserName' => '1',";
    $conf[] = "  'ArchivePreUserCmd' => '0',";
    $conf[] = "  'PingCmd' => '0',";
    $conf[] = "  'FullAgeMax' => '1',";
    $conf[] = "  'PingMaxMsec' => '1',";
    $conf[] = "  'CompressLevel' => '1',";
    $conf[] = "  'DumpPreShareCmd' => '0',";
    $conf[] = "  'BackupFilesOnly' => '1',";
    $conf[] = "  'EMailNotifyOldBackupDays' => '1',";
    $conf[] = "  'EMailAdminUserName' => '1',";
    $conf[] = "  'RsyncCsumCacheVerifyProb' => '1',";
    $conf[] = "  'BlackoutPeriods' => '1',";
    $conf[] = "  'NmbLookupFindHostCmd' => '0',";
    $conf[] = "  'MaxOldPerPCLogFiles' => '1',";
    $conf[] = "  'TarClientCmd' => '0',";
    $conf[] = "  'EMailNotifyOldOutlookDays' => '1',";
    $conf[] = "  'SmbSharePasswd' => '1',";
    $conf[] = "  'SmbClientIncrCmd' => '0',";
    $conf[] = "  'FullKeepCntMin' => '1',";
    $conf[] = "  'RsyncArgs' => '1',";
    $conf[] = "  'ArchiveComp' => '1',";
    $conf[] = "  'TarIncrArgs' => '1',";
    $conf[] = "  'EMailUserDestDomain' => '1',";
    $conf[] = "  'TarClientPath' => '0',";
    $conf[] = "  'RsyncClientCmd' => '0',";
    $conf[] = "  'IncrFill' => '1',";
    $conf[] = "  'RestoreInfoKeepCnt' => '1',";
    $conf[] = "  'UserCmdCheckStatus' => '0',";
    $conf[] = "  'RsyncdClientPort' => '1',";
    $conf[] = "  'IncrAgeMax' => '1',";
    $conf[] = "  'RsyncdUserName' => '1',";
    $conf[] = "  'RsyncRestoreArgs' => '1',";
    $conf[] = "  'ClientCharsetLegacy' => '1',";
    $conf[] = "  'SmbClientFullCmd' => '0',";
    $conf[] = "  'ArchiveInfoKeepCnt' => '1',";
    $conf[] = "  'BackupZeroFilesIsFatal' => '1',";
    $conf[] = "  'EMailNoBackupRecentMesg' => '1',";
    $conf[] = "  'FullKeepCnt' => '1',";
    $conf[] = "  'TarShareName' => '1',";
    $conf[] = "  'EMailNoBackupEverSubj' => '1',";
    $conf[] = "  'TarClientRestoreCmd' => '0',";
    $conf[] = "  'EMailNoBackupRecentSubj' => '1',";
    $conf[] = "  'ArchivePar' => '1',";
    $conf[] = "  'XferLogLevel' => '1',";
    $conf[] = "  'ArchiveDest' => '1',";
    $conf[] = "  'ClientTimeout' => '1',";
    $conf[] = "  'EMailNotifyMinDays' => '1',";
    $conf[] = "  'RsyncdAuthRequired' => '1',";
    $conf[] = "  'SmbClientRestoreCmd' => '0',";
    $conf[] = "  'ClientNameAlias' => '1',";
    $conf[] = "  'DumpPostShareCmd' => '0',";
    $conf[] = "  'IncrLevels' => '1',";
    $conf[] = "  'EMailOutlookBackupMesg' => '1',";
    $conf[] = "  'BlackoutBadPingLimit' => '1',";
    $conf[] = "  'BackupFilesExclude' => '1',";
    $conf[] = "  'FullPeriod' => '1',";
    $conf[] = "  'ArchivePostUserCmd' => '0',";
    $conf[] = "  'RsyncClientRestoreCmd' => '0',";
    $conf[] = "  'IncrPeriod' => '1',";
    $conf[] = "  'RsyncShareName' => '1',";
    $conf[] = "  'RestorePostUserCmd' => '0',";
    $conf[] = "  'BlackoutGoodCnt' => '1',";
    $conf[] = "  'ArchiveClientCmd' => '0',";
    $conf[] = "  'ArchiveSplit' => '1',";
    $conf[] = "  'XferMethod' => '1',";
    $conf[] = "  'NmbLookupCmd' => '0',";
    $conf[] = "  'BackupsDisable' => '1',";
    $conf[] = "  'SmbShareName' => '1',";
    $conf[] = "  'RestorePreUserCmd' => '0',";
    $conf[] = "  'IncrKeepCntMin' => '1',";
    $conf[] = "  'EMailNoBackupEverMesg' => '1',";
    $conf[] = "  'EMailHeaders' => '1',";
    $conf[] = "  'DumpPreUserCmd' => '0',";
    $conf[] = "  'RsyncClientPath' => '0',";
    $conf[] = "  'DumpPostUserCmd' => '0'";
    $conf[] = "};";
    $conf[] = "";
    if (is_file("/usr/share/artica-postfix/bin/install/backuppc/BackupPC_stnd.css")) {
        @copy("/usr/share/artica-postfix/bin/install/backuppc/BackupPC_stnd.css", "/usr/share/backuppc/image/BackupPC_stnd.css");
    }
    if (is_file("/usr/share/artica-postfix/bin/install/backuppc/logo.gif")) {
        @copy("/usr/share/artica-postfix/bin/install/backuppc/logo.gif", "/usr/share/backuppc/image/logo.gif");
    }
    @file_put_contents($configfile, @implode("\n", $conf));
}
Пример #6
0
function vhosts_users_ou($array)
{
    $unix = new unix();
    $ldap = new clladp();
    $sock = new sockets();
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    $SSLStrictSNIVHostCheck = $sock->GET_INFO("SSLStrictSNIVHostCheck");
    $ou = $array["OU"][0];
    $apacheservername = trim($array["apacheservername"][0]);
    $wwwservertype = trim($array["wwwservertype"][0]);
    $wwwsslmode = $array["wwwsslmode"][0];
    $root = $array["apachedocumentroot"][0];
    $index_cgi = $unix->BACKUPPC_GET_CGIBIN_PATH();
    $img_dir = $unix->BACKUPPC_GET_IMG_DIR();
    if ($index_cgi == null) {
        echo "Starting Apache..............: BackupPC Unable to stat index.cgi\n";
        return;
    }
    if ($img_dir == null) {
        echo "Starting Apache..............: BackupPC Unable to images path\n";
        return;
    }
    @mkdir($root, 0755, true);
    shell_exec("/bin/cp {$index_cgi} {$root}/index.cgi");
    shell_exec("/bin/ln -s {$img_dir} {$root}/image >/dev/null 2>&1");
    shell_exec("chmod 4755 {$root}/index.cgi");
    patchIndex($root);
    $apacheuser = $unix->APACHE_GROUPWARE_ACCOUNT();
    if (preg_match("#(.+?):#", $apacheuser, $re)) {
        $apacheuser = $re[1];
    }
    shell_exec("chown -R backuppc:{$apacheuser} {$root}");
    system("chmod 4755 {$root}/index.cgi");
    $ApacheGroupWarePort_WRITE = $ApacheGroupWarePort;
    echo "Starting Apache..............: BackupPC checking host {$apacheservername} in {$root} for {$apacheuser}:backuppc\n";
    if ($wwwsslmode == "TRUE") {
        $ssl[] = "\tSSLEngine on";
        $ssl[] = "\tSSLCertificateFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.crt";
        $ssl[] = "\tSSLCertificateKeyFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.key";
        $unix->vhosts_BuildCertificate($apacheservername);
        $ApacheGroupWarePort_WRITE = "443";
        $SSLMODE = true;
        $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort}>";
        $conf[] = "\tServerName {$apacheservername}";
        $conf[] = "\tRedirect / https://{$apacheservername}";
        $conf[] = "</VirtualHost>\n";
    }
    echo "Starting Apache..............: BackupPC \"{$apacheservername}:{$ApacheGroupWarePort_WRITE}\"\n";
    $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort_WRITE}>";
    $conf[] = "\tServerName {$apacheservername}";
    //$conf[]="\tSuexecUserGroup backuppc backuppc";
    $conf[] = "\tServerAdmin webmaster@{$apacheservername}";
    $conf[] = "\tDocumentRoot {$root}";
    $conf[] = @implode("\n", $ssl);
    include_once dirname(__FILE__) . "/ressources/class.freeweb.inc";
    $freeweb = new freeweb();
    $conf[] = $freeweb->WebDavBrowserMatches();
    $conf[] = "\tAlias /backuppc {$root}";
    $conf[] = "\t<Directory \"{$root}\">";
    $conf[] = "\tAllowOverride None";
    $conf[] = "\tAllow from all";
    $conf[] = "\tOptions ExecCGI FollowSymlinks";
    $conf[] = "\tAddHandler cgi-script .cgi";
    $conf[] = "\tDirectoryIndex index.cgi";
    $conf[] = "\t\tAuthType Basic";
    $conf[] = "\t\tAuthBasicProvider ldap";
    $conf[] = "\t\tAuthzLDAPAuthoritative off";
    $conf[] = "\t\tAuthUserFile /dev/null";
    $conf[] = "\t\tAuthLDAPBindDN \"cn={$ldap->ldap_admin},{$ldap->suffix}\"";
    $conf[] = "\t\tAuthLDAPBindPassword {$ldap->ldap_password}";
    $conf[] = "\t\tAuthLDAPUrl ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/ou={$ou},dc=organizations,{$ldap->suffix}?uid";
    $conf[] = "\t\tAuthName \"Authorization required\"";
    $conf[] = "\t\trequire ldap-filter &(uid=*)";
    $conf[] = "\t\trequire valid-user";
    $conf[] = "\t</Directory>";
    $conf[] = "</VirtualHost>\n";
    return @implode("\n", $conf);
}
Пример #7
0
function CheckHomeFor($uid, $homeDirectory = null)
{
    if (!isset($GLOBALS["HomeDirectoriesMask"])) {
        LoadConfs();
    }
    $ct = new user($uid);
    if ($homeDirectory == null) {
        $homeDirectory = $ct->homeDirectory;
    }
    echo "Starting......: Home {$uid} checking home: {$homeDirectory}\n";
    if ($GLOBALS["profile_path"] == null) {
        $sock = new sockets();
        $profile_path = $sock->GET_INFO('SambaProfilePath');
        $GLOBALS["profile_path"] = $profile_path;
    }
    if ($ct->ou == null) {
        writelogs("{$uid}: OU=NULL, No a standard user...SKIP", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $ou = $ct->ou;
    $uid = strtolower($uid);
    $newdir = trim(getStorageEnabled($ou, $uid));
    if ($newdir != null) {
        $newdir = "{$newdir}/{$uid}";
        writelogs("LVM: [{$ou}]:: storage={$newdir};homeDirectory={$homeDirectory}", __FUNCTION__, __FILE__, __LINE__);
        if ($newdir != $homeDirectory) {
            writelogs("{$uid}:: change {$homeDirectory} to {$newdir}", __FUNCTION__, __FILE__, __LINE__);
            $ct->homeDirectory = $newdir;
            $ct->edit_system();
            $homeDirectory = $newdir;
        }
    }
    if ($homeDirectory == null) {
        $homeDirectory = "/home/{$uid}";
        writelogs("{$uid}:: change {$homeDirectory}", __FUNCTION__, __FILE__, __LINE__);
        $ct->homeDirectory = $homeDirectory;
        $ct->edit_system();
    }
    if ($GLOBALS["profile_path"] != null) {
        $export = "{$profile_path}/{$uid}";
        writelogs("Checking export:{$export}", __FUNCTION__, __FILE__, __LINE__);
        @mkdir($export);
        @chmod($export, 0775);
        @chown($export, $uid);
    }
    writelogs("Checking home:{$homeDirectory}", __FUNCTION__, __FILE__, __LINE__);
    @mkdir($homeDirectory);
    if ($GLOBALS["ArticaSambaAutomAskCreation"] == 1) {
        shell_exec("/bin/chmod {$GLOBALS["HomeDirectoriesMask"]} {$homeDirectory}");
    }
    @chown($homeDirectory, $uid);
    if ($ct->WebDavUser == 1) {
        $unix = new unix();
        $find = $unix->find_program("find");
        $apacheuser = $unix->APACHE_GROUPWARE_ACCOUNT();
        if (preg_match("#(.+?):#", $apacheuser, $re)) {
            $apacheuser = $re[1];
        }
        $internet_folder = "{$homeDirectory}/Internet Folder";
        if (!is_dir($internet_folder)) {
            @mkdir($internet_folder, $GLOBALS["SharedFoldersDefaultMask"], true);
        } else {
            @chmod($internet_folder, $GLOBALS["SharedFoldersDefaultMask"]);
        }
        $internet_folder = $unix->shellEscapeChars($internet_folder);
        echo "Starting......: Home {$uid} checking home: {$internet_folder}\n";
        writelogs("Checking {$ct->uid}:{$apacheuser} :{$internet_folder}", __FUNCTION__, __FILE__, __LINE__);
        shell_exec("/bin/chown -R {$ct->uid}:{$apacheuser} {$internet_folder} >/dev/null 2>&1 &");
        shell_exec("{$find} {$internet_folder} -type d -exec chmod {$GLOBALS["SharedFoldersDefaultMask"]} {} \\; >/dev/null 2>&1 &");
    }
}
Пример #8
0
function vhosts_users_ou($array)
{
    $unix = new unix();
    $ldap = new clladp();
    $sock = new sockets();
    $ApacheGroupware = $sock->GET_INFO("ApacheGroupware");
    if ($ApacheGroupware == null) {
        $ApacheGroupware = 1;
    }
    $ApacheGroupwareListenIP = $sock->GET_INFO("ApacheGroupwareListenIP");
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    $ApacheGroupWarePortSSL = $sock->GET_INFO("ApacheGroupWarePortSSL");
    $SSLStrictSNIVHostCheck = $sock->GET_INFO("SSLStrictSNIVHostCheck");
    $d_path = $unix->APACHE_DIR_SITES_ENABLED();
    if ($ApacheGroupware == 0) {
        $ApacheGroupwareListenIP = $sock->GET_INFO("FreeWebListen");
        $ApacheGroupWarePort = $sock->GET_INFO("FreeWebListenPort");
        $ApacheGroupWarePortSSL = $sock->GET_INFO("FreeWebListenSSLPort");
        echo "Starting......: Apache Webdav switch to Apache source\n";
        foreach (glob("{$d_path}/webdav-artica-*") as $filename) {
            echo "Starting......: Apache Webdav removing " . basename($filename) . "\n";
        }
    }
    if (!is_numeric($ApacheGroupWarePortSSL)) {
        $ApacheGroupWarePortSSL = 443;
    }
    if (!is_numeric($ApacheGroupWarePort)) {
        $ApacheGroupWarePort = 80;
    }
    if ($ApacheGroupwareListenIP == null) {
        $ApacheGroupwareListenIP = "*";
    }
    $ou = $array["OU"][0];
    $apacheservername = trim($array["apacheservername"][0]);
    $wwwservertype = trim($array["wwwservertype"][0]);
    $wwwsslmode = $array["wwwsslmode"][0];
    $root = $array["apachedocumentroot"][0];
    $ApacheGroupWarePort_WRITE = $ApacheGroupWarePort;
    $ww_account = $unix->APACHE_GROUPWARE_ACCOUNT();
    $users = loadWebDavUsers($ou);
    if (count($users) < 1) {
        return;
    }
    if ($wwwsslmode == "TRUE") {
        $ssl[] = "\tSSLEngine on";
        $ssl[] = "\tSSLCertificateFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.crt";
        $ssl[] = "\tSSLCertificateKeyFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.key";
        $unix->vhosts_BuildCertificate($apacheservername);
        $ApacheGroupWarePort_WRITE = "443";
        $SSLMODE = true;
        $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort}>";
        $conf[] = "\tServerName {$apacheservername}";
        $conf[] = "\tRedirect / https://{$apacheservername}";
        $conf[] = "</VirtualHost>\n";
    }
    echo "Starting Apache..............: WebDav \"{$apacheservername}:{$ApacheGroupWarePort_WRITE}\"\n";
    if (!is_dir($root)) {
        echo "Starting Apache..............: WebDav creating directory {$root}\n";
        @mkdir("{$root}", 755, true);
    }
    echo "Starting Apache..............: Apache user: {$ww_account}\n";
    system("/bin/chown -R {$ww_account} {$root}");
    $conf[] = "\n<VirtualHost {$ApacheGroupwareListenIP}:{$ApacheGroupWarePort_WRITE}>";
    $conf[] = "\tServerName {$apacheservername}";
    $conf[] = "\tServerAdmin webmaster@{$apacheservername}";
    $conf[] = "\tDocumentRoot /home";
    $conf[] = @implode("\n", $ssl);
    $conf[] = "\tDavLockDB \"{$root}/DavLock\"";
    $conf[] = "\tBrowserMatch \"Microsoft Data Access Internet Publishing Provider\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"MS FrontPage\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"^WebDrive\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"^WebDAVFS/1.[0123]\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"^gnome-vfs/1.0\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"^XML Spy\" redirect-carefully";
    $conf[] = "\tBrowserMatch \"^Dreamweaver-WebDAV-SCM1\" redirect-carefully";
    while (list($uid, $home) = each($users)) {
        $conf[] = "\t<Directory \"{$home}\">";
        echo "Starting Apache..............: WebDav \"{$uid}\"\n";
        $conf[] = "\tOptions Indexes FollowSymLinks Includes MultiViews";
        $conf[] = "\t\tAllowOverride None";
        $conf[] = "\t\tOrder allow,deny";
        $conf[] = "\t\tAllow from all";
        $conf[] = "\t\tDAV On";
        $conf[] = "\t\tAuthType Basic";
        $conf[] = "\t\tAuthBasicProvider ldap";
        $conf[] = "\t\tAuthzLDAPAuthoritative off";
        $conf[] = "\t\tAuthUserFile /dev/null";
        $conf[] = "\t\tAuthLDAPBindDN \"cn={$ldap->ldap_admin},{$ldap->suffix}\"";
        $conf[] = "\t\tAuthLDAPBindPassword {$ldap->ldap_password}";
        $conf[] = "\t\tAuthLDAPUrl ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/ou={$ou},dc=organizations,{$ldap->suffix}?uid";
        $conf[] = "\t\tAuthName \"Authorization required\"";
        $conf[] = "\t\trequire ldap-filter &(uid={$uid})";
        $conf[] = "\t\trequire valid-user";
        $conf[] = "\t\t<LimitExcept GET PUT HEAD OPTIONS POST>";
        $conf[] = "\t\t\tRequire valid-user";
        $conf[] = "\t\t</LimitExcept>";
        $conf[] = "\t</Directory>";
        $unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.samba.php --home {$uid}");
    }
    $conf[] = "LogLevel debug";
    $conf[] = "</VirtualHost>\n";
    return @implode("\n", $conf);
}