tomb

the crypto undertaker
git clone git://parazyd.org/tomb.git
Log | Files | Refs | README | LICENSE

commit c00a1721c881860626b51fd1b11357395f3fa7e4
parent 626f6ea78142f233038784d91a3a8b2337c12714
Author: Jaromil <jaromil@dyne.org>
Date:   Wed, 12 Jan 2011 17:02:19 +0100

desktop installation and mimetypes
and more updates

Diffstat:
Mconfigure.ac | 14++++++++++++--
Msrc/Makefile.am | 10+++++-----
Msrc/tomb | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Dsrc/tomb-gtk.cpp | 99-------------------------------------------------------------------------------
Msrc/tomb-notify.cpp | 2--
Asrc/tomb-open | 13+++++++++++++
Asrc/tomb-status.cpp | 179+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 312 insertions(+), 116 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -4,14 +4,14 @@ dnl ============================================================== AC_PREREQ([2.60]) -AC_INIT([Tomb],[0.8.0],[jaromil@dyne.org],[tomb]) +AC_INIT([Tomb],[0.9.0],[jaromil@dyne.org],[Tomb]) AC_CONFIG_MACRO_DIR([m4]) AC_CANONICAL_HOST dnl backwards compatibility for autoconf >= 2.64 dnl PACKAGE_URL should be the fifth argument of AC_INIT -m4_define([AC_PACKAGE_URL], [http://crypto.dyne.org]) +m4_define([AC_PACKAGE_URL], [http://tomb.dyne.org]) AC_DEFINE(PACKAGE_URL, "AC_PACKAGE_URL", [Package URL]) AC_SUBST(PACKAGE_URL, AC_PACKAGE_URL) @@ -69,6 +69,10 @@ AC_PROG_INSTALL AC_CHECK_PROG(have_zsh,zsh,yes,no) AC_CHECK_PROG(have_cryptsetup,cryptsetup,yes,no) +AC_CHECK_PROG(have_wipe,wipe,yes,no) +AC_CHECK_PROG(have_dcfldd,dcfldd,yes,no) +AC_CHECK_PROG(have_gksu,gksu,yes,no) +AC_CHECK_PROG(have_sudo,gksu,yes,no) PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.16, :, AC_MSG_ERROR([*** Gtk+2 >=2.16 development files not found!])) @@ -80,6 +84,12 @@ PKG_CHECK_MODULES(NOTIFY, libnotify, :, AC_SUBST([NOTIFY_CFLAGS]) AC_SUBST([NOTIFY_LIBS]) +PACKAGE_DATA_DIR='${prefix}/share/tomb' +AC_SUBST(PACKAGE_DATA_DIR) +# mime TODO see http://www.freedesktop.org/wiki/Specifications/AddingMIMETutor +XDG_DATA_DIR='${prefix}/share/mime/packages' +AC_SUBST(XDG_DATA_DIR) + dnl alphabetic order on dir/subdir, but Makefile sorts before everything AC_CONFIG_FILES([ Makefile diff --git a/src/Makefile.am b/src/Makefile.am @@ -1,11 +1,11 @@ -bin_SCRIPTS = tomb +bin_SCRIPTS = tomb tomb-open -bin_PROGRAMS = tomb-gtk tomb-notify +bin_PROGRAMS = tomb-status tomb-notify -tomb_gtk_SOURCES = tomb-gtk.cpp -tomb_gtk_LDADD = @GTK2_LIBS@ @NOTIFY_LIBS@ -tomb_gtk_CXXFLAGS = @GTK2_CFLAGS@ @NOTIFY_CFLAGS@ +tomb_status_SOURCES = tomb-status.cpp +tomb_status_LDADD = @GTK2_LIBS@ @NOTIFY_LIBS@ +tomb_status_CXXFLAGS = @GTK2_CFLAGS@ @NOTIFY_CFLAGS@ tomb_notify_SOURCES = tomb-notify.cpp tomb_notify_LDADD = @NOTIFY_LIBS@ diff --git a/src/tomb b/src/tomb @@ -55,10 +55,11 @@ else WIPE="rm -f" fi -# usb auto detect +# usb auto detect using dmesg # tested on ubuntu 10.04 - please test and patch on other systems if you can ask_usbkey() { notice "looking for key $1 on usb" + exec_as_user tomb-notify "Tomb needs a key." "Plug your usb key in the computer to open $1" echo -n " . please insert your usb key " plugged=false @@ -83,7 +84,7 @@ ask_usbkey() { # get the first partition usbpart=`dmesg |tail -n 8 | grep ' sd.:' |cut -d: -f2 |tr -d ' '` - # what that it is mounted + # wait that is mounted mounted=false while [ "$mounted" != "true" ]; do cat /proc/mounts | tail -n 2 | grep -q $usbpart @@ -336,10 +337,10 @@ mount_tomb() { notice "mounting $FILE on mountpoint $MOUNT" if [ -z $MOUNT ]; then - error "you need to specify a MOUNTPOINT for the mount command" - exit 0 - fi - if ! [ -x $MOUNT ]; then + act "mountpoint not specified, using default: /media/$FILE" + MOUNT=/media/${FILE} + mkdir -p $MOUNT + elif ! [ -x $MOUNT ]; then error "mountpoint $MOUNT doesn't exist" exit 0 fi @@ -413,7 +414,7 @@ mount_tomb() { notice "encrypted storage $FILE succesfully mounted on $MOUNT" if [ $DISPLAY ]; then - exec_as_user tomb-gtk ${FILE} ${MOUNT} + exec_as_user tomb-status ${FILE} ${MOUNT} fi } @@ -488,16 +489,110 @@ umount_tomb() { exec_as_user tomb-notify "Tomb closed:" "${FILE} Rest In Peace." } + +# install mime-types, bells and whistles for the desktop +# see http://developers.sun.com/solaris/articles/integrating_gnome.html +# and freedesktop specs +install() { + notice "Installing Tomb on your desktop" + + act "updating mimetypes..." + cat <<EOF > /tmp/dyne-tomb.xml +<?xml version="1.0"?> +<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> + <mime-type type="application/x-tomb-volume"> + <comment>Tomb encrypted volume</comment> + <glob pattern="*.tomb"/> + </mime-type> + <mime-type type="application/x-tomb-key"> + <comment>Tomb crypto key</comment> + <glob pattern="*.tomb.gpg"/> + </mime-type> +</mime-info> +EOF + xdg-mime install /tmp/dyne-tomb.xml + xdg-icon-resource install --context mimetypes --size 32 monmort.xpm monmort + xdg-icon-resource install --size 32 monmort.xpm dyne-monmort + + rm /tmp/dyne-tomb.xml + + act "updating desktop..." + cat <<EOF > /usr/share/applications/tomb.desktop +[Desktop Entry] +Version=1.0 +Type=Application +Name=Tomb crypto undertaker +GenericName=Crypto undertaker +Comment=Keep your bones safe +Exec=tomb-open %U +TryExec=tomb-open +Icon=monmort.xpm +Terminal=true +Categories=Utility;Security;Archiving;Filesystem; +MimeType=application/x-tomb-volume; +EOF + update-desktop-database + + act "updating menus..." + cat <<EOF > /etc/menu/tomb +?package(tomb):command="tomb" icon="/usr/share/pixmaps/monmort.xpm" needs="cryptsetup" \ + section="Applications/Accessories" title="Tomb" hints="Crypto" \ + hotkey="Tomb" +EOF + update-menus + + act "updating mime info..." + cat <<EOF > /usr/share/mime-info/tomb.keys +# actions for encrypted tomb storage +application/x-tomb-volume: + open=tomb-open %f + view=tomb-open %f + icon-filename=monmort.xpm + short_list_application_ids_for_novice_user_level=tomb +EOF + cat <<EOF > /usr/share/mime-info/tomb.mime +# mime type for encrypted tomb storage +application/x-tomb-volume + ext: tomb + +application/x-tomb-key + ext: tomb.gpg +EOF + cat <<EOF > /usr/lib/mime/packages/tomb +application/x-tomb-volume; tomb '%s'; needsterminal; priority=8 +EOF + update-mime + + act "updating application entry..." + + cat <<EOF > /usr/share/application-registry/tomb.applications +tomb + command=tomb-open + name=Tomb - Crypto Undertaker + can_open_multiple_files=false + expects_uris=false + requires_terminal=true + mime-types=application/x-tomb-volume,application/x-tomb-key +EOF + +} case "$CMD" in create) create_tomb ;; - format) format_tomb ;; + mount) mount_tomb ;; open) mount_tomb ;; + umount) umount_tomb ;; unmount) umount_tomb ;; close) umount_tomb ;; + + install) install ;; + + status) tomb-status ;; + notify) tomb-notify ;; + *) error "command \"$CMD\" not recognized" act "try -h for help" ;; diff --git a/src/tomb-gtk.cpp b/src/tomb-gtk.cpp @@ -1,99 +0,0 @@ -/* Tomb - encrypted storage undertaker - * - * (c) Copyright 2007-2011 Denis Roio <jaromil@dyne.org> - * - * This source code is free software; you can redistribute it and/or - * modify it under the terms of the GNU Public License as published - * by the Free Software Foundation; either version 3 of the License, - * or (at your option) any later version. - * - * This source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * Please refer to the GNU Public License for more details. - * - * You should have received a copy of the GNU Public License along with - * this source code; if not, write to: - * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include <gtk/gtk.h> -#include <libnotify/notify.h> - -/* The Tomb icon is an artwork by Jordi aka MonMort - a nomadic graffiti artist from Barcelona */ -#include <monmort.xpm> - -GtkStatusIcon *status_tomb; -GtkMenu *menu_tomb; - -NotifyNotification *notice; -GError *error; - -// forward declaration of callbacks -gboolean left_click(GtkWidget *w, GdkEvent *e); -gboolean cb_close(GtkWidget *w, GdkEvent *e); - - -int main(int argc, char **argv) { - GObject *tray; - GdkPixbuf *pb_monmort; - GtkWidget *menu_close; - gint menu_x, menu_y; - gboolean push_in = true; - - char tomb_file[512]; - - gtk_set_locale(); - gtk_init(&argc, &argv); - - // libnotify - notify_init(PACKAGE); - - // set and show the status icon - pb_monmort = gdk_pixbuf_new_from_xpm_data(monmort); - status_tomb = gtk_status_icon_new_from_pixbuf(pb_monmort); - // gtk_status_icon_set_name(status_tomb, "tomb"); - gtk_status_icon_set_title(status_tomb, "Tomb"); - gtk_status_icon_set_tooltip_text (status_tomb, "Tomb - crypto undertaker"); - - // gtk_status_icon_set_blinking(status_tomb, true); - menu_tomb = (GtkMenu*) gtk_menu_new(); - - menu_close = gtk_menu_item_new_with_label("Close"); - gtk_menu_attach(menu_tomb, menu_close, 0, 1, 0, 1); - g_signal_connect_swapped(menu_close, "activate", G_CALLBACK(cb_close), NULL); - gtk_widget_show(menu_close); - - g_signal_connect_swapped(status_tomb, "activate", G_CALLBACK(left_click), menu_tomb); - - notice = notify_notification_new_with_status_icon - ("Tomb encrypted undertaker", - "We started digging out bones", - NULL, status_tomb); - notify_notification_set_icon_from_pixbuf(notice, pb_monmort); - - notify_notification_show(notice, &error); - - gtk_main(); - - notify_uninit(); - - exit(0); - -} - -// callbacks -gboolean left_click(GtkWidget *w, GdkEvent *e) { - gtk_menu_popup(menu_tomb, NULL, NULL, - gtk_status_icon_position_menu, status_tomb, - 1, gtk_get_current_event_time()); -} -gboolean cb_close(GtkWidget *w, GdkEvent *e) { - execlp("tomb","tomb","-S","umount",NULL); - gtk_main_quit(); -} diff --git a/src/tomb-notify.cpp b/src/tomb-notify.cpp @@ -63,8 +63,6 @@ int main(int argc, char **argv) { notify_uninit(); - usleep(.5); - exit(0); } diff --git a/src/tomb-open b/src/tomb-open @@ -0,0 +1,12 @@ +#!/bin/sh +# startup wrapper to open tombs + +# got a tomb as argument +if [ $@ ]; then + tomb -S open $@ + exit $? +fi + +tomb -h + +sleep 10+ \ No newline at end of file diff --git a/src/tomb-status.cpp b/src/tomb-status.cpp @@ -0,0 +1,179 @@ +/* Tomb - encrypted storage undertaker + * + * (c) Copyright 2007-2011 Denis Roio <jaromil@dyne.org> + * + * This source code is free software; you can redistribute it and/or + * modify it under the terms of the GNU Public License as published + * by the Free Software Foundation; either version 3 of the License, + * or (at your option) any later version. + * + * This source code is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * Please refer to the GNU Public License for more details. + * + * You should have received a copy of the GNU Public License along with + * this source code; if not, write to: + * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <gtk/gtk.h> +#include <libnotify/notify.h> + +/* The Tomb icon is an artwork by Jordi aka MonMort + a nomadic graffiti artist from Barcelona */ +#include <monmort.xpm> + +GdkPixbuf *pb_monmort; +GtkStatusIcon *status_tomb; +GtkMenu *menu_left, *menu_right; + +NotifyNotification *notice; +GError *error; + +char filename[256]; +char mountpoint[256]; + +// forward declaration of callbacks +gboolean left_click(GtkWidget *w, GdkEvent *e); +gboolean cb_view(GtkWidget *w, GdkEvent *e); +gboolean cb_close(GtkWidget *w, GdkEvent *e); + +gboolean right_click(GtkWidget *w, GdkEvent *e); +gboolean cb_about(GtkWidget *w, GdkEvent *e); + + +int main(int argc, char **argv) { + GObject *tray; + GtkWidget *item_close, *item_view, *item_about; + gint menu_x, menu_y; + gboolean push_in = true; + + char tomb_file[512]; + + gtk_set_locale(); + gtk_init(&argc, &argv); + + // get the information from commandline + if(argc<3) sprintf(mountpoint,"unknown"); + else snprintf(mountpoint,255, "%s", argv[2]); + + if(argc<2) sprintf(filename, "unknown"); + else snprintf(filename,255, "%s", argv[1]); + + // libnotify + notify_init(PACKAGE); + + // set and show the status icon + pb_monmort = gdk_pixbuf_new_from_xpm_data(monmort); + status_tomb = gtk_status_icon_new_from_pixbuf(pb_monmort); + // gtk_status_icon_set_name(status_tomb, "tomb"); + gtk_status_icon_set_title(status_tomb, "Tomb"); + gtk_status_icon_set_tooltip_text (status_tomb, "Tomb - crypto undertaker"); + + // LEFT click menu + menu_left = (GtkMenu*) gtk_menu_new(); + // view + item_view = gtk_menu_item_new_with_label("View"); + gtk_menu_attach(menu_left, item_view, 0, 1, 0, 1); + g_signal_connect_swapped(item_view, "activate", G_CALLBACK(cb_view), NULL); + gtk_widget_show(item_view); + // close + item_close = gtk_menu_item_new_with_label("Close"); + gtk_menu_attach(menu_left, item_close, 0, 1, 1, 2); + g_signal_connect_swapped(item_close, "activate", G_CALLBACK(cb_close), NULL); + gtk_widget_show(item_close); + + // connect it + g_signal_connect_swapped(status_tomb, "activate", G_CALLBACK(left_click), menu_left); + + + // RIGHT click menu + menu_right = (GtkMenu*) gtk_menu_new(); + // about + item_about = gtk_menu_item_new_with_label("About"); + gtk_menu_attach(menu_right, item_about, 0, 1, 0, 1); + g_signal_connect_swapped(item_about, "activate", G_CALLBACK(cb_about), NULL); + g_signal_connect_swapped(item_about, "popup-menu", G_CALLBACK(cb_about), NULL); + gtk_widget_show(item_about); + // connect it + g_signal_connect_swapped(status_tomb, "popup-menu", G_CALLBACK(right_click), menu_right); + + // status icon + notice = notify_notification_new_with_status_icon + ("Tomb encrypted undertaker", + "We started digging out bones", + NULL, status_tomb); + notify_notification_set_icon_from_pixbuf(notice, pb_monmort); + + notify_notification_show(notice, &error); + + gtk_main(); + + notify_uninit(); + + exit(0); + +} + +// callbacks left click +gboolean left_click(GtkWidget *w, GdkEvent *e) { + gtk_menu_popup(menu_left, NULL, NULL, + gtk_status_icon_position_menu, status_tomb, + 1, gtk_get_current_event_time()); +} +gboolean cb_view(GtkWidget *w, GdkEvent *e) { + GtkWidget *dialog = + gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "Tomb '%s' open on '%s'", filename, mountpoint); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + +} + +gboolean cb_close(GtkWidget *w, GdkEvent *e) { + execlp("tomb","tomb","-S","umount",NULL); + gtk_main_quit(); +} + +// callbacks right click +gboolean right_click(GtkWidget *w, GdkEvent *e) { + gtk_menu_popup(menu_right, NULL, NULL, + gtk_status_icon_position_menu, status_tomb, + 1, gtk_get_current_event_time()); +} +gboolean cb_about(GtkWidget *w, GdkEvent *e) { + const gchar *authors[] = {"Denis Roio aka Jaromil - http://jaromil.dyne.org",NULL}; + const gchar *artists[] = {"Jordi aka MonMort - http://monmort.blogspot.org", + "Gabriele Zaverio aka Asbesto - http://freaknet.org/asbesto", + NULL}; + GtkWidget *dialog = gtk_about_dialog_new(); + gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(dialog), PACKAGE); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), VERSION); + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), + "(C)2007-2010 Denis Roio aka Jaromil"); + gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), artists); + gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog), authors); + + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), + "The Crypto Undertaker\n" +"\n" +"This program helps people keeping their bones together by taking care of their private data inside encrypted storage filesystems that are easy to access and transport.\n" +"\n" +"The level of security provided by this program is fairly good: it uses an accelerated AES/SHA256 (cbc-essiv) to access the data on the fly, as if it would be a mounted volume.\n" +"\n" +"To start digging your tomb be ready to get your hands dirty and use the commandline utility 'tomb' from a text terminal." +); + gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), PACKAGE_URL); + gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pb_monmort); + gtk_dialog_run(GTK_DIALOG (dialog)); + gtk_widget_destroy(dialog); +} +