| 1 |
.\" Hey Emacs! This file is -*- nroff -*- source. |
| 2 |
.\" |
| 3 |
.\" Author: KaiGai Kohei ([email protected]) 2009 |
| 4 |
.TH "avc_netlink_loop" "3" "30 Mar 2009" "" "SELinux API documentation" |
| 5 |
.SH "NAME" |
| 6 |
avc_netlink_open, avc_netlink_close, avc_netlink_acquire_fd, |
| 7 |
avc_netlink_release_fd, avc_netlink_check_nb, avc_netlink_loop \- SELinux |
| 8 |
netlink processing |
| 9 |
. |
| 10 |
.SH "SYNOPSIS" |
| 11 |
.B #include <selinux/selinux.h> |
| 12 |
.br |
| 13 |
.B #include <selinux/avc.h> |
| 14 |
.sp |
| 15 |
.BI "int avc_netlink_open(int " blocking ");" |
| 16 |
.sp |
| 17 |
.B void avc_netlink_close(void); |
| 18 |
.sp |
| 19 |
.B int avc_netlink_acquire_fd(void); |
| 20 |
.sp |
| 21 |
.B void avc_netlink_release_fd(void); |
| 22 |
.sp |
| 23 |
.B void avc_netlink_loop(void); |
| 24 |
.sp |
| 25 |
.B int avc_netlink_check_nb(void); |
| 26 |
. |
| 27 |
.SH "DESCRIPTION" |
| 28 |
These functions enable applications to handle notification of SELinux events |
| 29 |
via netlink. The userspace AVC normally checks for netlink messages on each |
| 30 |
call to |
| 31 |
.BR avc_has_perm (3). |
| 32 |
Applications may wish to override this behavior and check for notification |
| 33 |
separately, for example in a |
| 34 |
.BR select (2) |
| 35 |
loop. These functions also permit netlink monitoring without requiring a |
| 36 |
call to |
| 37 |
.BR avc_open (3). |
| 38 |
|
| 39 |
.BR avc_netlink_open () |
| 40 |
opens a netlink socket to receive SELinux notifications. The socket |
| 41 |
descriptor is stored internally; use |
| 42 |
.BR avc_netlink_acquire_fd (3) |
| 43 |
to take ownership of it in application code. The |
| 44 |
.I blocking |
| 45 |
argument controls whether the O_NONBLOCK flag is set on the socket descriptor. |
| 46 |
.BR avc_open (3) |
| 47 |
calls this function internally, specifying non-blocking behavior. |
| 48 |
|
| 49 |
.BR avc_netlink_close () |
| 50 |
closes the netlink socket. This function is called automatically by |
| 51 |
.BR avc_destroy (3). |
| 52 |
|
| 53 |
.BR avc_netlink_acquire_fd () |
| 54 |
returns the netlink socket descriptor number and informs the userspace AVC |
| 55 |
not to check the socket descriptor automatically on calls to |
| 56 |
.BR avc_has_perm (3). |
| 57 |
|
| 58 |
.BR avc_netlink_release_fd () |
| 59 |
returns control of the netlink socket to the userspace AVC, re-enabling |
| 60 |
automatic processing of notifications. |
| 61 |
|
| 62 |
.BR avc_netlink_check_nb () |
| 63 |
checks the netlink socket for pending messages and processes them. |
| 64 |
Callbacks for policyload and enforcing changes will be called; |
| 65 |
see |
| 66 |
.BR selinux_set_callback (3). |
| 67 |
This function does not block. |
| 68 |
|
| 69 |
.BR avc_netlink_loop () |
| 70 |
enters a loop blocking on the netlink socket and processing messages as they |
| 71 |
are received. This function will not return unless an error occurs on |
| 72 |
the socket, in which case the socket is closed. |
| 73 |
. |
| 74 |
.SH "RETURN VALUE" |
| 75 |
.BR avc_netlink_acquire_fd () |
| 76 |
returns a non-negative file descriptor number on success. Other functions |
| 77 |
with a return value return zero on success. On error, \-1 is returned and |
| 78 |
.I errno |
| 79 |
is set appropriately. |
| 80 |
. |
| 81 |
.SH "SEE ALSO" |
| 82 |
.BR avc_open (3), |
| 83 |
.BR selinux_set_callback (3), |
| 84 |
.BR selinux (8) |