• Resolved Akeif

    (@akeif)


    Hi all!

    I’ve recently installed a WordPress Multisite install to run a shared server for a group of my clients.

    I’m having trouble making wordpres use the umask I’ve set on my server.

    Here’s more detail of my tech stack before I go on

    Ubuntu 12.04, on Amazon EC2
    Most recent version of Apache2, PHP and MySQL

    I’ve added umask 007 to /etc/apache2/envvars wich make apache set file to 660 and folder to 770 on creation. I’ve tested it with PHP native functions and it works.

    But when I install/upgrade themes and plugins file permissions are set to 644 and folder to 755, wich is giving me problems since I need everyone in the group i’ve set to write on the files.

    The owner are set correctly, wich is www-data:www (www is a group i created).

    So basicaly WordPress bypass my config file.

    I’ve try creating a plugin function

    wpblog_fix_umask(){
    	umask('007');
    }
    add_action( 'init', 'wpblog_fix_umask' );

    Doesn’t work.

    Tried adding umask(‘007’) in the wp-config.php. Doesn’t work either.

    Any one have any suggestion?

    Google doesn’t help by the I’ve been searching for over 4 hours :p

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Akeif

    (@akeif)

    On another note I’ve notice that the unzip command doesn’t preserve file permissions.

    It’s probably the source of the issue since the plugins are downloaded by WP in zip format and then unziped.

    Thread Starter Akeif

    (@akeif)

    Ok so basicly I haven’t found how to have unzip use correct umask. Everything else use the correct umask.

    Sow i’ve fix this by monitoring folder creations in /wp-content/themes and /wp-content/plugins.

    When a theme or plugin is installed it create the folder again, so you can run a script to change the permissions as you need.

    Install iwatch.

    sudo apt-get update
    sudo apt-get install iwatch

    Then, on ubuntu you need to add your commands to /etc/init.d/rc.local
    sudo vi /etc/init.d/rc.local

    The commands look like this

    iwatch -c "/home/ubuntu/bin/fix-permissions %f" -e create /var/www/wp-content/plugins > /dev/null 2>&1 &"
    iwatch -c "/home/ubuntu/bin/fix-permissions %f" -e create /var/www/wp-content/themes > /dev/null 2>&1 &"

    Of course you have to create your own fix-permissions scripts and set it as an executable.

    And reboot.

    There’s going to be 2 iwatch process that will run and update your permissions as needed.

    That’s it.

    If you have any other idea or solution please share 🙂

    For me (on Ubuntu) I had to add umask 002 to /etc/apache2/envvars in order to get WordPress to upload plugins/images with 775 permissions instead of 755 (i.e. allow anyone besides Apache and root to change the uploaded files)

    Thread Starter Akeif

    (@akeif)

    For me (on Ubuntu) I had to add umask 002 to /etc/apache2/envvars in order to get WordPress to upload plugins/images with 775 permissions instead of 755 (i.e. allow anyone besides Apache and root to change the uploaded files)

    Thanks Will for the reply.

    I’ve added umask 002 to the file a while ago and it didn’t work for me. There must be something I’m missing because it worked for most people.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fail to make WP set the umask I want’ is closed to new replies.