<div dir="ltr">ping. this is still wrong and has been copy & pasted another two times. new patch covering all three:<div><br></div><div>Improve -Z error reporting.</div><div><br></div><div><div style="font-size:12.8000001907349px">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.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Before:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"> $ adb shell <span class="">mkdir</span> -Z x y</div><div style="font-size:12.8000001907349px">  <span class="">mkdir</span>: bad -Z 'x'</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">After:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div> $ adb shell <span class="">mkdir</span> -Z x y</div><div></div><div>  <span class="">mkdir</span>: -Z 'x' failed: Permission denied</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Other than this, the ToT <span class="">mkdir</span> works fine with SELinux.</div></div><div><br></div><div><div>diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c</div><div>index d6cd65c..39073fa 100644</div><div>--- a/toys/lsb/mknod.c</div><div>+++ b/toys/lsb/mknod.c</div><div>@@ -52,7 +52,7 @@ void mknod_main(void)</div><div> </div><div>  if (toys.optflags & FLAG_Z)</div><div>   if (-1 == lsm_set_create(TT.arg_context))</div><div>-    error_exit("bad -Z '%s'", TT.arg_context);</div><div>+    perror_exit("-Z '%s' failed", TT.arg_context);</div><div>  if (mknod(*toys.optargs, mode|modes[type], makedev(major, minor)))</div><div>   perror_exit("%s", *toys.optargs);</div><div> }</div><div>diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c<br></div><div>index 438e38e..95bdf33 100644</div><div>--- a/toys/posix/mkdir.c</div><div>+++ b/toys/posix/mkdir.c</div><div>@@ -43,7 +43,7 @@ void mkdir_main(void)</div><div> </div><div>  if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z))</div><div>   if (0>lsm_set_create(TT.arg_context))</div><div>-    error_exit("bad -Z '%s'", TT.arg_context);</div><div>+    perror_exit("-Z '%s' failed", TT.arg_context);</div><div> </div><div>  if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777);</div><div> </div><div>diff --git a/toys/posix/mkfifo.c b/toys/posix/mkfifo.c</div><div>index 7bc43cc..9aa3a3a 100644</div><div>--- a/toys/posix/mkfifo.c</div><div>+++ b/toys/posix/mkfifo.c</div><div>@@ -43,7 +43,7 @@ void mkfifo_main(void)</div><div> </div><div>  if (CFG_MKFIFO_Z && (toys.optflags&FLAG_Z))</div><div>   if (0>lsm_set_create(TT.Z))</div><div>-    error_exit("bad -Z '%s'", TT.Z);</div><div>+    perror_exit("-Z '%s' failed", TT.Z);</div><div> </div><div>  for (s = toys.optargs; *s; s++)</div><div>   if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg("%s", *s);</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 30, 2015 at 1:40 PM, enh <span dir="ltr"><<a href="mailto:enh@google.com" target="_blank">enh@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Improve mkdir -Z error reporting.<div><br></div><div>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.</div><div><br></div><div>Before:</div><div><br></div><div> $ adb shell mkdir -Z x y</div><div><div> mkdir: bad -Z 'x'</div></div><div><br></div><div>After:</div><div><br></div><div><div> $ adb shell mkdir -Z x y</div><div></div><div> mkdir: -Z 'x' failed: Permission denied</div></div><div><br></div><div>Other than this, the ToT mkdir works fine with SELinux.</div><div><br></div><div><div>diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c</div><div>index 438e38e..95bdf33 100644</div><div>--- a/toys/posix/mkdir.c</div><div>+++ b/toys/posix/mkdir.c</div><div>@@ -43,7 +43,7 @@ void mkdir_main(void)</div><div> </div><div>  if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z))</div><div>   if (0>lsm_set_create(TT.arg_context))</div><div>-    error_exit("bad -Z '%s'", TT.arg_context);</div><div>+    perror_exit("-Z '%s' failed", TT.arg_context);</div><div> </div><div>  if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777);</div><div> </div></div><div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Elliott Hughes - <a href="http://who/enh" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" target="_blank">http://jessies.org/~enh/</a><br>Android native code/tools questions? Mail me/drop by/add me as a reviewer.</div>
</div>