|
Chris PeBenito |
473ea7 |
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
Chris PeBenito |
473ea7 |
.\"
|
|
Chris PeBenito |
473ea7 |
.\" Author: Eamon Walsh (ewalsh@epoch.ncsc.mil) 2004
|
|
Chris PeBenito |
473ea7 |
.TH "avc_has_perm" "3" "27 May 2004" "" "SE Linux API documentation"
|
|
Chris PeBenito |
473ea7 |
.SH "NAME"
|
|
Chris PeBenito |
473ea7 |
avc_has_perm, avc_has_perm_noaudit, avc_audit, avc_entry_ref_init \- obtain and audit SELinux access decisions.
|
|
Chris PeBenito |
473ea7 |
.SH "SYNOPSIS"
|
|
Chris PeBenito |
473ea7 |
.B #include <selinux/selinux.h>
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.B #include <selinux/avc.h>
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.BI "void avc_entry_ref_init(struct avc_entry_ref *" aeref ");"
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.BI "int avc_has_perm(security_id_t " ssid ", security_id_t " tsid ,
|
|
Chris PeBenito |
473ea7 |
.in +\w'int avc_has_perm('u
|
|
Chris PeBenito |
473ea7 |
.BI "security_class_t " tclass ", access_vector_t " requested ,
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "struct avc_entry_ref *" aeref ", void *" auditdata ");"
|
|
Chris PeBenito |
473ea7 |
.in
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.BI "int avc_has_perm_noaudit(security_id_t " ssid ", security_id_t " tsid ,
|
|
Chris PeBenito |
473ea7 |
.in +\w'int avc_has_perm('u
|
|
Chris PeBenito |
473ea7 |
.BI "security_class_t " tclass ", access_vector_t " requested ,
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "struct avc_entry_ref *" aeref ", struct av_decision *" avd ");"
|
|
Chris PeBenito |
473ea7 |
.in
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.BI "void avc_audit(security_id_t " ssid ", security_id_t " tsid ,
|
|
Chris PeBenito |
473ea7 |
.in +\w'void avc_audit('u
|
|
Chris PeBenito |
473ea7 |
.BI "security_class_t " tclass ", access_vector_t " requested ,
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "struct av_decision *" avd ", int " result ", void *" auditdata ");"
|
|
Chris PeBenito |
473ea7 |
.in
|
|
Chris PeBenito |
473ea7 |
.SH "DESCRIPTION"
|
|
Chris PeBenito |
473ea7 |
.B avc_entry_ref_init
|
|
Chris PeBenito |
473ea7 |
initializes an
|
|
Chris PeBenito |
473ea7 |
.B avc_entry_ref
|
|
Chris PeBenito |
473ea7 |
structure; see
|
|
Chris PeBenito |
473ea7 |
.B ENTRY REFERENCES
|
|
Chris PeBenito |
473ea7 |
below. This function may be implemented as a macro.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm
|
|
Chris PeBenito |
473ea7 |
checks whether the
|
|
Chris PeBenito |
473ea7 |
.I requested
|
|
Chris PeBenito |
473ea7 |
permissions are granted
|
|
Chris PeBenito |
473ea7 |
for subject SID
|
|
Chris PeBenito |
473ea7 |
.IR ssid
|
|
Chris PeBenito |
473ea7 |
and target SID
|
|
Chris PeBenito |
473ea7 |
.IR tsid ,
|
|
Chris PeBenito |
473ea7 |
interpreting the permissions
|
|
Chris PeBenito |
473ea7 |
based on
|
|
Chris PeBenito |
473ea7 |
.I tclass
|
|
Chris PeBenito |
473ea7 |
and updating
|
|
Chris PeBenito |
473ea7 |
.IR aeref ,
|
|
Chris PeBenito |
473ea7 |
if non-NULL, to refer to a cache entry with the resulting decision. The granting or denial of permissions is audited in accordance with the policy. The
|
|
Chris PeBenito |
473ea7 |
.I auditdata
|
|
Chris PeBenito |
473ea7 |
parameter is for supplemental auditing; see
|
|
Chris PeBenito |
473ea7 |
.B avc_audit
|
|
Chris PeBenito |
473ea7 |
below.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm_noaudit
|
|
Chris PeBenito |
473ea7 |
behaves as
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm
|
|
Chris PeBenito |
473ea7 |
without producing an audit message. The access decision is returned in
|
|
Chris PeBenito |
473ea7 |
.I avd
|
|
Chris PeBenito |
473ea7 |
and can be passed to
|
|
Chris PeBenito |
473ea7 |
.B avc_audit
|
|
Chris PeBenito |
473ea7 |
explicitly.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.B avc_audit
|
|
Chris PeBenito |
473ea7 |
produces an audit message for the access query represented by
|
|
Chris PeBenito |
473ea7 |
.IR ssid ,
|
|
Chris PeBenito |
473ea7 |
.IR tsid ,
|
|
Chris PeBenito |
473ea7 |
.IR tclass ,
|
|
Chris PeBenito |
473ea7 |
and
|
|
Chris PeBenito |
473ea7 |
.IR requested ,
|
|
Chris PeBenito |
473ea7 |
with a decision represented by
|
|
Chris PeBenito |
473ea7 |
.IR avd .
|
|
Chris PeBenito |
473ea7 |
Pass the value returned by
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm_noaudit
|
|
Chris PeBenito |
473ea7 |
as
|
|
Chris PeBenito |
473ea7 |
.IR result .
|
|
Chris PeBenito |
473ea7 |
The
|
|
Chris PeBenito |
473ea7 |
.I auditdata
|
|
Chris PeBenito |
473ea7 |
parameter is passed to the user-supplied
|
|
Chris PeBenito |
473ea7 |
.B func_audit
|
|
Chris PeBenito |
473ea7 |
callback and can be used to add supplemental information to the audit message; see
|
|
Chris PeBenito |
473ea7 |
.BR avc_init (3).
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "ENTRY REFERENCES"
|
|
Chris PeBenito |
473ea7 |
Entry references can be used to speed cache performance for repeated queries on the same subject and target. The userspace AVC will check the
|
|
Chris PeBenito |
473ea7 |
.I aeref
|
|
Chris PeBenito |
473ea7 |
argument, if supplied, before searching the cache on a permission query. After a query is performed,
|
|
Chris PeBenito |
473ea7 |
.I aeref
|
|
Chris PeBenito |
473ea7 |
will be updated to reference the cache entry for that query. A subsequent query on the same subject and target will then have the decision at hand without having to walk the cache.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
After declaring an
|
|
Chris PeBenito |
473ea7 |
.B avc_entry_ref
|
|
Chris PeBenito |
473ea7 |
structure, use
|
|
Chris PeBenito |
473ea7 |
.B avc_entry_ref_init
|
|
Chris PeBenito |
473ea7 |
to initialize it before passing it to
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm
|
|
Chris PeBenito |
473ea7 |
or
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm_noaudit
|
|
Chris PeBenito |
473ea7 |
for the first time.
|
|
Chris PeBenito |
473ea7 |
Using an uninitialized structure will produce undefined behavior.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "RETURN VALUE"
|
|
Chris PeBenito |
473ea7 |
If requested permissions are granted, zero is returned. If requested permissions are denied or an error occured, \-1 is returned and
|
|
Chris PeBenito |
473ea7 |
.I errno
|
|
Chris PeBenito |
473ea7 |
is set appropriately.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
In permissive mode, zero will be returned and
|
|
Chris PeBenito |
473ea7 |
.I errno
|
|
Chris PeBenito |
473ea7 |
unchanged even if permissions were denied.
|
|
Chris PeBenito |
473ea7 |
.B avc_has_perm
|
|
Chris PeBenito |
473ea7 |
will still produce an audit message in this case.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "ERRORS"
|
|
Chris PeBenito |
473ea7 |
.TP
|
|
Chris PeBenito |
473ea7 |
.B EACCES
|
|
Chris PeBenito |
473ea7 |
A requested permission was denied.
|
|
Chris PeBenito |
473ea7 |
.TP
|
|
Chris PeBenito |
473ea7 |
.B EINVAL
|
|
Chris PeBenito |
473ea7 |
The
|
|
Chris PeBenito |
473ea7 |
.I tclass
|
|
Chris PeBenito |
473ea7 |
and/or the security contexts referenced by
|
|
Chris PeBenito |
473ea7 |
.I ssid
|
|
Chris PeBenito |
473ea7 |
and
|
|
Chris PeBenito |
473ea7 |
.I tsid
|
|
Chris PeBenito |
473ea7 |
are not recognized by the currently loaded policy.
|
|
Chris PeBenito |
473ea7 |
.TP
|
|
Chris PeBenito |
473ea7 |
.B ENOMEM
|
|
Chris PeBenito |
473ea7 |
An attempt to allocate memory failed.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "NOTES"
|
|
Chris PeBenito |
473ea7 |
Internal errors encountered by the userspace AVC may cause certain values of
|
|
Chris PeBenito |
473ea7 |
.I errno
|
|
Chris PeBenito |
473ea7 |
to be returned unexpectedly. For example, netlink socket errors may produce
|
|
Chris PeBenito |
473ea7 |
.B EACCES
|
|
Chris PeBenito |
473ea7 |
or
|
|
Chris PeBenito |
473ea7 |
.BR EINVAL .
|
|
Chris PeBenito |
473ea7 |
Make sure that userspace object managers are granted appropriate access to
|
|
Chris PeBenito |
473ea7 |
netlink by the policy.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "AUTHOR"
|
|
Chris PeBenito |
473ea7 |
Eamon Walsh <ewalsh@epoch.ncsc.mil>
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "SEE ALSO"
|
|
Chris PeBenito |
473ea7 |
.BR avc_init (3),
|
|
Chris PeBenito |
473ea7 |
.BR avc_context_to_sid (3),
|
|
Chris PeBenito |
473ea7 |
.BR avc_cache_stats (3),
|
|
Chris PeBenito |
473ea7 |
.BR avc_add_callback (3),
|
|
Chris PeBenito |
473ea7 |
.BR security_compute_av (3)
|