[Toybox] integration of SMACK

Rob Landley rob at landley.net
Tue May 19 21:26:16 PDT 2015


On Mon, May 18, 2015 at 2:58 AM, José Bollo <jobol at nonadev.net> wrote:
> Le mercredi 13 mai 2015 à 14:15 -0700, enh a écrit :
> (snip)
>>
>>         To be correct, from my cp man page, I see that "-p" is same as
>>         "--preserve=mode,ownership,timestamps" and that
>>         "--preserve[=ATTR_LIST]"
>>         accepts the attributes: "context",  "links", "xattr", "mode",
>>         "ownership", "timestamps", and  "all".
>>
>>
>> coincidentally, someone on Android asked for cp --preserve this week.
>> internal bug 21121352. i'll get around to that at some point if no one
>> beats me to it (but not before Google I/O).
>
> Hi Elliott, hi all,
>
> I worked a lot last Wednesday on implementing "cp --preserve". It works
> quiet well now on my side. I planned to finalize it this Monday.
>
> So let me know if you already made some effort on your side.
>
> I need advise about how to write a good test of cp for toybox

I threw this on the todo list but if somebody beats me to it...

Speaking of which, here are some notes from yesterday (results already
checked in) about banging on ls:

-----

The S_ISLNK() stanza is an abomination. I realize that you need to do this,
but let's be honest: this is a bug workaround for kernel problems stemming
from the fact that these APIs haven't been updated since the 1990's.
Either there should be a getfileconat() or fgetfilecon() should work
on O_PATH filehandles.

Why is |O_NOATIME commented out here? The man page says it was introduced in
2.6.8, git annotate says openat() was introduced 2.6.16 (which was 2006
and we depend on posix-2008...)

Ah, I see:

  #ifdef __USE_GNU
  # define O_DIRECT        040000 /* Direct disk access.  */
  # define O_NOATIME     01000000 /* Do not set atime.  */
  # define O_PATH       010000000 /* Resolve pathname but do not open file.  */
  #endif

Once again, the linux kernel is not a part of the gnu project and the glibc
developers didn't get that. Right, easy to fix up in portability.h.

And why does this have O_NONBLOCK? We're recursing down into directories
using openat() without that. Does this mean something in an selinux or
smack context?

The label: and totals: behavior is funky.

"ls -s" and "ls -sd *" differ, the first prints totals: the second doesn't
  because total: is only on contents of a directory - posix

Fix fix fix...

-----

And here are notes from Jose's socket update patch:

I don't think this covers all the cases. What about symlink to a socket
without -L, or symlink to a file we haven't got permission to open? In
those cases we need the "follow symlink but do it by path because O_PATH
is broken" version?

Also, if O_PATH worked, we wouldn't need O_NONBLOCK to avoid triggering
automounting. (Is automounting still a thing in 2015?)

P.S. I pulled your "other fix" by taking the actual commit, see
git f25d4954a786.

Rob

 1432095976.0


More information about the Toybox mailing list