Jump to content
Froxlor Forum
  • 0

Log lässt sich nicht öffnen


Go to solution Solved by d00p,

Question

Ich habe auf die neueste Version upgedatet und erhalte beim öffnen des Logs im Webinterface einen Fehler:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rainer' in 'where clause'

Der Benutzer rainer ist als Kunde angelegt und auch im Server-Berechtigungssystem auf Dateisystemebene hinterlegt für die Ordner des Benutzers.

Webserver: Apache/2.4.29 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1
PHP-Version: 7.2.24-0ubuntu0.18.04.1
MySQL-Server-Version: 5.7.28-0ubuntu0.18.04.4
Webserver-Interface: CGI-FCGI
Speicherauslastung:
MemTotal:        4039476 kB
MemFree:         1436424 kB
MemAvailable:    2697988 kB
System-Auslastung: 1.10 / 1.02 / 0.61
Kernel: 4.15.0-72-generic (x86_64)
Installierte Version: 0.10.10 (DB: 201912100)

 

 

Link to post
Share on other sites

15 answers to this question

Recommended Posts

  • 1
  • Solution

Also, auch hier, habe meinem admin ebenfalls das customers_see_all flag entzogen, ohne patch, erhalte ich auch diese Meldung, mit korrekt angewendetem Patch lässt sich die syslog problemlos öffnen

Link to post
Share on other sites
  • 0

Ich öffne: https://domain/froxlor/admin_logger.php?page=log

im Log auf dem Server steht gleichzeitig: tail -f  /var/log/apache2/error.log

[Fri Dec 20 21:10:23.314251 2019] [mpm_prefork:notice] [pid 15241] AH00163: Apache/2.4.29 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1 configured -- resuming normal operations
[Fri Dec 20 21:10:23.314279 2019] [core:notice] [pid 15241] AH00094: Command line: '/usr/sbin/apache2'
froxlor[27137]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rainer' in 'where clause'
froxlor[27137]: --- DEBUG: #0 /var/www/froxlor/lib/Froxlor/Database/Database.php(83): PDOStatement->execute(Array) #1 /var/www/froxlor/lib/Froxlor/Database/Database.php(104): Froxlor\Database\Database::pexecute(Object(PDOStatement), Array, true, true) #2 /var/www/froxlor/lib/Froxlor/Api/Commands/SysLog.php(130): Froxlor\Database\Database::pexecute_first(Object(PDOStatement), Array, true, true) #3 /var/www/froxlor/admin_logger.php(34): Froxlor\Api\Commands\SysLog->listingCount() #4 {main}
froxlor[27137]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rainer' in 'where clause'
froxlor[27137]: --- DEBUG: #0 /var/www/froxlor/lib/Froxlor/Database/Database.php(83): PDOStatement->execute(Array) #1 /var/www/froxlor/lib/Froxlor/Database/Database.php(104): Froxlor\Database\Database::pexecute(Object(PDOStatement), Array, true, true) #2 /var/www/froxlor/lib/Froxlor/Api/Commands/SysLog.php(130): Froxlor\Database\Database::pexecute_first(Object(PDOStatement), Array, true, true) #3 /var/www/froxlor/admin_logger.php(34): Froxlor\Api\Commands\SysLog->listingCount() #4 {main}
froxlor[27137]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rainer' in 'where clause'
froxlor[27137]: --- DEBUG: #0 /var/www/froxlor/lib/Froxlor/Database/Database.php(83): PDOStatement->execute(Array) #1 /var/www/froxlor/lib/Froxlor/Database/Database.php(104): Froxlor\Database\Database::pexecute(Object(PDOStatement), Array, true, true) #2 /var/www/froxlor/lib/Froxlor/Api/Commands/SysLog.php(130): Froxlor\Database\Database::pexecute_first(Object(PDOStatement), Array, true, true) #3 /var/www/froxlor/admin_logger.php(34): Froxlor\Api\Commands\SysLog->listingCount() #4 {main}
froxlor[27137]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rainer' in 'where clause'
froxlor[27137]: --- DEBUG: #0 /var/www/froxlor/lib/Froxlor/Database/Database.php(83): PDOStatement->execute(Array) #1 /var/www/froxlor/lib/Froxlor/Database/Database.php(104): Froxlor\Database\Database::pexecute(Object(PDOStatement), Array, true, true) #2 /var/www/froxlor/lib/Froxlor/Api/Commands/SysLog.php(130): Froxlor\Database\Database::pexecute_first(Object(PDOStatement), Array, true, true) #3 /var/www/froxlor/admin_logger.php(34): Froxlor\Api\Commands\SysLog->listingCount() #4 {main}

parallel zeigt tail -f  /var/kunden/logs/Froxlor/froxlor.log

[2019-12-20 21:16:10] froxlor.NOTICE: [API] list customers {"source":"admin","action":"30","user":"admin"} []

 

