#!/bin/sh -p # # monthly_alias # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 1997 by Dan Harkless, and is released under the # GNU General Public License . # # USAGE: # % monthly_alias # # EXAMPLE: # % monthly_alias dan dan-pop # % tail -1 /etc/aliases # dan_jan97: dan-pop # # DESCRIPTION: # Adds an alias to the /etc/aliases file of the form $1_mmmyy. Mail to that # address will be forwarded to $2. You might set up a cron job to do this at # midnight on the 1st of every month. # # These monthly aliases are useful when posting to Usenet expecting replies. # People can email you without having to go through any anti-SPAM contortions, # yet you can stave off the flow of SPAM at the end of the month, or once # you've got all the replies you need. # # On normal systems, this script will have to be setuid root to be able to # write to /etc/aliases. On Solaris, the "-p" parameter to /bin/sh preserves # the effective uid and gid rather than resetting them to the real uid and gid # values. Before installing monthly_alias, make sure that the /bin/sh on your # system does not allow the caller to craft $1 or $2 to be able to execute # arbitrary commands as root by embedding " and ; characters (I should really # re-write this as a perl script with taint checks). # # DATE MODIFICATION # ========== ================================================================== # 1997-01-07 Original. # Make sure 2 parameters were passed. if [ $# != 2 ]; then progname=monthly_alias # can't use $0 in a setuid script on Solaris echo "usage: $progname " exit 1 fi # Get the date in mmmyy format. mmmyy=`date +%h%y | tr "[A-Z]" "[a-z]"` # Add an alias to /etc/aliases. echo "$1_$mmmyy: $2" >> /etc/aliases