summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2014-07-01 00:12:41 +0900
committerPádraig Brady <P@draigBrady.com>2014-07-01 15:45:53 +0100
commite4081e44e0dcc4bfe11d0da0ae47518df087349d (patch)
treeabb29dd2a28dc5cd95d3511ba25251cea2ed6af7 /src
parent3e89d5bb9b34861c17cd23f5efd8323eec4f0bab (diff)
downloadcoreutils-e4081e44e0dcc4bfe11d0da0ae47518df087349d.tar.xz
chcon: use security_check_context() for context validation
context_new() and _free() are used for checking validity of a specified context. libselinux provides security_check_context for this purpose so use it. Note that context_new() can fail for a valid context - e.g. ENOMEM. * src/chcon.c (main): Use security_check_context().
Diffstat (limited to 'src')
-rw-r--r--src/chcon.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/chcon.c b/src/chcon.c
index 32d4b0f8b..8c18167ff 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -555,13 +555,10 @@ main (int argc, char **argv)
}
else
{
- context_t context;
specified_context = argv[optind++];
- context = context_new (specified_context);
- if (!context)
- error (EXIT_FAILURE, 0, _("invalid context: %s"),
+ if (security_check_context (specified_context) < 0)
+ error (EXIT_FAILURE, errno, _("invalid context: %s"),
quotearg_colon (specified_context));
- context_free (context);
}
if (reference_file && component_specified)