[Toybox] [toybox] smack support

enh enh at google.com
Sat Sep 19 10:38:32 PDT 2015


On Fri, Sep 18, 2015 at 11:34 PM, Rob Landley <rob at landley.net> wrote:
> On 09/17/2015 04:05 PM, Joya Cruz, Alejandro wrote:
>> Hi Rob,
>>
>> Doing some test between TOYBOX 0.6.0 and Smack I got interested on what
>> is the support that is given to Smack.
>> The most important user related utilitie it might are:
>> ls -Z Show the Smack labels on files. (already on toybox)
>
> I've never been quite sure what the complete todo list is. I got patches
> for ls, mkfifo, mknod, mkdir, id, and cp, but I don't think that's a
> complete list? (Ah, and here's one for stat...)

i've only ever mentioned the ones that Android used to have. ps is the
only one still missing. (we didn't have mkdir -Z before toybox.)

>> any idea when the rest is coming ( if its coming ) ?
>> chsmack:Show and sett all of the Smack attributes on files.
>
> Dig dig dig... Ok I found chsmack, doesn't look too hard to implement?
> (First I've heard of it, though...)
>
>> cp --preserve=xattr: Create a new file with same content and Smack
>> attributes as an existing file.
>
> I have a pending patch for that, I just need to grind far enough down in
> my todo list.
>
>> id and id -Z to show the current process Smack label.
>
> I thought I'd applied that one already?
>
> (Rummage, rummage... yeah the plumbing's there. Did it not work when you
> tried it? I don't have a smack build/test environment. I got a tizen
> emulator working once but didn't have a compiler targeting it...)

id -Z certainly works fine for SELinux.

>> ps -Z show information about processes, including their Smack labels.
>
> I'm about 2/3 of the way through implementing ps, it's fairly high
> priority to get back to but I'm traveling this week. (I want to include
> it in the next release though.)
>
> However, I don't think I ever got a -Z patch for ps? (First I've heard
> of it having -Z, actually...)

yeah, i was waiting until ps was in a somewhat usable state before
worrying about it. my notes:

   ps --- default columns differ; toolbox defaults to showing
everything, filters by name, assumed by scripts?; -t different (=-T?),
-x, -P, -p, -c, --abi; need standard --ppid, -Z.

i hadn't even built toybox ps for a while, but unnecessarily tricksy
code has tripped it up again:

diff --git a/toys/pending/ps.c b/toys/pending/ps.c
index 29111d5..2bd7bcb 100644
--- a/toys/pending/ps.c
+++ b/toys/pending/ps.c
@@ -238,11 +238,12 @@ void ps_main(void)
   TT.width--;

   // find controlling tty, falling back to /dev/tty if none
-  for (i = fd = 0; i < 4; i++) {
+  for (i = 0; i < 4; i++) {
     struct stat st;

-    if (i != 3 || -1 != (i = fd = open("/dev/tty", O_RDONLY))) {
-      if (isatty(i) && !fstat(i, &st)) {
+    fd = i;
+    if (i != 3 || -1 != (fd = open("/dev/tty", O_RDONLY))) {
+      if (isatty(fd) && !fstat(fd, &st)) {
         TT.tty = st.st_rdev;
         break;
       }


> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1442684312.0


More information about the Toybox mailing list