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

How can I get rtorrent to write as a non root user. #39

Open
disappeared1 opened this issue Aug 6, 2016 · 2 comments
Open

How can I get rtorrent to write as a non root user. #39

disappeared1 opened this issue Aug 6, 2016 · 2 comments

Comments

@disappeared1
Copy link

disappeared1 commented Aug 6, 2016

I noticed that the directories created are www-data. But the files written by rtorrent are all root.

What would be the best method to get these files written as a specific linux user? I'm guessing i'd have to run rtorrent here as the user i choose using su or something?

@guillemsola
Copy link

guillemsola commented Dec 30, 2016

This is a hot topic for me too. This is probably not a docktorrent image issue but something could be done.

Docker doesn't know what users do you have in your host machine. To solve it you should see what user id you have in your host and create one user in the docker image with the same id. Then rtorrent should be run with this user. This should be done at image creation time.

I personally decided to hack a bit the rtorrent capabilities. For this I modified the /root/.rtorrent.rc

For this I created a new variable with the final file name once copied to the finished folder

system.method.insert = d.get_finished_name,simple,"cat=$d.get_finished_dir=,$d.get_name="

Then, once the download finished event is thrown I added an execution step for the copied file to change the user

execute=chown,-R,1000:1000,$d.get_finished_name=

Notice that I used the user id 1000 which is usually the standard user in most of the linux distros. You can see your user id with id -u username. The user id could be parametrized to be changed at image container creation time.

All the changes look like

# Default directory to save the downloaded torrents.
directory = /rtorrent/downloads

system.method.insert = d.get_finished_dir,simple,"cat=/rtorrent/finished/,$d.get_custom1="
system.method.insert = d.get_finished_name,simple,"cat=$d.get_finished_dir=,$d.get_name="
system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.get_base_path=,$d.get_finished_dir=;execute=chown,-R,1000:1000,$d.get_finished_name="

@o6uoq
Copy link

o6uoq commented Dec 31, 2016

@guillemsola hot tip for a hot topic, thank you!

However, for my rtorrent/rutorrent setup, I'm using the default downloads directory without any post-finished moving after a completed download:

# downloaded torrents directory
directory = /rtorrent/downloads/

#system.method.insert = d.get_finished_dir,simple,"cat=/rtorrent/finished/,$d.get_custom1="
#system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.get_base_path=,$d.get_finished_dir="

(notice it's commented out)

The only thing I am doing is this:

# insert a new method to determine the basename of a given metadata (.torrent) file
system.method.insert = d.get_loaded_basename,string|simple,"execute_capture=bash,-c,\"echo -n \$(basename \\\"$1\\\")\",cleanbase,$d.get_loaded_file="

# insert another method to concatenate the final destination directory with the basename
system.method.insert = d.get_meta_path,simple,"cat=/rtorrent/torrents/,$d.get_loaded_basename="

# finally, move the .torrent, and update the tied_to_file to reference the new path
system.method.set_key = event.download.inserted_new,move_loaded,"execute=mv,-u,$d.get_loaded_file=,$d.get_meta_path=;d.set_tied_to_file=$d.get_meta_path="

I am assuming that I'll need to add some chown'ing to (1) system.method.set_key for when downloads are finished (as I'm assuming that rtorrent will assume the downloads dir as specified above) and (2) for where my torrent file ends up.

I'll update this issue once I've done some digging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants