From b5393299aa0bde564c61db09dddb33ebab2f5974 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Wed, 19 Apr 2017 16:46:34 +0200
Subject: [PATCH] deployment gui - task#1411 - commands on cli will be executed
 with "cliadmin"

---
 config/inc_user2roles.php                     | 1 +
 public_html/deployment/classes/user.class.php | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/config/inc_user2roles.php b/config/inc_user2roles.php
index 19e2b562..bba2fe5e 100644
--- a/config/inc_user2roles.php
+++ b/config/inc_user2roles.php
@@ -11,6 +11,7 @@ return array(
     // "developer" => array(),
     // "projectmanager" => array(),
     "admin" => array(
+        "cliadmin", // generic cli user from user class
         "hahn",
         "dschueler",
     ),
diff --git a/public_html/deployment/classes/user.class.php b/public_html/deployment/classes/user.class.php
index 6536ee96..7df8085a 100644
--- a/public_html/deployment/classes/user.class.php
+++ b/public_html/deployment/classes/user.class.php
@@ -64,6 +64,9 @@ class user {
         if (!$sUser && is_array($_SERVER) && array_key_exists("PHP_AUTH_USER", $_SERVER)){
             $sUser=$_SERVER["PHP_AUTH_USER"];
         }
+        if (php_sapi_name() == "cli") {
+            $sUser="cliadmin";
+        }
         return $sUser;
     }
 
@@ -190,7 +193,7 @@ class user {
      * @return type
      */
     public function showDenied(){
-        return '<div class="alert alert-danger" role="alert">'
+        return 'USER: ' . $this->_sUsername . ' - groups ' . print_r($this->getUserGroups(),1) . '<div class="alert alert-danger" role="alert">'
         . t("class-user-error-deny-no-role").'<br>('.$this->_sLastCheckedPermission.')</div><br>'
         . '<a href="/deployment/all/login/" class="btn btn-primary">'.t('menu-login').'</a>'
         ;
-- 
GitLab