[Ilugc] Auto e-mail greeter program

  • From: binand@xxxxxxxxx (Binand Sethumadhavan)
  • Date: Mon Oct 16 16:09:27 2006

On 16/10/06, Girish Venkatachalam <girishvenkatachalam@xxxxxxxxx> wrote:

2. Your aeg script has a race condition; on multiuser systems with
malicious users, this can lead to arbitrary files owned by the user
running AEG to be wiped out. mktemp(1)  is the safe way of creating
temporary files.
Oh yes, I know mktemp but forgot. I could put that change in but I am not too 
particular.

Yep, this is the single biggest argument used against FOSS. The
developer is usually not particular about users' requirements or
security considerations. Developer's response is in most cases, "works
for me". I'd imagine 60% of the patches Redhat includes are about
fixing things like race conditions etc. because the developer could
not be bothered to fix silly bugs like these.

That is actually meant to solve the confusion between mm/dd and dd/mm formats 
for dates. You can easily look at an entry and identify.

But you are asking your user to enter the same information twice, in
slightly different formats. Why don't you use one format and convert
to the other if need be? How would you like if a program asked you,
"Enter IP address in x.y.z.t format" and in the next window, asks you
"Enter same IP address as a 32-bit integer"?

4. All your lines which goes "| cut -d '|' ..." can be replaced far
cleaner with the bash inbuilt command "set".
How? Can you give a code sample? I guess I get what you are saying but some 
prodding will help. :-)

Well, given this $line:

Amma and appa |dad@xxxxxxxxx,mom@xxxxxxxxx|mday|Oct 5|10/05

And this snippet:

declare -x oldifs="$IFS"; declare -x IFS="|"; set -- $line; declare -x
IFS="$oldifs"

You can then have:

appellation="$1"
mailids="$2"
event="$3"
event_date="$5"

and you don't have a single fork/exec combo for external programs in
your script for this (and most of the code above is concerned about
restoring IFS, which you can ignore inside a shell script under
certain conditions).

In addition, this messy bit:

        TODAY=`date +%D | cut -d/ -f1-2`
        event_date=`echo ${line} | cut -d'|' -f5 `
        if [ "${TODAY}" = "${event_date}" ];then
                send_email
        fi

is far cleaner if you go as (with event_date coming from your FOURTH
field ("Oct 16"), not the fifth):

if [ `date +%j` -eq `date +%j -d $event_date` ]; then
    send_mail
fi

Binand

Other related posts: