commit 7c1ab24c50daabf288ead557e0d43df99e2e571e
parent 9263d885c9438d1d4edb8ade7efaa568d5a69afc
Author: Jaromil <jaromil@dyne.org>
Date: Tue, 1 Jul 2014 12:10:20 +0200
minor fixes to locking and send
Diffstat:
3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/src/zlibs/email b/src/zlibs/email
@@ -379,8 +379,8 @@ BEGIN { head=1 }
'
tmp="$TMPDIR/msmtp.$host.$datestamp.$RANDOM"
- newlock $tmp
- cat <<EOF > $tmp
+ newlock "$tmp"
+ cat <<EOF > "$tmp"
account default
from ${email}
user ${login}
@@ -393,9 +393,13 @@ logfile "${MAILDIRS}/logs/msmtp.log"
auth ${auth}
password ${password}
EOF
- msmtp -C $tmp -t < "${qbody}"
+ tsize=`stat -c '%s' "$qbody"`
+ act "sending $tsize bytes over the network ..."
+ msmtp -C "$tmp" -t < "${qbody}"
res=$?
- unlink $tmp
+ # unlink "$tmp"
+ unlock "$tmp"
+ rm -f "$tmp"
fi
# evaluate results
@@ -463,8 +467,8 @@ peek() {
unset password all; return 1
}
tmp="$TMPDIR/$imap.peek.$RANDOM"
- newlock $tmp
- cat <<EOF >> $tmp
+ newlock "$tmp"
+ cat <<EOF >> "$tmp"
set imap_pass = "${password}"
# set imap_peek = yes
EOF
@@ -478,7 +482,7 @@ set sort=reverse-date-received
EOF
(sleep 1;
cp /dev/null "$TMPDIR/muttpass"
- unlink $tmp # secure delete in ram
+ unlink "$tmp" # secure delete in ram
) &
${=mutt} -F $MUTTDIR/rc -f ${iproto}://${ilogin}@${imap}${folder}
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -238,6 +238,7 @@ filter_maildir() {
else
error "Error filtering to maildir ${filter_from[$exp]}"
error "File: $m"
+ continue
fi
fi
done
@@ -267,6 +268,7 @@ filter_maildir() {
else
error "Error filtering to maildir ${filter_to[$exp]}"
error "File: $m"
+ continue
fi
fi
done
diff --git a/src/zlibs/locking b/src/zlibs/locking
@@ -32,28 +32,32 @@ command -v dotlock > /dev/null
lock() {
func "$dotlock: $1"
- ${=dotlock} ${1}
- case $? in
+ ${=dotlock} "$1"
+ res=$?
+ case $res in
1) error "Cannot lock non existing file: $1"
return 1 ;;
3) error "Locked file in use: $1"
- pidcheck ${1}
+ pidcheck "$1"
return 3 ;;
- 5) error "Impossible to lock: $1"
+ 5) error "Lock is impossible on: $1"
return 5 ;;
# success
- 0) echo "$$" > ${1}.pid
+ 0) print "$$" > "$1.pid"
return 0 ;;
+
+ *) error "Unknown error locking: $res"
+ return 1 ;;
esac
}
newlock() { # lock file, create if not existing
func "creating locked file: $1"
- touch $1
- chmod 600 $1
- lock $1
+ touch "$1"
+ chmod 600 "$1"
+ lock "$1"
}
pidcheck() { # check if lock belongs to us
@@ -76,7 +80,7 @@ pidcheck() { # check if lock belongs to us
sleep 1; continue
else
act "Owner (${lockpid}) not running, taking over the lock"
- rm -f ${1}.pid; print "$$" > ${1}.pid
+ rm -f "${1}.pid"; print "$$" > "${1}.pid"
_prun=0
fi
done
@@ -88,7 +92,7 @@ pidcheck() { # check if lock belongs to us
else # pid file doesn't exists
func "no pid file found for: $1"
func "we will take it over"
- print "$$" > ${1}.pid
+ print "$$" > "${1}.pid"
fi
return 0
}