You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Andrew January <an...@gmail.com> on 2015/10/13 15:34:18 UTC

[daemon] Upstart integration (removing checkuser)

Hey,

I'm trying to get upstart to launch a a java program daemonized using jsvc.

Upstart (annoyingly) doesn't have any support for pid files, but instead
monitors system calls to detect forks. You can control whether it's
expecting 1 or 2 forks using the "expect fork" and "expect daemon"
respectively (http://upstart.ubuntu.com/cookbook/#expect)

If I don't pass the -user flag to jsvc, I can get upstart to detect the
controller process using "expect fork". However, if I _do_ pass the -user
flag (because the java program needs to read some root-owned files on
startup, then drop to a non-privileged user) it doesn't pick up the correct
process because jsvc has extra forks to check the user passed in is valid (
http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c?view=markup&pathrev=1460687#l427).
You actually get two extra forks, because the process restarts with the
given procname.

Looking through the code, the only reason I can see for it to fork and
check the user is as a fail-early strategy and not create the controller
process if it's never going to be able to switch the user. I am thinking of
submitting a patch to add a "-disableusercheck" flag which would skip the
checkuser call. Is there another reason for the checkuser fork that means
removing it would lead to issues? If I submitted such a patch is it likely
to be considered?

Cheers,
Andrew