encfs icon indicating copy to clipboard operation
encfs copied to clipboard

enhance exit code

Open blshkv opened this issue 8 years ago • 15 comments

Hi,

I'm trying to code a small bash script which should detect different scenarios. However, I found that encfs returns two exit codes: 0 or 1 only:

EncFS Password: 
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message
code: 1

I suggest to create a list of various codes for each case: an invalid password, module is not installed, mountpoint is not empty and so on. In particular, I need a different exit code when the directory was successfully mounted (decrypted) already.

Thank you.

blshkv avatar Dec 28 '15 04:12 blshkv

That sounds like a very useful suggestion! I myself integrate encfs through bash scripts.

pepa65 avatar Dec 30 '15 10:12 pepa65

ping?

blshkv avatar Feb 01 '17 03:02 blshkv

Can I contribute ?

Furinkazan33 avatar Oct 12 '17 16:10 Furinkazan33

Sure @Furinkazan33, I think you can sending a PR.

benrubson avatar Oct 13 '17 11:10 benrubson

@benrubson I don't have the permission yet.

Furinkazan33 avatar Oct 13 '17 18:10 Furinkazan33

Fork the repository, and push modifications to a new branch into your own repository. GitHub will then propose you to submit your modifications into a PR here, the upstream repository 👍

benrubson avatar Oct 13 '17 18:10 benrubson

ping?

blshkv avatar Aug 09 '18 04:08 blshkv

Sorry, looks like nobody is working on this.

rfjakob avatar Aug 09 '18 07:08 rfjakob

I'm not sure this would be easy to achieve. EncFS calls fuse_main(). And fuse_main() returns 0 on success, nonzero on failure : https://libfuse.github.io/doxygen/fuse_8h.html Unfortunately nonzero is not detailed.

We would then have to implement system stuffs to find out what could have made fuse_main() to fail. I think this would be more reliable and easy to implement at a (Bash) script level, verifying all prerequisites are here before mounting.

benrubson avatar Aug 09 '18 07:08 benrubson

hm.. that sounds like an fuse issue. Perhaps, we should ask them to implement it as well.

blshkv avatar Aug 09 '18 08:08 blshkv

Reading the config file and checking the password happens before jumping to fuse, so these could easily get their own exit codes i believe.

rfjakob avatar Aug 10 '18 13:08 rfjakob

For wrong password yes for sure. But what about the following ?

I need a different exit code when the directory was successfully mounted (decrypted) already.

benrubson avatar Aug 10 '18 13:08 benrubson

Hmm, this is actually quite easy using shell script:

if mountpoint /path/to/dir ; then exit 2 fi

rfjakob avatar Aug 10 '18 13:08 rfjakob

Using shell script yes of course ! But inside EncFS itself, we would be "platform-dependant" (remember the unmount stuff).

benrubson avatar Aug 10 '18 13:08 benrubson

it may be "easy" but it is a wrong approach. A user should not check for border conditions of a software. That must be done by the software itself. Specifically, sys-fs/encfs-1.9.4 version crashes (!!!) with the following encfs[17049]: segfault at 2d0 ip 00007f1e533c5d8d sp 00007ffe06bcc650 error 4 in libpthread-2.26.so[7f1e533bd000+1c000] on the attempt to mount a mounted directory.

This is not acceptable. All relevant checks similar with the PoC bash script above must be done by encfs and fuse

blshkv avatar Aug 11 '18 00:08 blshkv