sci-misc/boinc: Update init script to fix bug 584386 and 603522
authorSven Eden <yamakuzure@gmx.net>
Thu, 8 Dec 2016 09:21:44 +0000 (10:21 +0100)
committerDavid Seifert <soap@gentoo.org>
Wed, 4 Jan 2017 13:41:54 +0000 (15:41 +0200)
commite4bdce024162b77ee4947674c2e4399fc4cf23f7
tree5b2a5dcbd8ccd5329d93d2163309c546f2e4828b
parentddf093bb3ac8523db1f663ca75371edb9cd93904
sci-misc/boinc: Update init script to fix bug 584386 and 603522

Gentoo-Bug: 584386

The boinc init script starts boinc_client in daemon mode, and relies on
boinccmd to send a quit signal to stop the service.

This leads to the following two problems:
1) It is not possible to generate a pid file, as the pid read from the
   started boinc_client is invalid after it forked to background.
2) The stop command immediately returns, but boinc_client can still be
   active for a long time, over a minute in fact, while it is stopping
   running projects and cleaning up its work data. This is especially
   problematic when boinc is stopped while shutting down the machine.

Gentoo-Bug: 603522

The init script for boinc calls "chown -R" on "${RUNTIMEDIR}".
This leads to the security issue, that the "boinc" user can create a
hardlink within ${RUNTIMEDIR} pointing to a file that he does not
own, and the next time the daemon is started, the init script (as
root) will give ownership of the *target* of the hardlink to the
boinc user.

This commit removes the usage of "chown -R" from start_pre(), and
adds a single call to "chown" to create_work_directory() if, and only
if the working directory has been newly created.

Other fixes and changes:

Another problem found is the function cuda_check(), which assumes the cuda
libraries to be installed in /opt/cuda/lib, leading to an invalid symlink
for libcudart.so on 64 bit machines where the library is installed in
/opt/cuda/lib64.

This commit changes the following behaviour, besides some long overdue
cleanup:
1) start() no longer uses the --daemon option of the boinc_client, but
   the --background option of the start-stop-daemon command. Further it
   creates a pid file in the path set by the new config variable
   BOINC_PIDFILE, that has been added to boinc.conf.
2) stop() no longer uses boinccmd to send a quit signal, but uses the
   --stop and --pidfile options of the start-stop-daemon command. The
   waiting time should be large enough to successfully await the end of
   the exiting task of the boinc_client program.
3) cuda_check() now checks the validity of the libcudart.so symlink and
   removes it if it is invalid. Further it looks for a present
   libcudart.so library in /opt/cuda/lib* and picks the newest found to
   create a new symlink if none is present.
4) The suspend() and resume() functions have been updated to use the
   start-stop-daemon command, so both the user:group and a possibly
   required password are now used to circumvent authentication errors.

Package-Manager: portage-2.3.3
Closes: https://github.com/gentoo/gentoo/pull/3056
sci-misc/boinc/files/boinc.conf
sci-misc/boinc/files/boinc.init