From 6878585a2fc89b5a05782a54da2b6e8fa8f8843e Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Fri, 26 Jan 2018 14:50:33 +0100
Subject: [PATCH] ci server - sync-Packages cronjob runs as www-data - no sudo
 required --> remove runas

---
 shellscripts/cron_deployment.php    | 4 ++++
 shellscripts/cron_sync_packages.php | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/shellscripts/cron_deployment.php b/shellscripts/cron_deployment.php
index 29b47151..a0162b8c 100644
--- a/shellscripts/cron_deployment.php
+++ b/shellscripts/cron_deployment.php
@@ -9,6 +9,10 @@
 // http://iml:deployment@ci.iml.unibe.ch/deployment/?prj=ci&action=deploy&par3=preview&confirm=1
 
 $sDocroot = (dirname(__dir__)) . "/public_html";
+$processUser = posix_getpwuid(posix_geteuid());
+if ($processUser['name']=="root"){
+    die("Do not start the script as user root\n");
+};
 
 require_once("$sDocroot/deployment/classes/logger.class.php");
 global $oCLog;
diff --git a/shellscripts/cron_sync_packages.php b/shellscripts/cron_sync_packages.php
index 11ff4cd4..3536b8a4 100644
--- a/shellscripts/cron_sync_packages.php
+++ b/shellscripts/cron_sync_packages.php
@@ -9,6 +9,10 @@
     require_once(dirname(__DIR__)."/config/inc_projects_config.php");
     
     echo "\n========= SYNC archive files ==========\n";
+    $processUser = posix_getpwuid(posix_geteuid());
+    if ($processUser['name']=="root"){
+        die("Do not start the script as user root\n");
+    };
     
     if (array_key_exists('mirrorPackages', $aConfig) && count($aConfig['mirrorPackages']) ){
         foreach (array_keys($aConfig["phases"]) as $sPhase){
-- 
GitLab