Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 350213 - net-p2p/deluge uses single rc script for two daemons
Summary: net-p2p/deluge uses single rc script for two daemons
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement with 1 vote (vote)
Assignee: Paolo Pedroni
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-31 09:52 UTC by Cameron Tacklind
Modified: 2016-02-29 10:52 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Initial split of daemons in patch form (deluge.patch,4.19 KB, patch)
2010-12-31 09:53 UTC, Cameron Tacklind
Details | Diff
Patch for current ebuild to use deluge patches and multiple init.d files (deluge-ebuild.patch,630 bytes, patch)
2011-01-05 18:58 UTC, Cameron Tacklind
Details | Diff
Adding support to deluged to switch uid on it's own (deluged-setuid.patch,2.73 KB, patch)
2011-01-05 19:08 UTC, Cameron Tacklind
Details | Diff
Adding support to deluge-web to switch uid on it's own (deluge-web-setuid.patch,2.11 KB, patch)
2011-01-05 19:08 UTC, Cameron Tacklind
Details | Diff
New init.d file for deluged (deluged.init,2.06 KB, text/plain)
2011-01-05 19:09 UTC, Cameron Tacklind
Details
New init.d file for deluge-web (deluge-web.init,1.67 KB, text/plain)
2011-01-05 19:09 UTC, Cameron Tacklind
Details
New conf.d file for deluged (deluged.conf,188 bytes, text/plain)
2011-01-05 19:09 UTC, Cameron Tacklind
Details
New conf.d file for deluge-web (deluge-web.conf,191 bytes, text/plain)
2011-01-05 19:09 UTC, Cameron Tacklind
Details
Fixed group support for deluged (deluged-setuid.patch,2.73 KB, patch)
2011-01-14 19:48 UTC, Cameron Tacklind
Details | Diff
Fixed group support for deluge-web (deluge-web-setuid.patch,2.11 KB, patch)
2011-01-14 19:49 UTC, Cameron Tacklind
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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