<font size=2 face="sans-serif">So I understand the SERVICE_START/STOP
are sent by systemd.  We do have a unit file for systemd as following:</font>
<br>
<br><font size=2 face="sans-serif"> </font><font size=2 face="Monospace">[Unit]</font>
<br><font size=2 face="Monospace">Description=......</font>
<br>
<br><font size=2 face="Monospace">[Service]</font>
<br><font size=2 face="Monospace">Type=forking</font>
<br><font size=2 face="Monospace">WorkingDirectory=/</font><font size=2 color=#2f2f2f face="Monospace"><u>var</u></font><font size=2 face="Monospace">/</font><font size=2 color=#2f2f2f face="Monospace"><u>lib</u></font><font size=2 face="Monospace">/....</font>
<br>
<br><font size=2 face="Monospace">PIDFile=/</font><font size=2 color=#2f2f2f face="Monospace"><u>var</u></font><font size=2 face="Monospace">/run/xxxx.pid</font>
<br>
<br><font size=2 face="Monospace">ExecStart=/</font><font size=2 color=#2f2f2f face="Monospace"><u>usr</u></font><font size=2 face="Monospace">/</font><font size=2 color=#2f2f2f face="Monospace"><u>sbin</u></font><font size=2 face="Monospace">/xxxx</font>
<br>
<br><font size=2 face="Monospace">Restart=always</font>
<br>
<br><font size=2 face="Monospace"># Wait a bit before restarting xxx</font>
<br><font size=2 face="Monospace">RestartSec=5s</font>
<br>
<br><font size=2 face="Monospace"># xxxx kicks the </font><font size=2 color=#2f2f2f face="Monospace"><u>watchdog</u></font><font size=2 face="Monospace">
</font>
<br><font size=2 face="Monospace">WatchdogSec=60</font>
<br>
<br><font size=2 face="Monospace"># If xxxx doesn't signal that it's ready,
consider it failed</font>
<br><font size=2 face="Monospace">TimeoutStartSec=300</font>
<br>
<br><font size=2 face="Monospace"># Time between SIGTERM and SIGKILL on
shutdown</font>
<br><font size=2 face="Monospace">TimeoutStopSec=20</font>
<br>
<br><font size=2 face="Monospace"># Allows calls to sd_notify from main
process</font>
<br><font size=2 face="Monospace">NotifyAccess=main</font>
<br>
<br><font size=2 face="Monospace">StandardInput=null</font>
<br><font size=2 face="Monospace">StandardOutput=journal</font>
<br><font size=2 face="Monospace">StandardError=journal</font>
<br><font size=2 face="Monospace"> </font>
<br><font size=2 face="Monospace">[Install]</font>
<br><font size=2 face="Monospace">WantedBy=</font><font size=2 color=#2f2f2f face="Monospace"><u>multi</u></font><font size=2 face="Monospace">-user.target</font>
<br>
<br>
<br><font size=2 face="Monospace">Would this trigger the creation of the
audit record?  Our application is expected to be up and running all
the time.  But we can shut it down, or</font>
<br><font size=2 face="Monospace">it could be down due to error.  We
want audit record when it is down.  Would TimeoutStopSec=  tag
(don't know if this is the proper name) </font>
<br><font size=2 face="Monospace">does it, or I need other special tag?
 </font>
<br>
<br><font size=2 face="Monospace">Thanks.</font>
<br><font size=2 face="sans-serif"><br>
<br>
 Gisela Cheng   <br>
 giselac@us.ibm.com<br>
</font>
<br><font size=1 color=#800080 face="sans-serif">----- Forwarded by Gisela
Cheng/Poughkeepsie/IBM on 08/05/2014 09:24 AM -----</font>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:      
 </font><font size=1 face="sans-serif">Steve Grubb <sgrubb@redhat.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:      
 </font><font size=1 face="sans-serif">linux-audit@redhat.com</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:      
 </font><font size=1 face="sans-serif">Gisela Cheng/Poughkeepsie/IBM@IBMUS</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:      
 </font><font size=1 face="sans-serif">08/04/2014 04:34 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:    
   </font><font size=1 face="sans-serif">Re: How to define
rule for SERVICE_START/STOP?</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>On Monday, August 04, 2014 03:16:18 PM Gisela Cheng
wrote:<br>
>  We want to use Linux audit type SERVICE_START/STOP for our application<br>
> running as service.<br>
>  But I am not able to find example on how to use auditctl to
define the<br>
> rule.  It seems to me that all the examples are of rules defined
for<br>
> system_calls.<br>
<br>
There are 2 kinds of events. Some are hardwired into the applications (or
<br>
kernel) and they send them if auditing is enabled. The other kind are <br>
discretionary in that the admin defines what to audit. The problem with
the <br>
discretionary rules are that it is from the kernel's point of view. Meaning
<br>
that you only get events as the process transitions through something the
<br>
kernel controls like files or syscalls.<br>
<br>
<br>
> Questions:<br>
>  1.  Can I use audit type SERVICE_START/STOP for my application
runs as<br>
> service?<br>
<br>
The SERVICE_START/STOP command are intended to be sent by the init daemon.
<br>
Systemd already sends these. Upstart could be patched, but if that is done
it <br>
would need to match the layout, order, and formatting of the systemd events.<br>
<br>
> or would it be considered as type USR_CMD?<br>
<br>
USER_CMD is for something like sudo to record what command the user will
be <br>
running.<br>
<br>
>  2.  How do I use auditctl to define rule for SERVICE_START/STOP?
 Can you<br>
> direct/point me to URL/documentation where it is documented?<br>
<br>
It can't define these events because the kernel only sees a process start
or <br>
stop. It has no idea that its a service. Only init can tell the difference.<br>
<br>
-Steve<br>
<br>
</font></tt>