Is there any reason why we don't call
daemon --user=ejabberd /usr/sbin/ejabberdctl start
in the init script but instead call runuser in /usr/sbin/ejabberdctl
/sbin/runuser -s /bin/bash -p ejabberd -c "$ERL_COMMAND"
At least start/stop could be done via "daemon --user=ejabberd".
I did it just for unification - ejabberd can be started and stopped not only by using init-script, but also by using ejabberdctl (and vice versa). That's why I thought - why not to sed user in one common place, and, since init-script is using ejabberdctl actually, I decided to set uid within it.
Please, tell us your opinion regarding this, and what do you think - should I modify this scheme and explicitly add "--user" parameter in init-script?
(In reply to comment #1)
> I did it just for unification - ejabberd can be started and stopped not only by
> using init-script, but also by using ejabberdctl (and vice versa).
Ah OK. This makes sense. In this case I wouldn't use the "daemon --user" option because then you would need a hack like 'if `id -un` -eq "ejabberd"; then ...' in the ejabberdctl script. I would say your solution is perfectly fine under this circumstances. Because in the end "daemon --user" does nothing else then calling runuser too.
I closed this bug, thanks for clarification!