safecat hardlinks Re: [nycbug-talk] dying for details

George Georgalis george
Thu May 19 17:39:14 EDT 2005


On Thu, May 19, 2005 at 05:06:09PM -0400, George Georgalis wrote:
>
>How do you deposit a mail into two separate maildirs using one 'file'
>and two hardlinks? ie, use safecat to put it in a maildir, and hardlink
>it to another maildir?
>

...well this is a little crude, but should be acceptable, I don't
_expect_ name collision to actually occur anyway...

# do spamd check
score=`spamc -x -c <"$tmp"` # score it with spamd
exitstat=$?
case $exitstat in
1) # spam 
        sipd="$scq/IP/`echo $TCPREMOTEIP | sed 's|\.|/|g'`/`hostname`" # an IP/host name
        mkdir -p $sipd/{new,cur,tmp} # make an IP/host named maildir
        printf "$TCPREMOTEIP\t`date +%Y.%m.%d.%H%M.%S`\t`date -R`\n" >>$sipd/date # keep track
        # keep a copy for manual checks and keep a copy for statistics
        ln "$tmp" "$sipd/new/" && ln "$tmp" "$scd/new/" \
                || { rm -f "$tmp" "$sipd/new/$tmp" "$scd/new/$tmp" ; exit 71 ;} # temporarily refuse on name collision
        rm "$tmp"
        exit 31
;;

...better ideas?

// George


-- 
George Georgalis, systems architect, administrator Linux BSD IXOYE
http://galis.org/george/ cell:646-331-2027 mailto:george at galis.org




More information about the talk mailing list