diff -r 60bc07f3f415 -r ee0797f46473 usr/share/usbmount/async_usbmount --- a/usr/share/usbmount/async_usbmount Thu Feb 27 17:12:59 2014 +0100 +++ b/usr/share/usbmount/async_usbmount Tue Nov 04 14:58:00 2014 +0100 @@ -38,6 +38,14 @@ return 1 } +getRemoteIp () +{ + ip_address=$(ifconfig eth0 | grep "inet " | awk '{ print $2 }' | cut -d ":" -f 2) + ip_netmask=$(ifconfig eth0 | grep "inet " | awk '{ print $4 }' | cut -d ":" -f 2) + remote_ip=$(ipcalc $ip_address/$ip_netmask | grep HostMin | awk '{ print $2}') + + echo $remote_ip +} ###################################################################### # Main program @@ -72,6 +80,11 @@ log debug "creating /var/run/usbmount directory" fi +if [ ! -e /tmp/usbmount ]; then + mkdir -p /tmp/usbmount + log debug "creating /tmp/usbmount directory" +fi + umask 022 if [ "$1" = add ]; then @@ -94,24 +107,29 @@ then log info "blkid -p $DEVNAME has retured with $BLKID_RESULT" log info "Stick is maybe encrypted. Try decrypt" - wget -q -T 3 -t 1 -O /dev/null http://192.168.56.1:8090/password?text=Please+send+me+the+password + wget -q -T 3 -t 1 -O /dev/null http://$(getRemoteIp):8090/password?text=Please+enter+the+password if [ "$?" != "0" ] then - log err "Connection to http://192.168.56.1:8090/password?text=Please+send+me+the+password failed" + log err "Connection to \"http://$(getRemoteIp):8090/password?text=Please+enter+the+password\" failed" exit 1 fi log info "Password notification sended, wait for response" - /usr/bin/osecvm-password-receiver.py eth0 58080 $DEVNAME /media/usb0 + /usr/bin/encryptionprovider.py -m eth0 58080 $DEVNAME /media/usb0 if [ "$?" != "0" ] then log err "Stick removed. exit" exit 1 fi - mkdir -p "/var/run/usbmount/encrypted" - /usr/bin/osecfs /etc/osecfs/osecfs_usb.cfg "/var/run/usbmount/encrypted" rw + chattr -i "/tmp/usbmount" + mkdir -p "/tmp/usbmount/encrypted" + /usr/bin/osecfs /etc/osecfs/osecfs_usb.cfg "/tmp/usbmount/encrypted" rw log info "Encrypted stick mounted" + + #run_initlistener.sh $DEVNAME & + encryptionprovider.py -i eth0 58081 "$DEVNAME" /media/usb0 & + chattr +i "/tmp/usbmount" exit 0 fi set -e @@ -212,15 +230,16 @@ # A block or partition device has been removed. # Test if it is mounted. - for device in $(/usr/bin/truecrypt -l | awk '{ print $2}') + for device in $(/usr/bin/encryptionprovider.py -g) do if [ "$DEVNAME" = "$device" ] then - log info "encrypted device was removed" - umount "/var/run/usbmount/encrypted" - rmdir "/var/run/usbmount/encrypted" - log info "/usr/bin/truecrypt -d $DEVNAME" - /usr/bin/truecrypt -d "$DEVNAME" + log info "umout encrypted device" + chattr -i "/tmp/usbmount" + umount "/tmp/usbmount/encrypted" + rmdir "/tmp/usbmount/encrypted" + log info "/usr/bin/encryptionprovider.py -u $DEVNAME" + /usr/bin/encryptionprovider.py -u "$DEVNAME" log info "everything done" fi done