• I use WP-CLI to update WordPress and all its plugins. Ever since the update to WordPress 4.5 (now 4.5.1), I keep getting the following error message whenever I run an update through WP-CLI:

    Unable to open /home/wp-content/wflogs/config.php for reading and writing.

    However, the update seems to complete successfully.

    Can anyone help?

    Thanks.

    https://www.ads-software.com/plugins/wordfence/

Viewing 15 replies - 1 through 15 (of 26 total)
  • Hello spambayes,
    I suspect that the folder has different owner/group (i.e. the ones apache/php are running as) than what WP-CLI is running as?

    I have the same issue on 4.4.2.

    wp-content/wflogs/config.php is owned by the web server and has read write permissions. But the user that runs wp.cli is the group and starts with read and write permissions but after a day these permissions are removed.

    There is reference to this issue on https://www.ads-software.com/support/topic/firewall-doesnt-configure-directory-permissions?replies=12#post-8273703 but I cannot see how replacing core WordPress functionality would be a fix for a plugin.

    @wfasa do you have any ideas why this file in particular would have it group permissions removed? No other files in the same sub directory or the rest of my WordPress installation have this issue.

    Thanks.

    Plugin Author WFMattR

    (@wfmattr)

    Hi ta5ae,

    I saw the other request you’ve sent us too, and I’ve forwarded this on to the dev team (reference number FB1721) so they can check it out. The permissions are changed as a side effect of writing files safely when multiple visits on busy sites (or during attacks) are also trying to read it.

    -Matt R

    Thread Starter spambayes

    (@spambayes)

    ls -l returns the following for /wp-content/wflogs:

    drwxr-xr-x  2 web     web         8 Apr 27 01:45 wflogs

    and the following under /wflogs:

    -rw-rw-r--  1 web  web  40083 Apr 26 03:32 attack-data.php
    -rw-------  1 web  web    751 Apr 27 01:45 config.php
    -rw-rw-r--  1 web  web     51 Apr 26 03:32 ips.php
    -rw-rw-r--  1 web  web  18457 Apr 26 03:32 rules.php
    -rw-rw-r--  1 web  web  13814 Apr 26 03:32 wafRules.rules

    Any suggestions?

    Thanks.

    Plugin Author WFMattR

    (@wfmattr)

    Hi spambayes,

    We’re looking at preventing the warning in a future version. I’ve confirmed with the dev team that this shouldn’t cause an issue with the way the firewall works, in the meantime. Sorry for the inconvenience!

    -Matt R

    Same problem for me… tryed to change file permission, nothing happened
    Antonio

    Why does Wordfence need write access to a config file?

    Same issue for me, except I get these errors in my logs on every web access. This whole firewall feature has been very problematic and not worked for me since it has been introduced.

    https://www.ads-software.com/support/topic/firewall-cant-write-to-wflogs-repeatedly-even-after-being-fixed

    Same problem with me since latest version 6.1.9 on all my websites:

    Fatal error: Uncaught exception ‘wfWAFStorageFileException’ with message ‘Unable to open /www/wp-content/wflogs/ips.php for reading and writing.’ in /wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php:355 Stack trace: #0 /www/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php(452): wfWAFStorageFile->open() #1 /www/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php(409): wfWAFStorageFile->fetchConfigData() #2 /www/wp-content/plugins/wordfence/lib/wordfenceClass.php(729): wfWAFStorageFile->getConfig(‘wafStatus’) #3 [internal function]: wordfence::enqueueAJAXWatcher(‘plugins.php’) #4 /www/wp-includes/plugin.php(525): call_user_func_array(‘wordfence::enqu…’, Array) #5 /www/wp-admin/admin-header.php(92): do_action(‘admin_enqueue_s…’, ‘plugins.php’) #6 /www/wp-admin/plugins.p in /www/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/storage/file.php on line 355

    Same problem as Cavor is having.

    brewmaster,
    Wordfence needs to write configurations to a file and get them from there instead of writing them to the database because the Firewall loads before any other code on your site loads. At that point a database connection has not yet been established.

    We have released a quick update 6.1.10 which should fix the ‘wfWAFStorageFileException’ errors you are experiencing.

    Thanks.

    Hi,

    could it be that this file is created by a WP CRON Job? My Crons are not running in the wordpress calls itself (as suggested by WP), but by cron-jobs in Linux.
    They are again and again then owned by “root.root” and the webserver can’t read them.

    Is this file created/touched by CRON functionality?

    Regards,
    Andy

    Any resolution to this?

    I’m having this same issue with WF saying this:
    “Unable to open /usr/share/nginx/html/wp-content/wflogs/config.php for reading and writing.”

    Lots of these errors showing up for me and nothing being written to wflogs/config.php…

    Permissions are:
    drwxr-xr-x 2 www-data www 4096 Aug 6 11:45 .
    drwxrwsr-x 11 www-data www 4096 Aug 6 11:28 ..
    -rw-rw—- 1 www-data www 40083 Aug 5 15:45 attack-data.php
    -rw-rw—- 1 root root 874 Aug 6 11:45 config.php
    -rw-rw-r– 1 www-data www 133 Aug 5 15:45 .htaccess
    -rw-rw—- 1 www-data www 51 Aug 5 15:45 ips.php
    -rw-rw-r– 1 www-data www 21288 Aug 5 15:45 rules.php
    -rw-rw—- 1 www-data www 14996 Aug 5 15:45 wafRules.rules

    You’ll notice config.php is owned by root:root. Wordfence appears to keep changing the permissions of this file back from my web server user and group of www-data:www after I changed them, thinking that was the problem…

    And I just checked the Wordfence Diagnostic page and it says the process is being run by www-data:
    Process Owner: www-data
    And absolutely everything else on that Diagnostics page is in the green.

    Please help!

    Well, I seemed to fix this by disabling and removing the plugin, deleting all the files (.user.ini and wordfence-waf.php file in the web root, ran the wordfence assistant plugin, removed all the wordfence data, deleted all the tables just to be sure, then re-installed Wordfence again (removed the assistant plugin) and manually re-added “auto_prepend_file = ‘/usr/share/nginx/html/wordfence-waf.php'” to my php.ini file and now everything works fine.
    Just as a side note, I also granted all privileges on my mysql user for wordpress, since before it was giving me errors about not being able to access certain columns in certain tables, and not being able to drop some info / tables from the db.
    Anyway, as a result of all this, Wordfence now seems to be working well, no more errors in the logs (so far…), etc.
    Hope this helps someone!

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘Unable to open /wflogs/config.php for reading and writing’ is closed to new replies.