From: Stephen Smalley <sds@tycho.nsa.gov>
To: kuangjiou <kuangjiou@huawei.com>,
"selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>
Subject: Re: Got Segmentation fault when use avc_context_to_sid() funtion!! can anyone help me?
Date: Thu, 06 Nov 2014 08:05:51 -0500 [thread overview]
Message-ID: <545B722F.3020401@tycho.nsa.gov> (raw)
In-Reply-To: <60ABE64B4BE4AC45964F1A967BA76CB2BBDFFB@SZXEML507-MBX.china.huawei.com>
On 11/06/2014 07:44 AM, kuangjiou wrote:
> Hello,everyone!
> I am learning how to use the selinux userspace apps recent.And I got Segmentation fault when I use the avc_context_to_sid() funtion, dose anyone know how to resolve this problem? Thank you very much!
>
> The following is my testing code with avc_context_to_sid() funtion
>
> #include <selinux/selinux.h>
> #include <selinux/avc.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main()
> {
> const char *scon = "system_u:object_r:unconfined_t";
> security_id_t sid;
> sid->ctx = scon;
> sid->refcnt = 28;
>
> avc_context_to_sid(scon, &sid);
>
> return 0;
> }
Must be preceded by a call to avc_init() or avc_open(). In current
libselinux, that is asserted on entry to the function.
However, I'd encourage you to consider using selinux_check_access()
instead for SELinux userspace object managers; it internally handles
calling avc_init() and avc_context_to_sid() as well as mapping class and
permission strings to numbers, making it much easier to use the AVC from
userspace. We have been using it in the Android userspace.
next prev parent reply other threads:[~2014-11-06 13:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 12:44 Got Segmentation fault when use avc_context_to_sid() funtion!! can anyone help me? kuangjiou
2014-11-06 13:05 ` Stephen Smalley [this message]
2014-11-06 13:25 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=545B722F.3020401@tycho.nsa.gov \
--to=sds@tycho.nsa.gov \
--cc=kuangjiou@huawei.com \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.