commit d109103f1e54aaaa21fe69b6634ff31cc30967bb
parent e22998efbc6a54e3d29ffa3505d6e6527d587525
Author: Jaromil <jaromil@dyne.org>
Date: Mon, 4 Jun 2012 00:11:16 +0200
general fixes for stability and osx
Diffstat:
3 files changed, 91 insertions(+), 39 deletions(-)
diff --git a/build-osx.sh b/build-osx.sh
@@ -99,5 +99,3 @@ copydeps bin/gpg
copydeps bin/pinentry
copydeps bin/lynx
-cp src/jaro build/osx
-
diff --git a/install.sh b/install.sh
@@ -46,7 +46,7 @@ notice "Installing Jaromail in $WORKDIR"
# install the main jaromail script
${=mkdir} ${WORKDIR}/bin
-cp src/jaro ${WORKDIR}/bin
+cp -f src/jaro ${WORKDIR}/bin
# make sure we have a temp and cache dir
${=mkdir} $WORKDIR/tmp $WORKDIR/cache
@@ -244,7 +244,6 @@ for mod in ${lbdb_modules}; do
done
cp src/lbdb/dotlock $WORKDIR/.lbdb/
cp src/lbdb/fetchaddr $WORKDIR/.lbdb/
-cp src/gnome-keyring/jaro-gnome-keyring $WORKDIR/bin/
chmod +x $WORKDIR/.lbdb/*
ln -sf $WORKDIR/.lbdb/lbdb-fetchaddr $WORKDIR/bin/
ln -sf $WORKDIR/.lbdb/lbdbq $WORKDIR/bin/
@@ -293,6 +292,7 @@ act "Check the commandline help for a list of commands: jaro -h"
# OS specific post install rules
case $OS in
GNU)
+ cp src/gnome-keyring/jaro-gnome-keyring $WORKDIR/bin/
;;
MAC)
;;
diff --git a/src/jaro b/src/jaro
@@ -39,16 +39,6 @@ TMPRAM=0
mkdir="`which mkdir` -m 700 -p"
# date stamp
datestamp=`date '+%d%b%y'`
-# temporary directory
-touch /dev/shm/jaromail.test.tmp > /dev/null
-if [ $? = 0 ]; then
- # we can use volatile ram
- rm -f /dev/shm/jaromail.test.tmp
- TMPDIR=/dev/shm/jaromail.$USER.$datestamp
- TMPRAM=1
-else
- TMPDIR=$WORKDIR/tmp
-fi
##########################
@@ -104,9 +94,6 @@ case $(uname) in
error "Running on an unknown operating system, assuming GNU" ;;
esac
-{ test $TMPRAM = 1 } && {
- act "Using temporary directory in volatile RAM" }
-
if [ -z $MAILDIRS ]; then
# check if we are inside the directory
if [ -r jaro/bin/jaro ]; then
@@ -126,8 +113,39 @@ ${=mkdir} $WORKDIR
# make sure the directory is private
chmod 700 $WORKDIR
+
+# temporary directory
+TMPDIR=$WORKDIR/tmp
+case $OS in
+ GNU)
+ touch /dev/shm/jaromail.test.tmp > /dev/null
+ { test $? = 0 } && {
+ # we can use volatile ram
+ rm -f /dev/shm/jaromail.test.tmp
+ TMPDIR=/dev/shm/jaromail.$USER
+ TMPRAM=1
+ }
+ ;;
+ MAC)
+ mount | grep 'JaroTmp' > /dev/null
+ { test $? = 0 } && {
+ # our RAM temp directory is active
+ TMPDIR=/Volumes/JaroTmp/jaromail.$USER
+ TMPRAM=1
+ }
+ ;;
+esac
+
+{ test $TMPRAM = 1 } && {
+ act "Using temporary directory in volatile RAM" }
+
+
# make sure we have a temp and cache dir
${=mkdir} "$TMPDIR"
+{ test $? != 0 } && {
+ error "Cannot create temporary directory: $TMPDIR"
+ return 1 }
+
${=mkdir} "$WORKDIR/cache"
${=mkdir} "$WORKDIR/log"
${=mkdir} "$WORKDIR/certs"
@@ -140,7 +158,7 @@ cleanexit() {
for f in `ls $TMPDIR/ | grep -v '.lock$'`; do
unlink $TMPDIR/$f
done
- { test $TMPRAM = 1 } && { rmdir $TMPDIR }
+# { test $TMPRAM = 1 } && { rmdir $TMPDIR }
unset typeset -h name login host protocol port password auth folders accountopt
}
# make sure tmp is wiped from sensitive data in case of sigINT
@@ -791,18 +809,14 @@ peek() {
switch_identity
case $transport in
- ssl)
- act "using secure connection (SSL)"
- iproto="imaps"
- ;;
- plain)
- act "using clear text connection"
- iproto="imap"
- ;;
+ ssl) act "using secure connection (SSL)"
+ iproto="imaps" ;;
+ plain) act "using clear text connection"
+ iproto="imap" ;;
esac
- sleep 2
# escape at sign in login
ilogin=`echo $login | sed 's/@/\\@/'`
+
ask_password $login $host
{ test $? != 0 } && {
error "Error retrieving password for $login on $host"
@@ -811,10 +825,15 @@ peek() {
newlock $TMPDIR/muttpasswd
cat <<EOF >> $TMPDIR/muttpasswd
set imap_pass = "${password}"
-\`$WORKDIR/bin/dotlock -u $TMPDIR/muttpasswd; echo 'set imap_peek=yes'\`
+# set imap_peek = yes
EOF
unset password
- (sleep 5; unlink $TMPDIR/muttpasswd)&
+ echo "source $TMPDIR/muttpasswd" >> $MUTTDIR/password
+ (sleep 1;
+ cp /dev/null $MUTTDIR/password
+ cp /dev/null $TMPDIR/muttpasswd
+ unlock $TMPDIR/muttpasswd
+ ) &
mutt -F $MUTTDIR/rc -f ${iproto}://${ilogin}@${host}${folder}
return $?
}
@@ -869,31 +888,24 @@ macro index,pager A "<pipe-message>$WORKDIR/bin/jaro -l Whitelist.txt -q forget<
macro index,pager z "<pipe-message>$WORKDIR/bin/jaro -l Blacklist.txt -q learn<enter>" "add sender to blacklist"
macro index,pager Z "<pipe-message>$WORKDIR/bin/jaro -l Blacklist.txt -q forget<enter>" "remove sender from blacklist
-\`test -r $TMPDIR/muttpasswd && echo "source $TMPDIR/muttpasswd"\`
-EOF
-
- if [ -r $MUTTDIR/general ]; then
- echo "# user tweaked configuration" >> $MUTTDIR/rc
- echo "source ${MUTTDIR}/general" >> $MUTTDIR/rc
- fi
-
-cat <<EOF >> $MUTTDIR/rc
# mailboxes in order of priority
source $MUTTDIR/mboxes
# specific configuration files
-# hardcoded path for now (TODO)
source $MUTTDIR/crypto
source $MUTTDIR/colors
source $MUTTDIR/formats
source $MUTTDIR/keybindings
source $MUTTDIR/identity
+source $MUTTDIR/password
source $WORKDIR/Mutt.txt
## end of Jaro Mail generated muttrc
####################################
EOF
+ # this one is empty and sources files in temp when necessary
+ touch $MUTTDIR/password
# just the header, will be completed later in procmail loop
rm -f $MUTTDIR/mboxes
@@ -1194,6 +1206,45 @@ filter() {
echo "${briefing}"
}
+# opens and closes a ramdisk for temporary files
+ramdisk() {
+ case $OS in
+ GNU)
+ # TODO
+ # not so urgent, since usually /dev/shm is mounted and writable
+ ;;
+ MAC)
+ case ${PARAM[1]} in
+ open)
+ mount | grep 'JaroTmp' > /dev/null
+ { test $? = 0 } && {
+ error "A Jaro Mail ramdisk is already open"
+ return 1 }
+ # 2048 is a megabyte here
+ devsize=$((1024*2*10))
+ devname=`hdid -nomount ram://${devsize}`
+ act -n "Mounting 10MB ramdisk: $devname"
+ diskutil eraseVolume HFS+ JaroTmp `basename $devname` > /dev/null
+ { test $? != 0 } && {
+ error "Error initializing ramdisk"
+ hdiutil detach `basename $devname`
+ return 1 }
+ notice "Operation succesful, ramdisk ready on /Volume/JaroTmp"
+ ;;
+ close)
+ devname=`mount | awk '/JaroTmp/ {print $1}'`
+ { test "$devname" = "" } && {
+ error "No ramdisk seems to be open"
+ return 1 }
+ act "Unmounting ramdisk: $devname"
+ diskutil unmount /Volumes/JaroTmp > /dev/null
+ hdiutil detach `basename $devname` > /dev/null
+ notice "Ramdisk succesfully detached"
+ ;;
+ esac
+ ;;
+ esac
+}
######################
usage() {
@@ -1277,6 +1328,7 @@ main()
subcommands_opts[passwd]=""
subcommands_opts[cert]=""
+ subcommands_opts[ramdisk]=""
subcommands_opts[source]=""
# subcommands_opts[mount]=${subcommands_opts[open]}
@@ -1380,6 +1432,8 @@ main()
;;
cert) cert ${PARAM} ;;
+ ramdisk) ramdisk ${PARAM} ;;
+
'source') CLEANEXIT=0; return 0 ;;
__default) func "no command provided"
autostart ${PARAM}