1

The Codex notes that wp-config.php can be used to over-ride file permissions by adding:

define('FS_CHMOD_FILE', 0644);
define('FS_CHMOD_DIR', 0755);

Having done this... why then, when using an ftp app to view the permissions of a file, are they shown as different?

For example, by ftp I set wp-config.php to 600 before modifying it - and by ftp it still appears to be 600 rather than the 644 set in wp-config.php.

  • Those settings are not going to retroactively change any files in your WP directory structure. – C C Jan 25 '17 at 14:06
  • @ C C ... thanks. didn't know that. Assumed that it would. – glvr Jan 30 '17 at 8:10
1

FS_CHMOD_FILE and FS_CHMOD_DIR are applicable only if both of the following criteria are satisfied ...

  • the host allows the change in permissions (for an explanation on this, please see https://superuser.com/a/767261 )
  • the files are created by WordPress (such as WordPress core updates / upgrades, plugin installations / updates, theme installations / updates, or user uploaded media via example.com/wp-admin/media-new.php or using new post / page, etc)

So, considering the above criteria, the following statements are true...

  • permissions of existing files and folders are not modified (by WordPress) just because FS_CHMOD_FILE and FS_CHMOD_DIR are set now!
  • permissions of files that are created / uploaded via FTP/SFTP/SCP/rsync are not modified by WordPress, even after FS_CHMOD_FILE and FS_CHMOD_DIR are set.

I hope this clarifies about your following concerns...

Having done this... why then, when using an ftp app to view the permissions of a file, are they shown as different?

For example, by ftp I set wp-config.php to 600 before modifying it - and by ftp it still appears to be 600 rather than the 644 set in wp-config.php.

  • @ Pothi ... thanks.I think I now understand. Why I'd asked this was that, following a server hack, permissions had changed to 200. Wanting to temporarily reactivate so that I could use Wordpress plugins to investigate and not knowing enough to use command line to reset, I used ftp to quickly set a recursive 755 and then wanted to want a quick way to then revert the files to 644. – glvr Jan 27 '17 at 6:18
  • Got it. If you have access to the server resources, a more reliable and easier way to setup permissions is to use Access Control List. For even further fine-control over permissions, SELinux/Apparmor helps. – Pothi Kalimuthu Jan 27 '17 at 6:26
  • @ Pothi Kalimuthu... thanks. It's a managed server, because I don't have enough tech knowledge to handle bare/root. – glvr Jan 30 '17 at 8:15
1

Having done this... why then, when using an ftp app to view the permissions of a file, are they shown as different?

This is because changing the mode will not happen for all files at once, but only in certain scenarios and only for certain folders, and on certain actions, for instance, when upgrading:

File: wp-admin/includes/class-core-upgrader.php
134:        // Copy update-core.php from the new version into place.
135:        if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
136:            $wp_filesystem->delete($working_dir, true);
137:            WP_Upgrader::release_lock( 'core_updater' );
138:            return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' );
139:        }

At the end you must do that from the command line of your web server or check with the hosting support what is the best way to do so.

  • @ prosti ... thanks. That's something of which I wasn't aware. – glvr Jan 27 '17 at 6:20
  • Quick update... unable to sufficiently understand SSH, and hence ann FTP user, by using Filezilla (rather than Transmit) I've been able to recursively set appropriate permissions. – glvr Jan 30 '17 at 8:16
  • @gulliver were you able to set these permissions recursively at the end? Do you need help in there? – prosti Jan 30 '17 at 8:23
  • @ prosti ... thanks.Yes - as in previous comment, a different ftp app sorted it. – glvr Feb 2 '17 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.