Improve mkdir -Z error reporting.

The most likely reason for setfscreatecon to fail is that you don't have
permission, and that's reported by the write return EACCES. There isn't
really a "bad" context; they're just strings.

Before:

  $ adb shell mkdir -Z x y
  mkdir: bad -Z 'x'

After:

  $ adb shell mkdir -Z x y
  mkdir: -Z 'x' failed: Permission denied

Other than this, the ToT mkdir works fine with SELinux.

diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c
index 438e38e..95bdf33 100644
--- a/toys/posix/mkdir.c
+++ b/toys/posix/mkdir.c
@@ -43,7 +43,7 @@ void mkdir_main(void)

   if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z))
     if (0>lsm_set_create(TT.arg_context))
-      error_exit("bad -Z '%s'", TT.arg_context);
+      perror_exit("-Z '%s' failed", TT.arg_context);

   if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777);
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to