Archive for February, 2010

Screen – Like Ubuntu on any Linux distro

By Mark Davidson on February 6th, 2010

Just a real quick post about screen if you’ve ever used Ubuntu screen you might find its a bit nicer than the standard screen you find on other Linux distros. There is a brief intro here Ubuntu brings advanced Screen features to the masses, now if you’ve ever wondered how to get the same sort of setup on distros such as Debian and Gentoo here is the very simple process.

  1. Login to your server and change into you home directory.
  2. wget http://people.ubuntu.com/~kirkland/byobu/byobu.tar.gz
  3. tar -xzvf byobu.tar.gz (be warned this will overwrite your current .screenrc)
  4. Thats it fire up screen and you should be up and running.

Its worth noting that you can tweak what different status updates appear at the bottom of the screen session by modifiying ~/.byobu/status its just a case of uncommenting or commenting out the ones you want to use, then restarting the screen session for the changes to take affect. Gentoo in particular seemed to work well and supported almost all the options.

Linux Find and Modification Time

By Mark Davidson on February 5th, 2010

Recently I needed to do some cleaning up of some temporary files on one of my web servers so I came up with this find command

find . -mtime +1 -type f -printf '%p %Ax\n'

this command will list files in the current directory that where last modified more than 24 hours ago, when printing out the file names it will also print out the date the file was last modified.

find . -mtime +1 -type f -printf '%AY-%Am-%Ad %AT %p\n' | sort

makes use of some more conditions within the printf and the sort command. By putting the date on the front of each entry which is printed out and using the sort command the files are printed in chronological order.

find . -mtime +0 -type f -print0 | xargs -0 du -csh

is the final example I will give this time which combines using find with xargs and du in order to find the disk usage of all the files that match the find condition.

WordPress & Apache mod_security: Part 01

By Mark Davidson on February 5th, 2010

After my initial post about wordpress and mod_security, I decided to have a bit more of a look around to find what rules other people had needed to disable to get it working.

I found a really good post over at Gray.me.uk – Mod security and wordpress the final config which had a few additional rules mentioned, but did not solve the problems I was having initially. So I thought I would draw on what they had posted and what I have learnt to produce a fully working list of rules that need to be disabled in order for WordPress 2.9.1 and mod_security Core Rules 2.0.3 to work together.

Below follows an example vhost file the important elements of it being the LocationMatch tags containing the SecRuleRemovedById.

<VirtualHost *:80>
    ServerName pablumfication.co.uk
    ServerAlias www.pablumfication.co.uk

    DocumentRoot /var/www/pablumfication.co.uk
    <Directory />
        Options +FollowSymLinks
        AllowOverride FileInfo
    </Directory>

    <LocationMatch "/>
        SecRuleRemoveById 910006 # Google robot activity - Useful in someways but noisy for sites where you want them crawled
        SecRuleRemoveById 960015 # Request Missing an Accept Header -  Allow for Google Reader
    </LocationMatch>

    <LocationMatch "/wp-includes/">
        SecRuleRemoveById 960010 # Request content type is not allowed by policy - Allows for amongst other things spell check to work on admin area
        SecRuleRemoveById 960012 # Require Content-Length to be provided with every POST request - Same as above
    </LocationMatch>

    <LocationMatch "(/wp-admin/|/wp-login.php)">    
        SecRuleRemoveById 950005 # Remote File Access Attempt - This rule probably doesn't need to be disabled by everyone but it stops me putting /etc/ in posts and other such linux paths.
        SecRuleRemoveById 950117 # Remote File Inclusion Attack - Disable to allow http:// to be passed in args
    </LocationMatch>

    <LocationMatch "(/wp-admin/post.php|/wp-admin/options.php|/wp-admin/theme-editor.php|/wp-includes/)">
        SecRuleRemoveById 950006 # System Command Injection - Another rule that probably doesn't need to be disabled by everyone it stops .exe and various other extensions being passed in args.
    </LocationMatch>
</VirtualHost>