Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link system call - Permission denied #837

Closed
vikanezrimaya opened this issue Sep 13, 2018 · 7 comments
Closed

link system call - Permission denied #837

vikanezrimaya opened this issue Sep 13, 2018 · 7 comments

Comments

@vikanezrimaya
Copy link

Android 8.0, Termux, Huawei Y6 Prime 2018, link() syscall, link program and everything using link gets permission denied to use the call.

Suspecting that seccomp filter blocks link(). Though an application should crash then...

Filesystem on /data is f2fs. Hardlinks on SD card don't work either, yielding the same Permission denied error.

@ghost
Copy link

ghost commented Sep 13, 2018

Suspecting that seccomp filter blocks link().

@kisik21 SELinux does not allow usage of link() by regular applications.

The only solutions are:

  1. Use proot --link2symlink {your application that use link()} (package 'proot' needed), but this does not create hardlinks.
  2. Patch your application so it will create symlinks instead of hardlinks.

@vikanezrimaya
Copy link
Author

vikanezrimaya commented Sep 13, 2018 via email

@ghost
Copy link

ghost commented Sep 13, 2018

Is there a way to somehow make not symlinks, but copies with proot?

If your application will run under proot (with link2symlink), it will see link()'ed file as hardlink.

Or patch an app to do this

Termux app is emulator for terminal (console) only. Everything else is use only what is provided by Android. We can't change this !

is there a copy syscall

Linux kernel does not have such syscall (having it is pointless as such feature can be easily implemented on user level). See this to view what's Linux provides: https://filippo.io/linux-syscall-table/ (this is for x86, on ARM/AArch64 it is different).


Here I posted solutions for this that will allow to run your application without 'permission denied' error. But if you really want hardlinks, just root your device and disable selinux enforcing.

@vikanezrimaya
Copy link
Author

Oh, apologies, I meant not a syscall, but a function in general. sendfile() probably might do what I meant, but I'm not diving into C code until I fail to get other methods to work.

proot --link2symlink muchsync --init ~/Maildir sakura fails with error: proot info: vpid 1: terminated with signal 7.

What might this mean? seems like this is SIGBUS, but I have no idea what this means.

@fornwall
Copy link
Member

@kisik21 Hi! I'm closing this issue as it isn't caused by the Termux app itself.

For getting help with proot, either open an issue at https://github.com/termux/proot/issues if you suspect an issue in proot, or ask for help on on the Google+ community or the Gitter chat.

@jackzhp
Copy link

jackzhp commented Jan 23, 2020

with android 8(api 26), we have

static Path Files.createLink(Path link, Path existing)

so the hard link should be available, isn't it?

@ghost
Copy link

ghost commented Jan 23, 2020

static Path Files.createLink(Path link, Path existing)
so the hard link should be available, isn't it?

Yes, it is available but question not about availability (libc has necessary functions too).

Hard links are disallowed by SELinux as part of security hardening (yes, hardlinks provide certain file-related attack vectors). Files.createLink() is not allowed by SELinux for regular applications too, it just throws

java.nio.file.AccessDeniedException

Another thing is that Termux packages do not use Java API.

@termux termux locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants