Cant access eximstats sqlite3 db after WHM64 upgrade

后端 未结 1 810
被撕碎了的回忆
被撕碎了的回忆 2021-01-27 04:03

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         


        
1条回答
  •  深忆病人
    2021-01-27 04:43

    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'!
    

    0 讨论(0)
提交回复
热议问题