From 36565e2ef4894c996a29d18f49aae2cfc6fd0c61 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Sun, 16 Jan 2011 23:43:45 +0100 Subject: [PATCH] dropped c++ dependency plus various fixes --- configure.ac | 1 - src/Makefile.am | 14 ++++++++----- src/tomb | 27 +++++++++++++++----------- src/{tomb-notify.cpp => tomb-notify.c} | 0 src/tomb-open | 12 +++--------- src/{tomb-status.cpp => tomb-status.c} | 9 +++++---- 6 files changed, 33 insertions(+), 30 deletions(-) rename src/{tomb-notify.cpp => tomb-notify.c} (100%) rename src/{tomb-status.cpp => tomb-status.c} (98%) diff --git a/configure.ac b/configure.ac index d357044..6c58dc7 100644 --- a/configure.ac +++ b/configure.ac @@ -64,7 +64,6 @@ AC_CONFIG_SRCDIR([src/tomb]) dnl Checks for reguired programs. AC_PROG_CC -AC_PROG_CXX AC_PROG_INSTALL AC_CHECK_PROG(have_zsh,zsh,yes,no) diff --git a/src/Makefile.am b/src/Makefile.am index f6086c3..bb64f55 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,15 +1,19 @@ bin_SCRIPTS = tomb tomb-open -bin_PROGRAMS = tomb-status tomb-notify +bin_PROGRAMS = tomb-status tomb-notify tomb-askpass -tomb_status_SOURCES = tomb-status.cpp +tomb_status_SOURCES = tomb-status.c tomb_status_LDADD = @GTK2_LIBS@ @NOTIFY_LIBS@ -tomb_status_CXXFLAGS = @GTK2_CFLAGS@ @NOTIFY_CFLAGS@ +tomb_status_CFLAGS = @GTK2_CFLAGS@ @NOTIFY_CFLAGS@ -tomb_notify_SOURCES = tomb-notify.cpp +tomb_notify_SOURCES = tomb-notify.c tomb_notify_LDADD = @NOTIFY_LIBS@ -tomb_notify_CXXFLAGS = @NOTIFY_CFLAGS@ +tomb_notify_CFLAGS = @NOTIFY_CFLAGS@ + +tomb_askpass_SOURCES = tomb-askpass.c +tomb_askpass_LDADD = @GTK2_LIBS@ +tomb_askpass_CFLAGS = @GTK2_CFLAGS@ EXTRA_DIST = monmort.xpm pixmapdir = $(prefix)/share/pixmaps diff --git a/src/tomb b/src/tomb index b669f92..e44a579 100755 --- a/src/tomb +++ b/src/tomb @@ -43,9 +43,9 @@ fi # which wipe command to use which wipe > /dev/null if [ $? = 0 ]; then - WIPE="wipe -f -s -q" + WIPE=(wipe -f -s -q) else - WIPE="rm -f" + WIPE=(rm -f) fi # usb auto detect using dmesg @@ -96,14 +96,19 @@ ask_usbkey() { # user interface (just to ask the password) ask_password() { - xhost 2>/dev/null + exec_as_user xhost 2>/dev/null if [ $? = 0 ]; then # we have access to the X display - if [ -x /usr/bin/ssh-askpass ]; then # debian has this - export scolopendro="`ssh-askpass "Tomb: provide the password to unlock"`" + exec_as_user which tomb-askpass + if [ $? = 0 ]; then + keyname=`echo $enc_key | cut -d. -f1` + export scolopendro="`exec_as_user tomb-askpass $keyname`" + return + elif [ -x /usr/bin/ssh-askpass ]; then # debian has this + export scolopendro="`exec_as_user ssh-askpass "Tomb: provide the password to unlock"`" return fi - + else # we'll collect the password from commandline act "Tomb: provide the password to unlock" @@ -122,8 +127,7 @@ ask_password() { # drop privileges exec_as_user() { func "executing as user '$SUDO_USER': ${(f)@}" - sudo -u $SUDO_USER ${@} & - disown + sudo -u $SUDO_USER ${@} } @@ -288,7 +292,7 @@ create_tomb() { cryptsetup --key-file ${keytmp} --cipher aes luksOpen ${nstloop} tomb.tmp - ${WIPE} ${keytmp} + ${WIPE[@]} ${keytmp} notice "Your tomb is ready on ${FILE} and secured with key ${FILE}.gpg" act "Would you like to save the key on an external usb device?" @@ -306,7 +310,7 @@ create_tomb() { mkdir -p ${usbkey_mount}/.tomb cp -v ${FILE}.gpg ${usbkey_mount}/.tomb/ chmod -R go-rwx ${usbkey_mount}/.tomb - rm -rf ${FILE}.gpg + ${WIPE[@]} ${FILE}.gpg fi fi # cryptsetup luksDump ${nstloop} @@ -418,7 +422,8 @@ mount_tomb() { mount -o rw,noatime,nodev /dev/mapper/${mapper} ${MOUNT} notice "encrypted storage $FILE succesfully mounted on $MOUNT" - exec_as_user tomb-status ${mapper} ${FILE} ${MOUNT} + exec_as_user tomb-status ${mapper} ${FILE} ${MOUNT} & + disown } umount_tomb() { diff --git a/src/tomb-notify.cpp b/src/tomb-notify.c similarity index 100% rename from src/tomb-notify.cpp rename to src/tomb-notify.c diff --git a/src/tomb-open b/src/tomb-open index 8adcb8c..c7cb7da 100755 --- a/src/tomb-open +++ b/src/tomb-open @@ -22,13 +22,6 @@ # startup wrapper to open tombs -explore() { - which ${1} > /dev/null - if [ $? = 0 ]; then - ${1} ${2} - exit 0 - fi -} try() { which ${1} > /dev/null @@ -102,7 +95,7 @@ Create a new Tomb the computer you are using. If you will, I'll be your Crypto Undertaker. - Do you want to proceed, Master? (yes/no)" + Do you want to proceed, Master? (y/n)" EOF echo -n "> " read -q @@ -122,7 +115,7 @@ echo " You have commanded the creation of this Tomb:" echo " $filename ( $size MBytes )"; echo echo " Please confirm if you want to proceed now," -echo " digging will take quite some time! (yes/no)" +echo " digging will take quite some time! (y/n)" echo -n "> " read -q if [ $? != 0 ]; then @@ -141,3 +134,4 @@ if ! [ -r /usr/share/applications/tomb.desktop ]; then sudo tomb install fi +exit 0 diff --git a/src/tomb-status.cpp b/src/tomb-status.c similarity index 98% rename from src/tomb-status.cpp rename to src/tomb-status.c index 8bb8b5f..94d5edf 100644 --- a/src/tomb-status.cpp +++ b/src/tomb-status.c @@ -56,7 +56,7 @@ gboolean cb_about(GtkWidget *w, GdkEvent *e); int main(int argc, char **argv) { GtkWidget *item_close, *item_view, *item_about; gint menu_x, menu_y; - gboolean push_in = true; + gboolean push_in = TRUE; char tomb_file[512]; char tooltip[256]; @@ -155,13 +155,13 @@ gboolean cb_view(GtkWidget *w, GdkEvent *e) { pid_t cpid = fork(); if (cpid == -1) { fprintf(stderr,"error: problem forking process\n"); - return false; + return FALSE; } if (cpid == 0) { // Child execlp("tomb-open", "tomb-open", mountpoint ,(char*)NULL); exit(1); } - return true; + return TRUE; } gboolean cb_close(GtkWidget *w, GdkEvent *e) { @@ -169,7 +169,7 @@ gboolean cb_close(GtkWidget *w, GdkEvent *e) { int res; if (cpid == -1) { fprintf(stderr,"error: problem forking process\n"); - return false; + return FALSE; } if (cpid == 0) { // Child execlp("tomb","tomb","-S","umount",mapper,(char*)NULL); @@ -181,6 +181,7 @@ gboolean cb_close(GtkWidget *w, GdkEvent *e) { notify_uninit(); exit(0); } + return TRUE; } // callbacks right click