Maiux Consulenza Informatica – Roma Assistenza per computer, connessioni ad internet e reti locali. Realizzazione e gestione siti web

Quick permissions management for NextGEN using CPanel hosting

Posted on maggio 22, 2011

NextGEN is a WordPress plugin that allows pictures gallery management. It has many features, included thumbnail generation. Usually the thumbnails get "nobody" user ownership and are writeable from the Apache process: this makes your website more vulnerable.

These are two bash scripts I wrote to relax permissions of directories or fix permissions and ownership of directories and thumbnails in galleries managed by NextGEN.

The first one relaxes the permissions on directories, so you can manage the gallery adding and removing images, editing them (i.e. watermarking) and creating thumbnails.

The second one fixes the ownership on eventually created thumbnails and resets the permissions on directories and files enforcing security.

You can use them if you got a shell access to your hosting server.

WARNING: they are in beta stage and may not work with another configuration, or potentially cause data loss. So review carefully before running them 😉

Enjoy!

relax_permissions.sh

#!/bin/bash
#
# script to relax permissions to make possible thumbnail creation on NextGEN gallery (WordPress plugin)
#
# by maiux (2011) - development@maiux.com
#
# DISCLAIMER: USE AT YOUR OWN RISK, I'M NOT RESPONSIBLE OF ANY DATA LOSS: THIS IS A BETA SCRIPT
#
#
FIND_DIRS=$(find * -type d -maxdepth 0)

echo "Relaxing directory permissions (0777, rwxrwxrwx)..."
find $FIND_DIRS -type d -exec chmod 0777 {} \;

echo "Relaxing file permissions (0666, rw-rw-rw-)..."
find $FIND_DIRS -type f -exec chmod 0666 {} \;     

echo "If you didn't see any error message, job is done"

fix_ownership_and_permissions.sh

#!/bin/bash
#
# script to fix ownership and permissions after thumbnail creation on NextGEN gallery (WordPress plugin)
#
# by maiux (2011) - development@maiux.com
#
# DISCLAIMER: USE AT YOUR OWN RISK, I'M NOT RESPONSIBLE OF ANY DATA LOSS: THIS IS A BETA SCRIPT
#
#
FIND_DIRS=$(find * -type d -maxdepth 0)

echo Fixing thumbnails ownership...
find $FIND_DIRS -user nobody -name "thumbs_*" -print -exec gzip {} \; -exec gunzip {}.gz \;

echo "Fixing file permissions (0644, rw-r--r--)..."
find $FIND_DIRS -type f -exec chmod 0644 {} \;     

echo "Fixing directory permissions (0755, rwxr-xr-x)..."
find $FIND_DIRS -type d -exec chmod 0755 {} \;

echo "If you didn't see any error message, job is done"
Inserito in: NextGEN Comments Off
Commenti (0) Trackback (0)

Spiacenti, il modulo dei commenti è chiuso per ora.

Trackbacks are disabled.