Tiny Core Linux

Tiny Core Extensions => TCE Talk => Extension requests => Topic started by: netnomad on October 31, 2012, 01:40:33 PM

Title: encFS - a simple way to encrypt dropbox folders
Post by: netnomad on October 31, 2012, 01:40:33 PM
hi friends,

dropbox can be very convenient, but do you think it's secure?
a way to use dropbox in a more secure way is to use an encFS-encrypted container.
encFS is lean and clean.
my longterm experience with encFS is very positive, cause it's stable and easy to use.

is there a volunteer who would be so kind to package encFS?

thank you for your help and your commitment.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on October 31, 2012, 04:59:14 PM

is there a volunteer who would be so kind to package encFS?

I have packaged encfs.tcz for personal successful use. Yes, it is nice software (apart from boost dependency).
However, each time I have to chown tc /dev/fuse, or encfs won't work.
Basically, the problem is that /dev/fuse has not the right owner or permissions, probably due to a bug with udev rules.
I don't have udev knowledge to track down the issue, nor the time to build such knowledge.

So I refrained from submitting encfs up to now.
Any suggestion?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: curaga on November 01, 2012, 06:53:25 AM
The default udev rules set fuse to 666 root:root, and mount fusectl. We haven't changed that.

What does encfs want it to be?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 01, 2012, 09:36:50 AM
Hi curaga
Quote
What does encfs want it to be?
I did a little Googling last night on fuse, and I think it's supposed to be  root/fuse 660, and the user is supposed to
be added to group fuse.
I'm running TC4.1, and my machine shows  /dev/fuse  is  root/root 600
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 01, 2012, 09:57:06 AM
I'm running TC4.1, and my machine shows  /dev/fuse  is  root/root 600

I have TC4.6.1, and my /dev/fuse has exactly the same attributes as Rich's.
Some trial and error shows that encfs works, without chowning, by doing chmod o+rw (resulting in a 606).

The encfs error message is:
Code: [Select]
fuse: failed to open /dev/fuse: Permission denied
fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message,
which is quoted also here:
https://answers.launchpad.net/encfs/+question/22951 (https://answers.launchpad.net/encfs/+question/22951)
and here:
http://lists.debian.org/debian-user/2011/10/msg00530.html (http://lists.debian.org/debian-user/2011/10/msg00530.html).

Applying the solution
Code: [Select]
sudo addgroup fuse
sudo addgroup tc fuse
didn't solve the problem. But maybe I have to check build parameters for encfs.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 01, 2012, 12:46:44 PM
Hi caminati
Your first solution works because you made /dev/fuse accessible to all users.
Your second solution was close, you still need to:
Code: [Select]
sudo chown root:fuse /dev/fuse
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 01, 2012, 03:42:31 PM
When fuse.tcz is loaded, you must do this:

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
Perhaps this code should be added into /tce.installed/fuse script...
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: tinypoodle on November 01, 2012, 04:57:53 PM
When fuse.tcz is loaded, you must do this:

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
Perhaps this code should be added into /tce.installed/fuse script...

Do you refer to specific application making use of fuse, or in general for fuse?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 01, 2012, 05:13:18 PM
In general. Right now, udev fuse rules (see 99-fuse.rules file which comes with fuse extension) are not applied until rules are reloaded.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: tinypoodle on November 01, 2012, 07:55:47 PM
When fuse.tcz is loaded, you must do this:

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
Perhaps this code should be added into /tce.installed/fuse script...

Or in other case should be worth mentioning in info file at least
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 01, 2012, 08:43:34 PM
hmm, actually it requires:

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
tc@box:~$ sudo udevadm trigger --action=change --sysname-match=fuse

because /dev/fuse is created at boot time and /udevadm control --reload-rules/ does not apply any changes to already existing devices...
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 02, 2012, 07:39:58 AM
Hi caminati
Your first solution works because you made /dev/fuse accessible to all users.
Your second solution was close, you still need to:
Code: [Select]
sudo chown root:fuse /dev/fuse

Yes, it was implied that I also chowned: however, that doesn't solve the issue.
By the way, it seems that the problem is absent before i tce-load -i firmware.tcz, probably because its initialization script does
Code: [Select]
udevadm trigger.
hmm, actually it requires:

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
tc@box:~$ sudo udevadm trigger --action=change --sysname-match=fuse

because /dev/fuse is created at boot time and /udevadm control --reload-rules/ does not apply any changes to already existing devices...

