mhogomchungu / zuluCrypt

zuluCrypt is a front end to cryptsetup and tcplay and it allows easy management of encrypted block devices
https://mhogomchungu.github.io/zuluCrypt
Other
504 stars 60 forks source link

Unmounting doesn't work properly if a "before unmount command" is set #117

Closed aardbol closed 5 years ago

aardbol commented 5 years ago

I'd like a command to run after I unmount a mount, but Sirikali only supports before unmount command triggers. So I used that instead to clear the thumbnail cache so prevent sensitive data from being leaked. But I noticed that the unmount behavior doesn't work properly then. It does unmount the mount but the mountpoint isn't removed from the GUI, nor is the command executed.

The command: rm -rf /home/ik/.cache/thumbnails/*

mhogomchungu commented 5 years ago

Try to wrap your command in a script and make sure it return "0".

Your script will be given the path to the mount point as its only argument.

aardbol commented 5 years ago

Okay, I'll try that later. Thanks

mhogomchungu commented 5 years ago

SiriKali git version now has the ability to set pre-mount, post-mount, pre-unmount and post-unmount custom commands per favorite entry,

The post-mount custom command will run only if the volume is successfully mounted. The post-unmount custom command will run only if the volume is successfully unmounted.

The return values of these custom commands are never used when used when set per favorite entry.

aardbol commented 5 years ago

Okay great. I wrote a script to remove the thumbnail, but now it removes ALL the thumbnails when the encryption mount is unmounted. I was wanting modify it to only remove thumbnails that were created between the mount and unmount actions of SiriKali. These new options will allow me to do that more easily

aardbol commented 5 years ago

I tested the mount command now but they don't seem to work.

I created a small script for testing purposes:

#!/usr/bin/env python3

import subprocess

subprocess.check_output("notify-send \"ok\"", shell=True)

And then pass the script path as PreMount Command to the favorite in Sirikali: /home/ik/script.py

Nothing happens.

mhogomchungu commented 5 years ago

Your script worked fine here when trying to mount a volume. Are you sure you have the script's executable bit set? In other words, can you run the script directly from the terminal?

aardbol commented 5 years ago

Sure this test version works perfectly. Even the real script works perfectly from tht terminal. But when Sirikali is supposed to run it, nothing happens.

Antergos, latest sirikali version

mhogomchungu commented 5 years ago

While the main SiriKali window has focus, click "CTRL+D" to generate the debug window and then try again to open the favorite entry and post the contents of the debug window.

aardbol commented 5 years ago

Exit Code: 0
Exit Status: 0
-------
StdOut: 
-------
StdError: 
-------
Command: "/usr/bin/gocryptfs" -q "/mnt/256GBBTRFS/files" "/home/ik/.SiriKali/files_1"  -o rw,fsname=gocryptfs@"/mnt/256GBBTRFS/files"
-------

Exit Code: 0
Exit Status: 0
-------
StdOut: 
-------
StdError: 
-------
Command: /usr/bin/xdg-open "/home/ik/.SiriKali/files_1"
-------
mhogomchungu commented 5 years ago

Your script wasnt run and the only reason i can think of is that you set the command on the wrong favorite entry, or SiriKali failed to get the right favorites entry when it was looking for the favorites entry based on cipher path+mount path combo.

Is the volume getting mounted with the same mount path as registered in the favorites entry?

aardbol commented 5 years ago

Is the volume getting mounted with the same mount path as registered in the favorites entry?

No it doesn't. SK doesn't always delete the folders properly after unmounting, that's why the actual mount point sometimes changes to _1 or _2 etc.

I removed the existing folder and mounted again and now the command is run properly. That's confusing. But it's not a permanent solution unfortunately, because SK doesn't always respect the mount point

It also seems to give a problem with commands that contain extra arguments. For example: test.py arg1

mhogomchungu commented 5 years ago

Set the option Menu->Options->General Options->Re Use Mount Point and SiriKali will reuse a mount point folder when it sees it during mounting and will not delete it when unmounting.

SiriKali by default wants an exclusive control of the mount point and it searches for an empty path when mounting a volume and automatically deletes it when unmounting.

Yes, custom commands with options currently are not supported.

aardbol commented 5 years ago

Okay thanks.

Here's the commands for thumbnail removal for Sirikali and zuluCrypt mounts: https://gitlab.com/isaakm/sirikali-triggers

mhogomchungu commented 5 years ago

Git version should now work with custom command with custom options like test.py arg1 arg2 argN