mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
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().
This commit is contained in:
1 parent
3e89d5bb9b
commit
e4081e44e0
1 file changed
+2
-5
+2
-5
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user