Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 350213

Summary: net-p2p/deluge uses single rc script for two daemons
Product: Gentoo Linux Reporter: Cameron Tacklind <cameron>
Component: New packagesAssignee: Paolo Pedroni <paolo.pedroni>
Status: RESOLVED FIXED    
Severity: enhancement CC: cameron, chris.burroughs, flow, net-p2p
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Initial split of daemons in patch form
Patch for current ebuild to use deluge patches and multiple init.d files
Adding support to deluged to switch uid on it's own
Adding support to deluge-web to switch uid on it's own
New init.d file for deluged
New init.d file for deluge-web
New conf.d file for deluged
New conf.d file for deluge-web
Fixed group support for deluged
Fixed group support for deluge-web

Description Cameron Tacklind 2010-12-31 09:52:38 UTC
net-p2p/deluge uses a single rc script to start the daemon. There is an option in conf.d/deluge to start a UI as well. The "default" is the web-ui, but can be set to console or gtk. But why would you ever start anything but the webui (really a daemon) at startup? While this doesn't really cause any problems in normal operation, it should be separated to be more correct. They can be run as separate users, with different config folders, and started and stoped completely independently. This also lets rc think that deluged started just fine as long as the webui was started since it's exit status overrides the daemon's.

So for now, I'm attaching a first attempt at splitting these two. All I did was move the ui starting code to it's own rc script, made it explicitly call deluge-web, and fix the appropriate variables. Unfortunately, I can't say this works %100 as my deluge wasn't starting properly before this and this was my first attempt to make it's init script work better to help find the problem.

There is still plenty of room to improve these scripts which I plan to do soon, for instance:
 - Make webserver rc-script installed with use flag
 - Make deluge write it's own pid file (permission issue since deluge user can't write to /var/run/deluged.pid)
 - Let deluge fork it's self
Some will require a small patch to deluge...
 - Make deluge chuid on it's own
 - Make deluge use config from /etc (and state files in /var maybe?)
Comment 1 Cameron Tacklind 2010-12-31 09:53:47 UTC
Created attachment 258495 [details, diff]
Initial split of daemons in patch form
Comment 2 Cameron Tacklind 2011-01-05 18:52:10 UTC
I've written a simple patch (that I also will submit upstream) to let deluged and deluge-web switch uid (and gid) on their own. This lets them write a pidfile as root and then switch to a lower privilege. (which I think is the standard?)

I've also updated the init.d files to:
 - use this patch
 - let the daemons fork themselves
 - use symlink to run a second instance
 - use explicit variables for (without disabling old style I hope)
   - group
   - config dir

It all seems to work for me!
Comment 3 Cameron Tacklind 2011-01-05 18:58:05 UTC
Created attachment 258969 [details, diff]
Patch for current ebuild to use deluge patches and multiple init.d files
Comment 4 Cameron Tacklind 2011-01-05 19:08:12 UTC
Created attachment 258971 [details, diff]
Adding support to deluged to switch uid on it's own
Comment 5 Cameron Tacklind 2011-01-05 19:08:39 UTC
Created attachment 258973 [details, diff]
Adding support to deluge-web to switch uid on it's own
Comment 6 Cameron Tacklind 2011-01-05 19:09:11 UTC
Created attachment 258975 [details]
New init.d file for deluged
Comment 7 Cameron Tacklind 2011-01-05 19:09:24 UTC
Created attachment 258976 [details]
New init.d file for deluge-web
Comment 8 Cameron Tacklind 2011-01-05 19:09:40 UTC
Created attachment 258978 [details]
New conf.d file for deluged
Comment 9 Cameron Tacklind 2011-01-05 19:09:58 UTC
Created attachment 258979 [details]
New conf.d file for deluge-web
Comment 10 Cameron Tacklind 2011-01-14 19:48:58 UTC
Created attachment 259879 [details, diff]
Fixed group support for deluged

I accidentally used setuid for both user and group (instead of setgid)

I've also put the setgid before setuid so we are still root when we try to change groups
Comment 11 Cameron Tacklind 2011-01-14 19:49:38 UTC
Created attachment 259880 [details, diff]
Fixed group support for deluge-web

The same fix for deluge-web
Comment 12 Paolo Pedroni 2016-02-29 10:52:38 UTC
Fixed in deluge-1.3.12-r2