Cant access eximstats sqlite3 db after WHM64 upgrade

一曲冷凌霜 提交于 2019-12-31 04:57:05

问题


After WHM 64 upgradation, cant access eximstat db. MySQL code changed to PDO for accessing sqlite3 db as follows:

$db = new PDO('sqlite:/var/cpanel/eximstats_db.sqlite3', DB_USER, DB_PASSWORD);

The failues, defers tables are all blank. In fact, a new blank file was getting created in the var/cpanel directory, instead of getting connection to eximstats db. Surprisingly, CPanel:'View Sent summary' fetch information all correctly, But I cant access in my script which is residing on the domain.

Any help is greatly appreciated.

Thanks!!


回答1:


During a chat with the excellent support of cPanel, we figured out this:

It is a problem with rights for eximstats_db.sqlite3 table: you are trying to access the database as a non-root user, but database is owned by root and only writable by root.

In theory you should be able to access the file directly by passing the SQLITE3_OPEN_READONLY flag to the call to open the file as outlined here:

https://secure.php.net/manual/en/sqlite3.open.php

So granting read access to eximstats_db.sqlite3 tables (NB! there are 3 of them):

-rw----r-- 1 root root 135168 Jun 10 06:06 eximstats_db.sqlite3
-rw----r-- 1 root root 32768 Jun 12 14:34 eximstats_db.sqlite3-shm
-rw----r-- 1 root root 1058512 Jun 12 14:34 eximstats_db.sqlite3-wal

and using

$dbh = new SQLite3('/var/cpanel/eximstats_db.sqlite3',SQLITE3_OPEN_READONLY);

should work, but it doesn't. It appears to be a limitation with the SQlite3 library within PHP: even for read-only access it wants to lock access to the file. So you need to give them also write access:

-rw----rw- 1 root root 135168 Jun 10 06:06 eximstats_db.sqlite3
-rw----rw- 1 root root 32768 Jun 12 14:34 eximstats_db.sqlite3-shm
-rw----rw- 1 root root 1058512 Jun 12 14:34 eximstats_db.sqlite3-wal

That's that. After that, you'll see the defers, failures and other tables.

(Of course, in real life you might want to create a group and give read-write access to that group only, not everybody).


If you are not able to change permissions to these database files then the only solution I can see is to copy the files to domain, change the permissions there and then use these files instead:

$target = '/var/cpanel/eximstats_db.sqlite3-shm';
$newfile = '/home/yourdomain/where/your/script/is/eximstats_db.sqlite3';
copy($target, $newfile);
chmod($newfile, 0777);
// same with all 3 files..
$dbh = new SQLite3('eximstats_db.sqlite3'); // not '/var/cpanel/eximstats_db.sqlite3'!


来源:https://stackoverflow.com/questions/44499844/cant-access-eximstats-sqlite3-db-after-whm64-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!