<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1653019836;
        mso-list-type:hybrid;
        mso-list-template-ids:-1634456050 -1017991814 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-font-family:Calibri;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7 ;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7 ;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7 ;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style>
</head>
<body lang="EN-IN" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hi Steve,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Thanks for the reply.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I am actually trying to enable audit events support for an embedded webserver (<a href="https://github.com/openbmc/bmcweb">bmcweb</a>) which implements the DMTF Redfish specification.
 The idea is to use libaudit to generate server operations related audit events. For example
<o:p></o:p></span></p>
<ul style="margin-top:0cm" type="disc">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Authentication related events<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Power on related events<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Code update related events
<o:p></o:p></span></li></ul>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">And the design principle is that all the apps in LF
<a href="https://github.com/openbmc/openbmc">OpenBMC</a> are single threaded & use dbus as our communication model & we use event loops for processing events from dbus. I agree that probably it makes sense to disallow a particular operation If we fail to send
 an event. But can’t we do it without blocking using the event loops ? is there some example of doing that for sending audit events ? As it is a webserver we would want it to as much responsive as possible.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">And also , how much time does the daemon have to wait for a ACK reply ? does it have a time out of some sort ? I understand that the API that we discussed above does the send as
 well as receive part, are there specific API’s for just send & receive separately ? so that I could probably add the file descriptor to the event loop and invoke the receive API whenever we get a reply ACK from the kernel.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Thank,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Manoj<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Steve Grubb <sgrubb@redhat.com><br>
<b>Date: </b>Tuesday, 13 September 2022 at 10:55 PM<br>
<b>To: </b>linux-audit@redhat.com <linux-audit@redhat.com><br>
<b>Cc: </b>ManojKiran Eda <manojkiran.eda@gmail.com><br>
<b>Subject: </b>Re: Query regarding the lib audit-userspace<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">Hello,<br>
<br>
On Tuesday, September 13, 2022 12:53:32 PM EDT Manojkiran Eda wrote:<br>
> I was working on leveraging the libaudit shared library to generate audit<br>
> events from a user space daemon. I have been using the audit_open as well<br>
> as audit_log_acct_message() API’s to send message to the kernel audit<br>
> subsystem. <br>
<br>
audit_log_acct_message()  is meant to send events related to a user's <br>
account. For example, pam and shadow-utils uses it.<br>
<br>
> From the man pages I understand that every message to the<br>
> kernel audit subsystem would get an ACK back.<br>
<br>
Yes. This is to let you know if there was a problem such as lack of <br>
permissions.<br>
<br>
> Now my question is does the daemon[single threaded] consuming this libaudit<br>
> for sending events using audit_log_acct_message() API be blocked until it<br>
> gets an ACK back from the kernel ?<br>
<br>
Yes. In general, sending audit events should be rare.<br>
<br>
> If yes , is there a way to not have the application blocked during this<br>
> period ?<br>
<br>
The requirements that we normally need to adhere to is that if the audit <br>
event fails, then whatever the user was going to do needs to be prevented. If <br>
you really need to keep moving, send the event on it's own thread so that <br>
your application is not waiting. For example, sshd forks the user session so <br>
that it can keep processing other logins. But on that fork, it waits for the <br>
responses to make it easier to tear down the session if sending an audit <br>
event fails.<br>
<br>
Or, another approach would be to write the whole thing down to calling sendto <br>
and then you can wait however you want. I think putting on it's own thread is <br>
simplest. But as I said in the beginning, should there be a problem logging <br>
the event, can you undo whatever the event was for if you keep going?<br>
<br>
-Steve<br>
<br>
<o:p></o:p></span></p>
</div>
</div>
</body>
</html>