Re: [Patch 2/2 v2] libsemanage: maintain disable dontaudit state between handle commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-07-06 at 14:07 -0400, Stephen Smalley wrote:
> On Mon, 2009-07-06 at 13:37 -0400, Christopher Pardy wrote:
> > Currently any changes made to the policy which require committing a handle cause dontaudit rules to be disabled. This is confusing, and frustrating for users who want to edit policy with dontaudit rules turned off. This patch allows semanage to remember the last state of the dontaudit rules and apply them as default whenever a handle is created. Additionally other functions may check for the file semanage creates to determine if dontaudit rules are turned on. This knowledge can be useful for tools like SETroubleshoot which may want to change their behavior depending on the state of the dontaudit rules.
> > 
> > Stephen Smalley: This get function has the correct functionality as it
> > gets the actual value that will be committed to memory.
> > 
> > Signed-off-by: Christopher Pardy <cpardy@xxxxxxxxxx>
> > 
> > ---
> >  libsemanage/include/semanage/handle.h |    3 +++
> >  libsemanage/src/handle.c              |   34 ++++++++++++++++++++++++++++++++--
> >  libsemanage/src/libsemanage.map       |    2 +-
> >  libsemanage/src/semanage_store.c      |    1 +
> >  libsemanage/src/semanage_store.h      |    1 +
> >  5 files changed, 38 insertions(+), 3 deletions(-)
> > 
> 
> > diff -urpN selinux.orig2/libsemanage/src/handle.c selinux/libsemanage/src/handle.c
> > --- selinux.orig2/libsemanage/src/handle.c	2009-07-01 21:15:17.288238017 -0400
> > @@ -59,6 +62,14 @@ semanage_handle_t *semanage_handle_creat
> >  		goto err;
> >  	sepol_msg_set_callback(sh->sepolh, semanage_msg_relay_handler, sh);
> >  
> > +	/*set the disable dontaudit flag to system defaults*/
> > +	path = semanage_fname(SEMANAGE_DISABLE_DONTAUDIT);
> > +
> > +	if (access(path,F_OK) == 0)
> > +		semanage_set_disable_dontaudit(sh,1);
> > +	else
> > +		semanage_set_disable_dontaudit(sh,0);
> > +
> 
> No.  This will try to create or remove the file within the active policy
> store without even having started a transaction.  And it is completely a
> waste as you are merely re-creating or removing the file based on
> whether it already exists.  And you aren't allowed to touch the store
> from handle_create; the caller hasn't yet connected to the store via
> semanage_connect().  And technically all interaction with the file store
> ought to happen from the direct_api functions.

Suggestion:  In semanage_direct_connect(), test for the existence of the
flag file via access(), and then call sepol_set_disable_dontaudit() to
set the in-memory variable without touching any files.  Do not call
semanage_set_disable_dontaudit() at all from libsemanage, only from your
application.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with
the words "unsubscribe selinux" without quotes as the message.

[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux