afterlogic / webmail-lite-8

Open-source webmail script for existing IMAP server

Home Page:https://afterlogic.org/webmail-lite-8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error before install

BrianLakstins opened this issue · comments

Initial install on IIS (Windows Server 2019) using PHP 7.4.5 results in error:

PHP Fatal error: Uncaught Error: Call to a member function GetTenantName() on bool in I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Module\Manager.php:426
Stack trace:
#0 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Module\Manager.php(463): Aurora\System\Module\Manager->GetModulesPaths()
#1 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Module\Manager.php(270): Aurora\System\Module\Manager->GetModulePath()
#2 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Module\Manager.php(91): Aurora\System\Module\Manager->loadModule()
#3 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Api.php(211): Aurora\System\Module\Manager->loadModules()
#4 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Application.php(97): Aurora\System\Api::Init()
#5 I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\index.php(21): Aurora\System\Application::Start()
#6 {main}
thrown in I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot\system\Module\Manager.php on line 426

Looks like it is failing on fileexists for the core module.
The module path is saying "/modules/"
The dirname(FILE) path is the root path plus "\system\Module"

This is coming back false:
if (@\file_exists($sModulePath.$sModuleName.'/Module.php'))

I'm unsure if the relative module path needs to be absolute, or the absolute path is taken into account somewhere already and it's not using the right base path for the web site.

Any ideas?

I found where the weirdness occurs. It's in Api.php. This is some log from it:

[11-May-2020 14:10:36 UTC] AU_APP_ROOT_PATH1
[11-May-2020 14:10:36 UTC] AU_APP_ROOT_PATH2
[11-May-2020 14:10:36 UTC] /
[11-May-2020 14:10:36 UTC] AU_APP_ROOT_PATH-dir=I:\data\IIS\dns9.co\webmail\webmail-lite-8\wwwroot
[11-May-2020 14:10:36 UTC] AU_APP_ROOT_PATH-realpath=

This is the code that generates the log:

error_log('AU_APP_ROOT_PATH1');
if (!defined('AU_APP_ROOT_PATH'))
{
	define('AU_APP_ROOT_PATH', rtrim(realpath(dirname(__DIR__)), '\\/').'/');
	error_log('AU_APP_ROOT_PATH2');
	error_log(print_r(AU_APP_ROOT_PATH, TRUE));
	$dir = dirname(__DIR__);
	error_log('AU_APP_ROOT_PATH-dir='.print_r($dir, TRUE));
	$realpath = realpath($dir);
	error_log('AU_APP_ROOT_PATH-realpath='.print_r($realpath, TRUE));
}

It looks like the "realpath" function is changing the directory result to a blank string. It's removing everything from it. The documentation for realpath does not seem to indicate that this is it's normal function.

realpath manpage has a note:

https://www.php.net/manual/en/function.realpath.php

Note:

The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

The standard security I put on web sites does not include executable permissions on all folders in the directory hierarchy.

There are many referenced to realpath in the code, so I updated the security to allow read and execute access to all folders in the hierarchy.

Allowing more security access fixed the problem.