AndreyPavlenko / transmissionbtc

Transmission BitTorrent Client for Android
GNU General Public License v2.0
97 stars 14 forks source link

better support for native transmission functions with root access for transmission post-processing script #3

Open rodibin-at-placemaildotonline opened 5 years ago

rodibin-at-placemaildotonline commented 5 years ago

hello, i'm a power user with root access on my nvidia shield androdi tv and I LOVE this app!

i'm wondering if it's possible to add a few things to this app, extending to support most of transmission's native features namely:

1) upnp automatic mapping of ports 2) blocklist setup 3) script-torrent-done-filename support for bash scripts I created 4) support for transmission-remote calls from the bash script 5) trash original torrent files 6) support for renaming torrents

and in general support for most of other transmission options that are available on the main client tailorored for people who have root!

thanks let me know how I can help

AndreyPavlenko commented 5 years ago
  1. UPnP is enabled by default and port mapping should work
  2. Blocklist can be configured in WEB UI or via transmission remote
  3. I've never tested, but I think it should work. Try to add your script to the transmission configuration file.
  4. For bash scripts you may use the transmission-remote command. However, if you want to run the scripts on Android, you will need an android port of transmission-remote.
  5. "Remove from list" removes only the torrent file and does not remove the data.
  6. This is supported in WEB-UI
rodibin-at-placemaildotonline commented 5 years ago

You rock, thanks for the fast reply.

  1. Yes you are right I spoke too soon
  2. Done, thanks, I was just hoping to see it in the app's settings as well
  3. I just tested it, and in logcat I get a permissions error:
03-24 08:58:30.214 32193 14448 I transmission: Retrying scrape in 303 seconds.
03-24 08:58:38.000 32193 14448 E transmission: IPv4 DHT announce failed (good, 147 nodes): Try again
03-24 08:58:40.643 32193 14448 E transmission: Couldn't create "/storage/4D4F131D28B39596/Downloads/KNOPPIX_V8.2-2018-05-10-EN": Permission denied
03-24 08:59:28.270 32193 14448 E transmission: IPv4 DHT announce failed (good, 163 nodes): Operation now in progress
03-24 08:59:28.271 32193 14448 I transmission: State changed from "Incomplete" to "Done"
03-24 08:59:28.273 32193 14448 I transmission: Calling script "/storage/4D4F131D28B39596/tools/transmission/tr-complete.sh"
03-24 08:59:28.284 32193 14448 E transmission: Error executing script "/storage/4D4F131D28B39596/tools/transmission/tr-complete.sh" (13): Child process setup failed: Permission denied

Looks like transmission will need to call SU when it runs the script, I've already given it root permissions by increasing socket buffers

  1. thanks I will investigate this further
  2. I spoke too son on this one too, when I trash the torrent it does trash original torrent files
  3. awesome
AndreyPavlenko commented 5 years ago
  1. Try to put your script into the application directory - /data/data/com.ap.transmission.btc
rodibin-at-placemaildotonline commented 5 years ago

I will, but even if I did that there are several functions inside the bash script that require root. How can I run it with root?

AndreyPavlenko commented 5 years ago

The script may run su.

rodibin-at-placemaildotonline commented 5 years ago

I'm running into the same error after placing it into the right directory :(

The script executes successfully when I am ssh'd in as root so I'm thinking that transmission needs to request SU every time it executes the script.

03-24 12:39:01.317 27738 29228 I transmission: State changed from "Incomplete" to "Done" 03-24 12:39:01.317 27738 29228 I transmission: Calling script "/data/data/com.ap.transmission.btc/tr-complete.sh" 03-24 12:39:01.323 27738 29228 E transmission: Error executing script "/data/data/com.ap.transmission.btc/tr-complete.sh" (13): Child process setup failed: Permission denied

AndreyPavlenko commented 5 years ago

Have you added execute permissions ? Try this - chmod 777 /data/data/com.ap.transmission.btc/tr-complete.sh.

rodibin-at-placemaildotonline commented 5 years ago

Yes, and I even tried chgrp and chmod to the transmission user and still no dice, same error

AndreyPavlenko commented 5 years ago

Then I can suggest the following 2 options:

  1. Most probably your external storage /storage/4D4F131D28B39596 is mounted with noexec option (type mount | grep noexec). In this case you may remoun the storage without noexec and put your script to this storage.

  2. Put the script to /system/bin: mount -o rw,remount; cp your_stript /system/bin; mount -o ro,remount

rodibin-at-placemaildotonline commented 5 years ago
  1. mount command didn't work, is there another one? I'm not sure if this is the issue since I put the script in /data/data/com.ap.transmission.btc/ which is on the internal storage system?

  2. Can you clarify the commands I need to enter to try this one?

Wouldn't it be easier if there was an option built into transmissionbtc to run scripts as root? Like, it's the same thing as needing root for "increase socket buffers" except in this case it kicks in for running scripts. If you'd like I can help code it?

AndreyPavlenko commented 5 years ago

It would definitely be easier, but it requires Transmission modification because the script is called from Transmission code - https://github.com/AndreyPavlenko/transmission/blob/master/libtransmission/torrent.c#L2232

rodibin-at-placemaildotonline commented 5 years ago

hmm that sounds complicated, plus it would have to be put into the mainline repo eventually, right?

Perhaps there is an easier way. Is it possible to run the transmission-daemon as root on boot, a change that requires expanding root capability of the increase_so_buf, like a "run transmission-daemon as root" option. Something like this:

http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/

AndreyPavlenko commented 5 years ago

No, I've forked mainline repo and all changes I do in the fork. The mainline repo does not have support for Android.

increase_so_buf is just a shell script. The application runs su and writes the script to stdin - https://github.com/AndreyPavlenko/transmissionbtc/blob/master/src/main/java/com/ap/transmission/btc/Utils.java#L458. It's not possible to run the daemon as root because it's not a standalone executable. Transmission is built into the application as a JNI library.

rodibin-at-placemaildotonline commented 5 years ago

hmm sorry to hear that, I moved to using termux's built-in transmission, which I can run as root and allows me to use the torrent done completion script.

https://github.com/termux/termux-packages/tree/master/packages/transmission

Thank you so much for trying to help me!

If you're able to turn transmissionbtc into a remote control for transmission-daemon I'll definitely use it.