From: KaiGai Kohei <kaigai@ak.jp.nec.com>
To: SELinux <selinux@tycho.nsa.gov>
Subject: libselinux APIs should take "const" qualifier?
Date: Fri, 19 Mar 2010 16:52:27 +0900 [thread overview]
Message-ID: <4BA32D3B.9010502@ak.jp.nec.com> (raw)
Right now, security_context_t is an alias of char *, declared in selinux.h.
Various kind of libselinux API takes security_context_t arguments,
however, it is inconvenience in several situations.
For example, the following query is parsed, then delivered to access
control subsystem with the security context as "const char *" cstring.
ALTER TABLE my_tbl SECURITY LABEL TO 'system_u:object_r:sepgsql_table_t:SystemHigh';
const char * <---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In this case, we want to call selinux_trans_to_raw_context() to translate
the given security context into raw format. But it takes security_context_t
argument for the source context, although this pointer is read-only.
In the result, compiler raises warnings because we gave "const char *" pointer
into functions which take security_context_t (= char *).
Any comments?
It seems to me the following functions' prototype should be qualified by
"const".
extern int setcon(*const* security_context_t con);
extern int setexeccon(*const* security_context_t con);
extern int setfscreatecon(*const* security_context_t context);
extern int setkeycreatecon(*const* security_context_t context);
extern int setsockcreatecon(*const* security_context_t context);
extern int security_compute_av(*const* security_context_t scon,
*const* security_context_t tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd);
extern int security_compute_av_flags(*const* security_context_t scon,
*const* security_context_t tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd);
extern int security_compute_create(*const* security_context_t scon,
*const* security_context_t tcon,
security_class_t tclass,
security_context_t * newcon);
extern int security_compute_relabel(*const* security_context_t scon,
*const* security_context_t tcon,
security_class_t tclass,
security_context_t * newcon);
extern int security_compute_member(*const* security_context_t scon,
*const* security_context_t tcon,
security_class_t tclass,
security_context_t * newcon);
extern int security_compute_user(*const* security_context_t scon,
const char *username,
security_context_t ** con);
extern int security_check_context(*const* security_context_t con);
extern int security_canonicalize_context(*const* security_context_t con,
security_context_t * canoncon);
... and all the _raw version.
extern int selinux_trans_to_raw_context(*const* security_context_t trans,
security_context_t * rawp);
extern int selinux_raw_to_trans_context(*const* security_context_t raw,
security_context_t * transp);
--
KaiGai Kohei <kaigai@ak.jp.nec.com>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next reply other threads:[~2010-03-19 7:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-19 7:52 KaiGai Kohei [this message]
2010-03-19 13:32 ` libselinux APIs should take "const" qualifier? Stephen Smalley
2010-03-23 2:56 ` KaiGai Kohei
2010-06-11 6:35 ` KaiGai Kohei
2010-06-14 13:50 ` Steve Lawrence
2010-06-14 20:37 ` Chad Sellers
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=4BA32D3B.9010502@ak.jp.nec.com \
--to=kaigai@ak.jp.nec.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.