[Toybox] [PATCH] Improve mkdir -Z error reporting.
enh
enh at google.com
Tue Jun 30 15:04:00 PDT 2015
ping. this is still wrong and has been copy & pasted another two times. new
patch covering all three:
Improve -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/lsb/mknod.c b/toys/lsb/mknod.c
index d6cd65c..39073fa 100644
--- a/toys/lsb/mknod.c
+++ b/toys/lsb/mknod.c
@@ -52,7 +52,7 @@ void mknod_main(void)
if (toys.optflags & FLAG_Z)
if (-1 == lsm_set_create(TT.arg_context))
- error_exit("bad -Z '%s'", TT.arg_context);
+ perror_exit("-Z '%s' failed", TT.arg_context);
if (mknod(*toys.optargs, mode|modes[type], makedev(major, minor)))
perror_exit("%s", *toys.optargs);
}
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);
diff --git a/toys/posix/mkfifo.c b/toys/posix/mkfifo.c
index 7bc43cc..9aa3a3a 100644
--- a/toys/posix/mkfifo.c
+++ b/toys/posix/mkfifo.c
@@ -43,7 +43,7 @@ void mkfifo_main(void)
if (CFG_MKFIFO_Z && (toys.optflags&FLAG_Z))
if (0>lsm_set_create(TT.Z))
- error_exit("bad -Z '%s'", TT.Z);
+ perror_exit("-Z '%s' failed", TT.Z);
for (s = toys.optargs; *s; s++)
if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg("%s", *s);
On Sat, May 30, 2015 at 1:40 PM, enh <enh at google.com> wrote:
> 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);
>
>
>
--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150630/1e201658/attachment-0003.htm>
More information about the Toybox
mailing list