This works for me.
Is there any reason not to include the above udevadm commands in fuse.tcz's tce.install?
Should we PM Daniel Barnes?
For the moment I have submitted encfs.tcz with those commands suggested in info file.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 02, 2012, 09:08:45 AM
Hi caminati
Since the  99-fuse.rules file  is supplied with this extension, the tce.install script should probably make sure the
rules are initiated.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 02, 2012, 09:53:44 AM
Hi caminati
Since the  99-fuse.rules file  is supplied with this extension, the tce.install script should probably make sure the
rules are initiated.

I'm afraid I don't understand the term initiated here.
Is it udev jargon?
Do you mean that you agree tce.install script in fuse.tcz should be added AmatCoder's commands?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Juanito on November 02, 2012, 10:11:19 AM
no, since the fuse udev rules are in your extension, the script needs to be in your extension
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 02, 2012, 10:38:34 AM
no, since the fuse udev rules are in your extension, the script needs to be in your extension

Sorry, I'm lost (I admit I don't know how udev works, so maybe it's me): my encfs.tcz has no rules, it only contains three encfs binary files: /usr/local/bin/{encfs,encfsctl,encfssh}, and nothing else.

Moreover, fuse.tcz seems to have the same problem with basically any of its dependers: try
Code: [Select]
tce-load -i firmware.tcz
tce-load -i fusecompress.tcz {sshfs-fuse-2.2.tcz, sshfs-fuse.tcz} CurlFtpFS.tcz

