[systemd-devel] Started process not attach to its related service.

Lennart Poettering lennart at poettering.net
Tue Nov 22 12:03:14 UTC 2016


On Tue, 22.11.16 09:39, Benoit SCHMID (Benoit.Schmid at unige.ch) wrote:

> Good morning,
> 
> This topic is related to the systemd-sysv-generator thread submited by
> my colleague.
> I post it with another subject becaus I prefer to create another thread
> as it would make too many different questions in the same thread.
> 
> 1. I have defined a service.
> It is started by systemd on boot:
> # systemctl status sap
> ● sap.service - SYSV: Startup/Shutdown SAP and Oracle Listener
>    Loaded: loaded (/etc/rc.d/init.d/sap; bad; vendor preset: disabled)
>    Active: active (exited) since Tue 2016-11-22 09:22:23 CET; 3min 7s ago
>      Docs: man:systemd-sysv-generator(8)
>   Process: 14124 ExecStart=/etc/rc.d/init.d/sap start (code=exited,
> status=0/SUCCESS)
> 
> 2. This service starts /etc/rc.d/init.d/sap start.
> % cat /etc/rc.d/init.d/sap
> #!/bin/bash
> ...
> case "$1" in
>     start)
>         # Oracle listener and instance startup
>         echo -n "Starting Oracle Listener: "
>         su - $ORA_OWNR -c "env ORACLE_HOME=/oracle/XXX/12102
> /oracle/XXX/12102/bin/lsnrctl start LISTENER_XXX"

You are using "su" to change users here. "su" does considerably more
than that though: it opens a new login session. Use util-linux'
"setpriv" which is the tool to use if all you want to do is drop
privs...

That said, I'd always recommend stopping using SysV services all together.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list