Skip to contentSkip to conversation

avc_init & avc_open

DISCUSSION Joe Nall 2 participants 7 messages Apr 21, 2008 SELinux security module

lore
Share & tools
lore

Joe Nall

author
#0 lore raw

I have a userspace object manager that I would like to specify the log callback and the enforcing mode for simultaneously. The enforcing mode can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

joe

#1 lore raw
Quoted 4 lines · Joe Nall

I have a userspace object manager that I would like to specify the log callback and the enforcing mode for simultaneously. The enforcing mode can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#2 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 4 lines · Joe Nall

I have a userspace object manager that I would like to specify the log callback and the enforcing mode for simultaneously. The enforcing mode can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Do you know what rawhide rpm SELABEL_CB_LOG and friends might be in? They are not in <selinux/selinux.h> or in /usr/include on a current rawhide with libselinux-devel.

joe

#3 lore raw
Quoted 11 lines · Joe Nall
Quoted 9 lines · Stephen Smalley
Quoted 6 lines · Joe Nall

I have a userspace object manager that I would like to specify the log
callback and the enforcing mode for simultaneously. The enforcing mode
can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

Quoted 6 lines
Quoted 2 lines

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Do you know what rawhide rpm SELABEL_CB_LOG and friends might be in? They are not in <selinux/selinux.h> or in /usr/include on a current rawhide with libselinux-devel.

Looks like the man page is wrong - it is SELINUX_CB_LOG, not SELABEL_

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Joe Nall
Quoted 9 lines · Stephen Smalley
Quoted 6 lines · Joe Nall

I have a userspace object manager that I would like to specify the log
callback and the enforcing mode for simultaneously. The enforcing mode
can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Do you know what rawhide rpm SELABEL_CB_LOG and friends might be in? They are not in <selinux/selinux.h> or in /usr/include on a current rawhide with libselinux-devel.

Looks like the man page is wrong - it is SELINUX_CB_LOG, not SELABEL_

I've fixed this upstream.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#5 lore raw
In reply to Stephen Smalley
Quoted 13 lines · Stephen Smalley
Quoted 11 lines · Joe Nall
Quoted 9 lines · Stephen Smalley
Quoted 6 lines · Joe Nall

I have a userspace object manager that I would like to specify the log
callback and the enforcing mode for simultaneously. The enforcing mode
can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Do you know what rawhide rpm SELABEL_CB_LOG and friends might be in? They are not in <selinux/selinux.h> or in /usr/include on a current rawhide with libselinux-devel.

Looks like the man page is wrong - it is SELINUX_CB_LOG, not SELABEL_

I'm confused by the syntax. The following is extracted from my C++ code that is calling avc_open.

int avc_log(int ltype, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
...
}
...
static struct avc_entry_ref avcref;
if (!avc_initialized)
{
struct selinux_opt opts[] = { { AVC_OPT_SETENFORCE, (char *)1 } }; if (avc_open(opts, 1) < 0)

       ...

avc_entry_ref_init(&avcref); selinux_set_callback(SELINUX_CB_LOG, (selinux_callback)&avc_log); avc_initialized = 1;
}

Context.C: In member function ‘int Context::operator>=(const Context&)’:
Context.C:317: error: no matching function for call to ‘selinux_callback::selinux_callback(int (&)(int, const char*, ...))’ /usr/include/selinux/selinux.h:142: note: candidates are: selinux_callback::selinux_callback()
/usr/include/selinux/selinux.h:142: note: selinux_callback::selinux_callback(const selinux_callback&)
Context.C:318: error: conversion from ‘int (*)(int, const char*, ...)’ to non-scalar type ‘selinux_callback’ requested

What is the right syntax? Got a good example of selinux_set_callback usage?

joe

#6 lore raw
Quoted 37 lines · Joe Nall
Quoted 13 lines · Stephen Smalley
Quoted 11 lines · Joe Nall
Quoted 9 lines · Stephen Smalley
Quoted 6 lines · Joe Nall

I have a userspace object manager that I would like to specify the log
callback and the enforcing mode for simultaneously. The enforcing mode
can be set with avc_open (no man page) and the callbacks with avc_init(3). What is the best strategy?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

avc_init() was the old interface. selinux_set_callback() + avc_open() is the new interface.

Do you know what rawhide rpm SELABEL_CB_LOG and friends might be in? They are not in <selinux/selinux.h> or in /usr/include on a current rawhide with libselinux-devel.

Looks like the man page is wrong - it is SELINUX_CB_LOG, not SELABEL_

I'm confused by the syntax. The following is extracted from my C++ code that is calling avc_open.

int avc_log(int ltype, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
...
}
...
static struct avc_entry_ref avcref;
if (!avc_initialized)

Quoted 6 lines
    {
    struct selinux_opt opts[] = { { AVC_OPT_SETENFORCE, (char *)1 } };
    if (avc_open(opts, 1) < 0)
        ...
    avc_entry_ref_init(&avcref);
    selinux_set_callback(SELINUX_CB_LOG, (selinux_callback)&avc_log);

should be (union selinux_callback)&avc_log

Quoted 13 lines
    avc_initialized = 1;
    }

Context.C: In member function ‘int Context::operator>=(const Context&)’:
Context.C:317: error: no matching function for call to ‘selinux_callback::selinux_callback(int (&)(int, const char*, ...))’ /usr/include/selinux/selinux.h:142: note: candidates are:
selinux_callback::selinux_callback() /usr/include/selinux/selinux.h:142: note:
selinux_callback::selinux_callback(const selinux_callback&) Context.C:318: error: conversion from ‘int (*)(int, const char*, ...)’ to non-scalar type ‘selinux_callback’ requested

Quoted 2 lines

What is the right syntax? Got a good example of selinux_set_callback usage?

setfiles.c

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.