Archive for November 2009

PHP Network Upgrade Operation, Phase III: SQLite Compliance

The final of three planned phases of upgrades and improvements to the official worldwide PHP network is nearing a close, and this particular phase – though it was the simplest of the three – proved to be the most error-prone on our side. You can page through my communications with our army of mirror maintainers in the PHP news server archives.

First came the glitch with the Google Docs link to the application to become an official php.net mirror. After a few rather embarrassing moments – despite the fact that the same link had worked every time until now – it appeared to be resolved.

Almost simultaneously, a bug was discovered in the console we use to administer the mirrors around the world. After receiving reports from systems administrators and datacenters from all corners of the globe stating that they were, indeed, in compliance, Hannes Magnusson applied a patch which successfully corrected the issues.

Now, however, it seems that we’re pretty much back on track for a successful completion of the third upgrade phase, which means that the PHP Webmaster Team can then focus on adding new features and fixing bugs with a common target system configuration in mind. It also means that the general PHP community will reap the benefits of a better, more stable, more powerful network.

As a side note, if you love PHP and want to give a quick thanks to the folks in your country who operate the mirrors you use, please check out the list of official mirrors and visit the website of the corresponding maintainer. If it weren’t for these dedicated folks providing hardware, bandwidth, and maintenance services free-of-charge, the PHP project would probably not be nearly as successful as it is today…. and you might still be waiting for that download of PHP 3 to finish!

Finding Which php.ini Is Loaded

This is actually a throwback to the post Overriding PHP Settings, but is presented here separately due to the number of times the question is asked.

If you’re on a *NIX-based system and are trying to figure out which php.ini is being loaded by the CLI, simply run the following command:

ls -l `/bin/env php -i | grep "Loaded Configuration File" | sed 's/.*=> //g'`

If you want to edit the file right from that command, simply replace ‘ls -l’ with an editor of your choice, such as:

vi `/bin/env php -i | grep "Loaded Configuration File" | sed 's/.*=> //g'`

Script to Automate Multi-User Development Permissions In Linux: Part II

As discussed in the previous entry a few moments ago:

While deploying a large virtual server for a client, one of the obstacles they had faced with their previous setup was multi-user permissions with regard to everyone modifying files and directories with their own FTP and/or SSH accounts. Unfortunately, for reasons that won’t be divulged here (quite frankly because I don’t know), and even after I suggested alternatives such as updating policies and standard operating procedures, the client opted to continue using previous methods, but still wanted a resolution to issues they faced in their multi-developer environment.

The following simple Bash script is called directly via a cron job every fifteen minutes:


#!/bin/bash

mode='4771';

# The directory in which "multiUserPermissionsFix" resides.
dir='/danbrown/scripts/';

if ( test "`whoami`" != 'root' ); then
echo "$0 MUST be run as root!";
exit -1;
fi;

if ( test "$1" == "" ); then
echo "You must specify the base directory.";
exit -1;
fi;

if ( test "$2" == "" ); then
echo "You must specify the group ownership to set.";
exit -1;
fi;

if [ -d "$1" ]; then

echo -n "Verifying ownership and group ownership of all files.... ";
chown -R $2:$2 $1;
echo "Done.";

cd $1;

echo -n "Resetting permissions now.... ";
find . -type d -exec chmod $mode '{}' \;
# for i in `find . -type d`; do
# chmod $mode $i;
# done;
echo "Done.";

echo -n "Verifying ownership requirements.... ";
find . -type d -exec chmod o+s '{}' \;
# for i in `find . -type d`; do
# chmod o+s $i;
# done;
echo "Good.";

echo -n "Verifying group requirements.... ";
find . -type d -exec chmod g+s '{}' \;
# for i in `find . -type d`; do
# chmod g+s $i >> /dev/null 2>&1
# done;
echo "Good.";

if [ "$?" != "0" ]; then
echo "That group does not exist!";
exit -1;
fi;

echo -n "Fixing bad permissions.... ";
$dir/multiUserPermissionsFix $1;
echo "Done.";

echo "Task Complete.";

exit 0;

else

echo "That directory doesn't exist!";
exit -1;

fi;

Script to Automate Multi-User Development Permissions In Linux: Part I

While deploying a large virtual server for a client, one of the obstacles they had faced with their previous setup was multi-user permissions with regard to everyone modifying files and directories with their own FTP and/or SSH accounts. Unfortunately, for reasons that won’t be divulged here (quite frankly because I don’t know), and even after I suggested alternatives such as updating policies and standard operating procedures, the client opted to continue using previous methods, but still wanted a resolution to issues they faced in their multi-developer environment.

To address one particular issue, I wrote the following very simple Bash script and set it on a cron running every 15 minutes, dumping all errors and standard output to a black hole.


#!/bin/bash
# Name: multiUserPermissionsFix
# Mode: 0755

function usage {
echo "USAGE: $0 base_directory";
exit -1;
}

# If we didn't even bother to pass an argument to this script, die.
if ( test "$1" == "" ); then
usage;
fi;

# Set up find correctly.
export IFS=$'\n';

# If this is a valid directory, do the work.
if [ -d "$1" ]; then

# Force a trailing slash - workaround for symlinked directories, etc.
d="$1/";

# Find and fix all file permissions --- but ignore all 'cache' cases.
find . -type f -not -path "*cache*" -exec chmod 0664 '{}' \;

exit 0;

# If it wasn't a valid directory passed to this script, die on an error.
else
echo "That directory does not exist!";
exit -1;
fi;

This script is actually not called directly, but instead by a parent script. It recursively runs through all files and sets the permissions to 0664 (owner read/write, group read/write, world read) so that users within the group can update or delete the files within the directory without requiring administrative intervention.