All of lore.kernel.org
 help / color / mirror / Atom feed
From: KaiGai Kohei <kaigai@ak.jp.nec.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov, Eamon Walsh <ewalsh@tycho.nsa.gov>,
	Joshua Brindle <jbrindle@tresys.com>,
	Daniel J Walsh <dwalsh@redhat.com>
Subject: Re: PHP/SELinux: libselinux wrappers
Date: Fri, 27 Feb 2009 17:40:24 +0900	[thread overview]
Message-ID: <49A7A6F8.6050802@ak.jp.nec.com> (raw)
In-Reply-To: <49A76BD5.7040902@ak.jp.nec.com>

Today, I updated the PHP/SELinux package as follows:

 http://code.google.com/p/sepgsql/wiki/Memo_PHP_SELinux
 http://code.google.com/p/sepgsql/source/browse/misc/php-selinux/

 - bugfix: selinux_is_enabled() and selinux_mls_is_enabled() returned TRUE
   on errors.
 - cleanup: remove redundant length == 0 checks
 - upgrade: selinux_compute_av(), selinux_compute_create(),
   selinux_compute_relabel() and selinux_compute_member() accept $tclass
   described in text form, such as "file".
 - upgrade: selinux_compute_av() returns a set of associative arrays
   which contain true or false for each permissions.
 - The following functions are added:
   - selinux_file_label_lookup()
   - selinux_media_label_lookup()
   NOTE: Is the selinux_x_label_lookup() necessary?
 - The following functions are removed:
   - selinux_string_to_class()
   - selinux_class_to_string()
   - selinux_string_to_av_perm()
   - selinux_av_perm_to_string()
   - selinux_av_string()
   - selinux_matchpathcon()
   - selinux_lsetfilecon_default()

TODO:
 - Move them into PECL repository. (http://pecl.php.net/)
 - Make a request to merge this package into Fedora project.
   (libselinux-php? php-selinux?)
 - Describe reference manual based on PHP community's manner
   (http://jp.php.net/manual/en/index.php)

Thanks,

KaiGai Kohei wrote:
> KaiGai Kohei wrote:
>>> selinux_getcon() says that it returns false on error.  So false is a
>>> legal string value in PHP?  And you don't mean the string "false", I
>>> presume?  So it can be used in a conditional with the expected effect?
>> I belive we can discriminate between a legal string value and a bool one.
>> This function is available to check either one is returned.
>>   http://jp.php.net/manual/en/function.is-string.php
>>
>> However, it is necessary to note that "false" is casted to empty string
>> when we compare them without special care, like:
>>
>>   $ php -r 'if ("" == false)
>>                 echo "hello!\n";'
>>   hello!
>>
>> I'll confirm PHP developers whether we can consider "false" can be
>> an error condition on functions which return string, or not.
> 
> I was suggested to use "===" operator in the PHP list.
> It requires both of left and right side have same type and value,
> so we can discriminate between legal strings (including empty one)
> and error status.
> 
>   http://jp.php.net/manual/en/language.operators.comparison.php
> 
>>> security classes can be unsigned integers or their own type.
>>> access vectors can be unsigned integers, bitfields, or their own type.
>>> Or we could only deal with security classes and access vectors as
>>> strings and lists of strings respectively for PHP, and map them back and
>>> forth to integers within the wrappers.
>> I think it is good idea.
>>
>> You are saying such an interface, aren't you?
>>
>>   selinux_compute_av("staff_t:staff_r:staff_t",
>>                      "system_u:object_r:shadow_t",
>>                      "file");
>>   It returns an associative array which contains three subarray
>>   named as "allowed", "auditallow", "auditdeny".
> 
> I tried to implement the revised one.
> 
> We can check its result like:
>   $avd = selinux_compute_av(...);
>   $allowed = $avd["allowed"];
>   if ($allowed["read"] && $allowed["getattr"])
>       echo "Readable!\n";
> 
> ------
> $ php -r '$scontext = "staff_u:staff_r:staff_t";
>           $tcontext="system_u:object_r:etc_t";
>           $avd = selinux_compute_av($scontext, $tcontext, "file");
>           var_dump($avd["allowed"]);'
> array(21) {
>   ["ioctl"]=>
>   bool(true)
>   ["read"]=>
>   bool(true)
>   ["write"]=>
>   bool(false)
>   ["create"]=>
>   bool(false)
>   ["getattr"]=>
>   bool(true)
>   ["setattr"]=>
>   bool(false)
>   ["lock"]=>
>   bool(true)
>   ["relabelfrom"]=>
>   bool(false)
>   ["relabelto"]=>
>   bool(false)
>   ["append"]=>
>   bool(false)
>   ["unlink"]=>
>   bool(false)
>   ["link"]=>
>   bool(false)
>   ["rename"]=>
>   bool(false)
>   ["execute"]=>
>   bool(true)
>   ["swapon"]=>
>   bool(false)
>   ["quotaon"]=>
>   bool(false)
>   ["mounton"]=>
>   bool(false)
>   ["execute_no_trans"]=>
>   bool(true)
>   ["entrypoint"]=>
>   bool(false)
>   ["execmod"]=>
>   bool(false)
>   ["open"]=>
>   bool(false)
> }
> 


-- 
OSS Platform Development Division, NEC
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.

      reply	other threads:[~2009-02-27  8:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-09  6:41 PHP/SELinux: libselinux wrappers KaiGai Kohei
2008-09-18  2:25 ` KaiGai Kohei
2009-02-26  6:22 ` KaiGai Kohei
2009-02-26 14:39   ` Stephen Smalley
2009-02-26 14:57     ` Daniel J Walsh
2009-02-26 18:50       ` Joshua Brindle
2009-02-27  2:23         ` KaiGai Kohei
2009-02-27 19:08           ` Daniel J Walsh
2009-03-03  3:37             ` KaiGai Kohei
2009-03-10  7:05               ` KaiGai Kohei
2009-02-27  2:10       ` KaiGai Kohei
2009-02-27  1:56     ` KaiGai Kohei
2009-02-27  4:28       ` KaiGai Kohei
2009-02-27  8:40         ` KaiGai Kohei [this message]

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=49A7A6F8.6050802@ak.jp.nec.com \
    --to=kaigai@ak.jp.nec.com \
    --cc=dwalsh@redhat.com \
    --cc=ewalsh@tycho.nsa.gov \
    --cc=jbrindle@tresys.com \
    --cc=sds@tycho.nsa.gov \
    --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.