Blog
SSH Tutorials
Submitted by Aaron Longwell on Thu, 2005-07-07 15:59.The best SSH tutorial I've seen to date is hosted by Sun Micrososystems. It covers public/private key authentication, using SSH with cron, and various other topics.
Drupal for Corporate Sites
Submitted by Aaron Longwell on Wed, 2005-07-06 10:34.I came across an interesting discussion of strategies for using Drupal as a framework for a corporate web site. I've used some of these same techniques on this site.
http://contaire.com/drupalsite
Nested Data Binding Customization in Spring
Submitted by Aaron Longwell on Fri, 2005-07-01 13:45.As covered elsewhere, Spring's MVC databinding can be customized using the ServletRequestDataBinder's registerCustomEditor methods. In most cases, you specify just the data type or a combination of data type and field name (for field-specific data binding rules).
I ran into trouble trying to customize the data binding of a nested Collection component's field. It turns out it's just as easy, just not very intuitive.
To register a custom PropertyEditor for a nested field, you use the same method as a non-nested field, but you use a special syntax for the field name. The following is a hypothetical example binding an Order object. The Order contains a field called customer, which is of type Person. The Person class has its own field birthDate.
Error 413, Request Entity Too Large
Submitted by Aaron Longwell on Fri, 2005-07-01 08:54.I ran into a problem with a Drupal site today. Any file upload over about 500k was resulting in a "Document Contains No Data" error on Firefox, and an Error 413 "Request Entity Too Large" error on Internet Explorer. Because very small file uploads were working fine, I assumed the problem was file size related.
First I edited /etc/php.ini.
post_max_size = 25M
upload_max_filesize = 20M
Those values showed successfully in phpinfo() calls, but I was still receiving the Request Entity Too Large error. I read somewhere that the apache LimitRequestBody directive may be the culprit. As it turns out, my RedHat Linux distribution sets up a low LimitRequestBody by default. It is increased by editing the /etc/httpd/conf.d/php.conf file.
Cron Quick HOWTO
Submitted by Aaron Longwell on Wed, 2005-06-29 11:39.Cron is a system automation/task scheduler utility. Tasks are run by the cron daemon, which must be enabled and running for cron jobs to be performed. Jobs missed while crond was not running or while the computer was turned off will not be done at the next opportunity.
It maintains a cron table of tasks and their schedules for each user. The crontab command is used to edit the table.
crontab -e
The crontab file is a space-delimited text data file. The columns are reserved for the following data values.
- MINUTE Identifies the minute at which the task should run (0-59)
- HOUR Identifies the hour at which the task should run (0-23).
- DAY OF MONTH Identifies the day of the month on which the task should run (1-31).
- MONTH Identifies the number of the month on which the task should run (1-12 OR jan,feb,mar,etc).
- DAY OF WEEK Identifies the day of the week on which the task should run (0-6 OR sun,mon,tue,etc).
- COMMAND The command line for the task that is to be run.
Cron also has some shortcuts defined for commonly used schedules. These are:
- @reboot - Occurs on every bootup of the machine.
- @yearly - Occurs once every year (0 0 1 1 *).
- @annually - Occurs once every year (0 0 1 1 *).
- @monthly - Occurs on the first day of every month (0 0 1 * *).
- @weekly - Occurs at the beginning of each week (0 0 * * 0).
- @daily - Occurs at midnight every night (0 0 * * *).
- @midnight - Occurs at midnight every night (0 0 * * *).
- @hourly - Occurs at the start of every hour (0 * * * *).
Cron also allows some more complicated formulas in its data values. Here are the general forms:
- asterisk (*) - Indicates that the task should be run on every occurence of the data field in question (i.e. every minute, hour, day of month, month, day of week, etc).
- comma (,) - Indicates the task should be run on multiple minutes, hours, months, etc.
- dash (-) - Indicates the task should be run on each in a range of minutes, hours, months, etc.
- slash (/) - Indicates the task should be run every nth minute, hour, month, etc. (i.e. Every 5 minutes = */5, Each third of the workday = 8-5/3).
Installing Cron on Cygwin
Submitted by Aaron Longwell on Tue, 2005-06-28 17:40.To set up cron on Cygwin, first install the cron package with the Cygwin installer. Then install cron as a service.
cygrunsrv -I cron -p /usr/sbin/cron -a D
After the service is installed, it can be started.
net start cron
By default, crontab is set up to use vi as its editor. I prefer nano, so I change the EDITOR environment variable to let crontab aware of my preference. I edit $HOME/.bash_profile and add the following lines.
EDITOR=nano
export EDITOR
I then re-read the BASH profile.
Using SSH Public Keys with Cron on Cygwin
Submitted by Aaron Longwell on Tue, 2005-06-28 17:16.I recently became dissatisfied with the shareware backup application I've been using for my Windows workstations. I've decided to try using rsync and some Cygwin shell scripting to accomplish the task. I like to be as secure as possible, even when unnecessary. Developing insecure solutions just makes it easier to deploy them in production environments. This penchant for security resulted in an SSH-based solution that brings several challenges. Here's how I worked them out.
First, I didn't want to use the rsync daemon applications, as it requires some additional setup and is not as secure as SSH. I use SSH servers over Cygwin for several other purposes.
Windows SSH Server Daemon with Cygwin
Submitted by Aaron Longwell on Tue, 2005-06-28 09:16.I've found Cygwin to be the best method for setting up an SSH server on Windows. This is partly due to the need for Cygwin for other purposes (rsync, cron, shell scripts, etc).
To set it up, first install Cygwin, including the OpenSSH package. Then run the ssh host setup command.
ssh-host-config
This command should result in several prompts. Answer yes, yes, yes. To each question. Then use ntsec tty for the CYGWIN= variable.
After the installation script completes, you can start the sshd daemon with the Windows net command.
Sorting Password files by UID
Submitted by Aaron Longwell on Tue, 2005-06-28 07:06.When several clients are hosted on the same server, it's often helpful to know the UID and GID of client users. These scripts sort the password and group files to ease visual searches.
sort -t : -k 3,4 -g /etc/passwd
This simple script outputs the full contents of the /etc/passwd file, sorted by the 3rd field (the UID field). The -t option identifies the field separator. In this case we use the colon (:). The -k 3,4 option determines the order in which fields will be compared for the sort. We're sorting by the 3rd field (UID) followed by the 4th field (GID). Lastly, the -g option means we want the sort to occur numerically. This makes the number 56 appear after 9. Using the default (ASCII) sort places 56 before 9 (5 comes before 9).
CSS Font Size Strategy
Submitted by Aaron Longwell on Thu, 2005-06-16 11:26.I prefer a font size strategy based on percentage modifiers. This strategy works pretty reliably across platforms, and it preserves the functionality of browser font resizing (unlike a pixel-based method).
In a base.css stylesheet, I define the following rules:
body {
font-family: "Trebuchet MS", Helvetica, Arial, sans-serif;
font-size: 100.01%;
}
p, table {
font-size: 75.01%;
}
