Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
First off, we have to set a bunch of environment variables. Originally these were set in a separate file accessed from our script. This makes configuration a bit more convenient, but to simplify this demonstration, I included the initialization of the variables in the script.
#!/bin/sh
HOME=/usr/local/pass_aging
The following line of code establishes the number of days that the user's password is valid before the account will be locked. The value could also be set dynamically by pulling the fifth field from the /etc/shadow file if the account has been configured appropriately. However, I have found that accounts on a system often are created by many different people and the fields in the /etc/shadow file are not always filled in correctly to include appropriate account-expiration settings.