Using any of these programs fails due to denied permission on /dev/fuse.
Note that you have to use valid ssh/ftp connection to see that.
My impression (see also http://forum.tinycorelinux.net/index.php?topic=11777.0 (http://forum.tinycorelinux.net/index.php?topic=11777.0)) is that the problem is with fuse.tcz. Am I wrong?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 02, 2012, 12:17:34 PM
IMO, those commands should be into tce.install script from fuse.tcz (extension made by Daniel Barnes).

Fuse.tcz ships with a 99-fuse.rules file, so fuse.tcz should ensure its correct implementation (and should not do extensions which depended on it).
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Juanito on November 02, 2012, 01:05:40 PM
Ah - I thought the rules were in the proposed extension, sorry for the confusion
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 02, 2012, 01:45:50 PM
Ah - I thought the rules were in the proposed extension, sorry for the confusion

No prob.
I queried the tce bugs forum board about the issue, hoping danielibarnes is going to give feedback.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 02, 2012, 04:16:56 PM
Hi caminati
That was my fault, I should have said the fuse extension, not your extension.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: netnomad on November 04, 2012, 12:03:11 PM
hi caminati,

thank you for your encfs.tcz-package.

everything works fine after these two mentioned fuse-commands...

you could do it much more convenient for all users,
if you put these in a little script in your package under following path:
/usr/local/tce.installed/

so create that encfs-starting-script /usr/local/tce.installed/encfs

#!/bin/sh
sudo udevadm control --reload-rules
sudo udevadm trigger --action=change --sysname-match=fuse

make it executable f.e. with chmod 700 encfs,
repackage and upload it again.

btw i did that already in my individual meta-package encfs_meta.tcz and everything works fine.

thank you for your help
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: curaga on November 04, 2012, 02:29:16 PM
Eh, extensions shouldn't work around other extensions. Better fix that one in fuse.tcz.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: netnomad on November 04, 2012, 04:09:08 PM
Eh, extensions shouldn't work around other extensions. Better fix that one in fuse.tcz.

hi curaga,

of course, you are right!
sometimes meta-packages can help to load a set of packages and pre-configurations in one set.

hopefully fuse.tcz will be soon fixed, so this should be the first goal.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Juanito on November 04, 2012, 10:36:25 PM
Rather than adding a new group "fuse", I wonder if it wouldn't be better to compile fuse so that it works with "staff" - if possible of course...
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 04, 2012, 11:12:32 PM
Hi Juanito
Since the fuse rules file sets the mode to 666, would the group setting even matter?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 06, 2012, 07:29:48 AM
Problem is that udev has a bug...or an undocumented behavior...Example:

Code: [Select]
KERNEL=="fuse", MODE="0666"Works...mode is setted. (rule from fuse is like this...)

Code: [Select]
KERNEL=="fuse", ACTION=="add", MODE="0666"Does not work...mode is ignored. (default rule from udev is like this...)

Code: [Select]
KERNEL=="fuse", ACTION=="change", MODE="0666"Works...mode is setted.

Code: [Select]
KERNEL=="fuse", ACTION=="add|change", MODE="0666"Works...mode is setted.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: althalus on November 06, 2012, 06:09:04 PM
Problem is that udev has a bug...or an undocumented behavior...Example:

Code: [Select]
KERNEL=="fuse", MODE="0666"Works...mode is setted. (rule from fuse is like this...)

Code: [Select]
KERNEL=="fuse", ACTION=="add", MODE="0666"Does not work...mode is ignored. (default rule from udev is like this...)

Code: [Select]
KERNEL=="fuse", ACTION=="change", MODE="0666"Works...mode is setted.

Code: [Select]
KERNEL=="fuse", ACTION=="add|change", MODE="0666"Works...mode is setted.

Quick idea, haven't looked into how udev rules work or anything so feel free to tell me I'm wrong, but mightn't that just mean udev won't perform the add action because it thinks that it's already been added?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: Rich on November 06, 2012, 09:16:30 PM
Hi AmatCoder
Doesn't sound like a bug to me. If the item exists, there is nothing to add, and the rule is skipped.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 07, 2012, 06:02:06 AM
But /dev/fuse is created at boot by udev following default rules... The default rule is:
Code: [Select]
KERNEL=="fuse", ACTION=="add", MODE="0666", OPTIONS+="static_node=fuse", \
  RUN+="/bin/mount -t fusectl fusectl /sys/fs/fuse/connections"


And at boot, udev is executed as we can see in /etc/init.d/rcS :

Code: [Select]
# Start Udev to populate /dev and handle hotplug events
echo -n "${BLUE}Starting udev daemon for hotplug support...${NORMAL}"
/sbin/udevd --daemon 2>&1 >/dev/null
/sbin/udevadm trigger --action=add 2>&1 >/dev/null &
rotdash $!
echo "${GREEN}Done.${NORMAL}"

Note that action triggered is "add", so mode should be setted...
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: AmatCoder on November 07, 2012, 07:00:30 AM
Oh, now I can see what's happening....

Some tce.installed scripts (e.g.: alsa.tcz) do:
Code: [Select]
udevadm trigger
If you run this without --action parameter then default action is "change"... So rules with ACTION=="add" are skipped, devices are preserved BUT permission is set to default mode (600):

Code: [Select]
[...]
udev_node_mknod: preserve file '/dev/fuse', because it has correct dev_t
udev_node_mknod: set permissions /dev/fuse, 020600, uid=0, gid=0
[...]
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 07, 2012, 01:48:29 PM
Oh, now I can see what's happening....

Some tce.installed scripts (e.g.: alsa.tcz) do:
Code: [Select]
udevadm trigger
If you run this without --action parameter then default action is "change"... So rules with ACTION=="add" are skipped, devices are preserved BUT permission is set to default mode (600):

Code: [Select]
[...]
udev_node_mknod: preserve file '/dev/fuse', because it has correct dev_t
udev_node_mknod: set permissions /dev/fuse, 020600, uid=0, gid=0
[...]

Thanks for your analysis.
You seem to be one of the ones having deepest insight here about udev stuff.
What is the appropriate way to deal with the problem?
Maybe amending all the extensions blindly doing
Code: [Select]
udevadm trigger ?
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: curaga on November 07, 2012, 02:25:28 PM
Removing the "ACTION" clause from fuse.tcz ought to do.

Note that the change action is the correct one, calling add would re-add all existing devices which could break things.
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: netnomad on November 17, 2012, 05:07:25 AM
hi friends,

thank you for all your helpful replies.
i solved my last issues with an own meta-package,
but what could we do that it works with the standard-packages in the repository?

i guess that fuse.tcz should be optimized?
or ought there be changes in encfs.tcz, too?

thank you for further hints or recommendations...
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: danielibarnes on November 17, 2012, 08:46:07 PM
Netnomad just brought this thread to my attention. I am doing some research on the the issue. Is there a consensus on the change which should be made to the fuse extension?

Thanks,
Daniel
Title: Re: encFS - a simple way to encrypt dropbox folders
Post by: caminati on November 19, 2012, 05:11:35 AM
Netnomad just brought this thread to my attention. I am doing some research on the the issue. Is there a consensus on the change which should be made to the fuse extension?

Thanks,
Daniel

I didn't grasp the last comment by curaga. However,  AmatCoder's solution (see http://forum.tinycorelinux.net/index.php/topic,14326.0.html (http://forum.tinycorelinux.net/index.php/topic,14326.0.html)) is working for me.
Maybe someone wants to test it (unsquashfs fuse.tcz; append the two lines to usr/local/tce.installed/fuse, followed by a newline; mksquashfs into a.tcz; substitute fuse.tcz with a.tcz; do all this as root) further?