Möglicher Grund:

Normalerweise erhalten alle Kundenbenutzer im Datei-Berechtigungssystem von Ubuntu eine Nummer, die irgendwie von Froxlor kommt.

Ich habe eingestellt, dass das Berechtigungssystem diese UID automatisch auflöst in den Benutzernamen, in dem es den Benutzernamen direkt aus der SQL-Datenbank erhält. Ich weiß leider nicht mehr wo ich das eingestellt habe. Kann das damit zusammenhängen?

Link to post
Share on other sites
  • 0

Ist der Aufrufende zufällig ein Admin/Reseller der nicht alle Kunden sehen darf? Damit konnte ich es reproduzieren. Versuch mal folgenden Patch:

diff --git a/lib/Froxlor/Api/Commands/SysLog.php b/lib/Froxlor/Api/Commands/SysLog.php
index c10a33bd..61924105 100644
--- a/lib/Froxlor/Api/Commands/SysLog.php
+++ b/lib/Froxlor/Api/Commands/SysLog.php
@@ -105,7 +105,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
                        if (count($customer_names) > 0) {
                                $result_stmt = Database::prepare("
                                        SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
-                                       WHERE `user` = :loginname OR `user` IN (" . implode(', ', $customer_names) . ")
+                                       WHERE `user` = :loginname OR `user` IN ('" . implode("', '", $customer_names) . "')
                                ");
                        } else {
                                $result_stmt = Database::prepare("

 

Link to post
Share on other sites
  • 0

Danke! Ich habe nur einen Admin-Benutzer und er kann alles.

Es hat noch nicht geklappt.

 

Bei mir steht Entity statt Ent

class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntity

Und ich habe das hier ersetzt:

WHERE `user` = :loginname OR `user` IN ('" . implode("', '", $customer_names) . "')

Apache habe ich neugestartet.

 

Link to post
Share on other sites
  • 0

Das ist ein git diff...du sollst das nicht 1:1 übernehmen als Datei.

Das was du ersetzt hast ist korrekt und das um was es geht.

Apache brauchst du dafür nicht neustarten. Und was heisst "es hat noch nicht geklappt"? Bitte fehlermeldungen und logs.

Link to post
Share on other sites
  • 0

Ich habe dir alles geschickt.

 

Ich vermute, dass es um diese Tabelle geht:

INSERT INTO `panel_syslog` (`logid`, `action`, `type`, `date`, `user`, `text`) VALUES

Mich irritiert bei dem Fehler, dass er sagt, dass die Column als "rainer" benannt ist. Das klingt als ob das der Spaltenname wäre. Der Spaltenname ist aber "user". Vielleicht lese ich die Meldung ja falsch

Link to post
Share on other sites
  • 0

Gutes Stichwort! Ich kannte dieses Flag nicht. Nachdem ich das in der Datenbank auf 1 gestellt habe, klappt nun alles wieder. Danke!

Die Datei habe ich an der entsprechenden Stelle manuell verändert. Der Github-Befehl ist bei mir nicht vorhanden und ich weiß ihn auch nicht richtig anzuwenden. Nach der manuellen Veränderung hat sich aber mein Fehler nicht gelöst. Lösung war bisher das mit dem Flag.

<?php
namespace Froxlor\Api\Commands;

use Froxlor\Database\Database;

/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright (c) the authors
 * @author Froxlor team <team@froxlor.org> (2010-)
 * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package API
 * @since 0.10.6
 *       
 */
class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntity
{

	/**
	 * list all log-entries
	 *
	 * @param array $sql_search
	 *        	optional array with index = fieldname, and value = array with 'op' => operator (one of <, > or =), LIKE is used if left empty and 'value' => searchvalue
	 * @param int $sql_limit
	 *        	optional specify number of results to be returned
	 * @param int $sql_offset
	 *        	optional specify offset for resultset
	 * @param array $sql_orderby
	 *        	optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields
	 *        	
	 * @access admin, customer
	 * @throws \Exception
	 * @return string json-encoded array count|list
	 */
	public function listing()
	{
		$result = array();
		$query_fields = array();
		if ($this->isAdmin() && $this->getUserDetail('customers_see_all') == '1') {
			$result_stmt = Database::prepare("
			SELECT * FROM `" . TABLE_PANEL_LOG . "` " . $this->getSearchWhere($query_fields) . $this->getOrderBy() . $this->getLimit());
		} elseif ($this->isAdmin()) {
			// get all admin customers
			$_custom_list_result = $this->apiCall('Customers.listing');
			$custom_list_result = $_custom_list_result['list'];
			$customer_names = array();
			foreach ($custom_list_result as $customer) {
				$customer_names[] = $customer['loginname'];
			}
			if (count($customer_names) > 0) {
				$result_stmt = Database::prepare("
				SELECT * FROM `" . TABLE_PANEL_LOG . "`
				WHERE `user` = :loginname OR `user` IN (" . implode(', ', $customer_names) . ")" . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit());
			} else {
				$result_stmt = Database::prepare("
				SELECT * FROM `" . TABLE_PANEL_LOG . "`
				WHERE `user` = :loginname" . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit());
			}
			$query_fields['loginname'] = $this->getUserDetail('loginname');
		} else {
			// every one else just sees their logs
			$result_stmt = Database::prepare("
			SELECT * FROM `" . TABLE_PANEL_LOG . "`
			WHERE `user` = :loginname AND `action` <> 99 " . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit());
			$query_fields['loginname'] = $this->getUserDetail('loginname');
		}
		Database::pexecute($result_stmt, $query_fields, true, true);
		while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
			$result[] = $row;
		}
		$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list log-entries");
		return $this->response(200, "successfull", array(
			'count' => count($result),
			'list' => $result
		));
	}

	/**
	 * returns the total number of log-entries
	 *
	 * @access admin
	 * @throws \Exception
	 * @return string json-encoded array
	 */
	public function listingCount()
	{
		$params = null;
		if ($this->isAdmin() && $this->getUserDetail('customers_see_all') == '1') {
			$result_stmt = Database::prepare("
				SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
			");
		} elseif ($this->isAdmin()) {
			// get all admin customers
			$_custom_list_result = $this->apiCall('Customers.listing');
			$custom_list_result = $_custom_list_result['list'];
			$customer_names = array();
			foreach ($custom_list_result as $customer) {
				$customer_names[] = $customer['loginname'];
			}
			if (count($customer_names) > 0) {
				$result_stmt = Database::prepare("
					SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
					WHERE `user` = :loginname OR `user` IN ('" . implode("', '", $customer_names) . "')
				");
			} else {
				$result_stmt = Database::prepare("
					SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
					WHERE `user` = :loginname
				");
			}
			$params = [
				'loginname' => $this->getUserDetail('loginname')
			];
		} else {
			// every one else just sees their logs
			$result_stmt = Database::prepare("
				SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
				WHERE `user` = :loginname AND `action` <> 99
			");
			$params = [
				'loginname' => $this->getUserDetail('loginname')
			];
		}

		$result = Database::pexecute_first($result_stmt, $params, true, true);
		if ($result) {
			return $this->response(200, "successfull", $result['num_logs']);
		}
	}

	/**
	 * You cannot get log entries
	 */
	public function get()
	{
		throw new \Exception('You cannot get log entries', 303);
	}

	/**
	 * You cannot add log entries
	 */
	public function add()
	{
		throw new \Exception('You cannot add log entries', 303);
	}

	/**
	 * You cannot update log entries
	 */
	public function update()
	{
		throw new \Exception('You cannot update log entries', 303);
	}

	/**
	 * delete log entries
	 *
	 * @param int $min_to_keep
	 *        	optional minutes to keep, default is 10
	 *        	
	 * @access admin
	 * @throws \Exception
	 * @return string json-encoded array
	 */
	public function delete()
	{
		if ($this->isAdmin()) {
			$min_to_keep = self::getParam('min_to_keep', true, 10);
			if ($min_to_keep < 0) {
				$min_to_keep = 0;
			}
			$truncatedate = time() - (60 * $min_to_keep);
			$params = array();
			if ($this->getUserDetail('customers_see_all') == '1') {
				$result_stmt = Database::prepare("
					DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc
				");
			} else {
				// get all admin customers
				$_custom_list_result = $this->apiCall('Customers.listing');
				$custom_list_result = $_custom_list_result['list'];
				$customer_names = array();
				foreach ($custom_list_result as $customer) {
					$customer_names[] = $customer['loginname'];
				}
				if (count($customer_names) > 0) {
					$result_stmt = Database::prepare("
					DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc AND `user` = :loginname OR `user` IN (" . implode(', ', $customer_names) . ")
				");
				} else {
					$result_stmt = Database::prepare("
					SELECT COUNT(*) as num_logs FROM `" . TABLE_PANEL_LOG . "`
					DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc AND `user` = :loginname
				");
				}
				$params = [
					'loginname' => $this->getUserDetail('loginname')
				];
			}
			$params['trunc'] = $truncatedate;
			Database::pexecute($result_stmt, $params, true, true);
			$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] truncated the froxlor syslog");
			return $this->response(200, "successfull", true);
		}
		throw new \Exception("Not allowed to execute given command.", 403);
	}
}

 

Link to post
Share on other sites
  • 0

Die gleiche Änderung wie für listingCount() muss auch in listing() vorgenommen werden, aber dein Problem lag in der Tat an den fehlenden Berechtigungen des admins, da ist mir auch jetzt noch ein Rätsel wie du das geschafft hast ;)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...