termux / termux-root-packages

Termux packages that are only usable by root users.
Other
1.04k stars 295 forks source link

[Package request] Inclusion of libfuse2 #188

Closed FreddieOliveira closed 4 years ago

FreddieOliveira commented 4 years ago

Package description

Filesystem in Userspace (FUSE) is a software interface for Unix and Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code, or it was supposed to be.

Actually this is not so true in Android, since only root user are allowed to use it. Nor relaxing permissions of /dev/fuse, nor setting the set ID bit of the libs and binaries makes any difference. Blame Google for this.

Here's the Ubuntu package page for reference: https://packages.ubuntu.com/focal/libfuse2

Link to home page and sources

  1. Home page: https://github.com/libfuse/libfuse
  2. Source code: https://github.com/libfuse/libfuse

Additional information

Unfortunately, libfuse2 doesn't come with a test suit, so the building steps bellow refers to the release build type. To test it, use some other program that uses it. Like CryFS and EncFS

As discussed here, some patches are necessary as a workaround to some pthread functions not available in the Android SDK. The strategy used was to use an atomic watch variable and check if it's set right before the so called cancellation points functions. This mimics as close as possible the pthread_cancel behavior.

These are the libs it depends upon:

libiconv.so
libdl.so
libc.so

All the steps above were executed from within termux using the latest stable version of libfuse v2. First download the patches, then run:

$ wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz
$ tar xf fuse-2.9.9.tar.gz && cd fuse-2.9.9
$ patch lib/fuse.c ../fuse.c.patch
$ patch lib/fuse_loop_mt.c ../fuse_loop_mt.c.patch
$ MOUNT_FUSE_PATH=/data/data/com.termux/files/usr/bin UDEV_RULES_PATH=/data/data/com.termux/files/usr/etc/udev/rules.d INIT_D_PATH=/data/data/com.termux/files/usr/etc/init.d ./configure --prefix=/data/data/com.termux/files/usr/ --disable-example --disable-mtab
$ make -j8
$ make install-strip

So far, everything seems to be working as expected. This is the list of files added to the system when installed:

files
└── usr
    ├── bin
    │   ├── fusermount
    │   ├── mount.fuse
    │   └── ulockmgr_server
    ├── etc
    │   ├── init.d
    │   │   └── fuse
    │   └── udev
    │       └── rules.d
    │           └── 99-fuse.rules
    ├── include
    │   ├── fuse
    │   │   ├── cuse_lowlevel.h
    │   │   ├── fuse.h
    │   │   ├── fuse_common.h
    │   │   ├── fuse_common_compat.h
    │   │   ├── fuse_compat.h
    │   │   ├── fuse_lowlevel.h
    │   │   ├── fuse_lowlevel_compat.h
    │   │   └── fuse_opt.h
    │   ├── fuse.h
    │   └── ulockmgr.h
    ├── lib
    │   ├── libfuse.a
    │   ├── libfuse.la
    │   ├── libfuse.so -> libfuse.so.2.9.9
    │   ├── libfuse.so.2 -> libfuse.so.2.9.9
    │   ├── libfuse.so.2.9.9
    │   ├── libulockmgr.a
    │   ├── libulockmgr.la
    │   ├── libulockmgr.so -> libulockmgr.so.1.0.1
    │   ├── libulockmgr.so.1 -> libulockmgr.so.1.0.1
    │   ├── libulockmgr.so.1.0.1
    │   └── pkgconfig
    │       └── fuse.pc
    └── share
        └── man
            ├── man1
            │   ├── fusermount.1
            │   └── ulockmgr_server.1
            └── man8
                └── mount.fuse.8

14 directories, 29 files

Attachments

fuse.c.patch.txt fuse_loop_mt.c.patch.txt

ghost commented 4 years ago

Added in https://github.com/termux/termux-root-packages/commit/eb22f7a625c45ea8261221f0150e24669d74f3c8.