libselinux/getconlist: report failures
Check the given context a priori, to print a more user friendly message, opposed to a generic following get_ordered_context_list/_with_level failure. Notify the user about failures of get_ordered_context_list/_with_level, so no-context-found and a failure results are distinguishable. Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
0451adebdf
commit
9cc6b5cf40
|
@ -58,8 +58,14 @@ int main(int argc, char **argv)
|
|||
free(level);
|
||||
return 2;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
cur_context = argv[optind + 1];
|
||||
if (security_check_context(cur_context) != 0) {
|
||||
fprintf(stderr, "Given context '%s' is invalid.\n", cur_context);
|
||||
free(level);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the list and print it */
|
||||
if (level)
|
||||
|
@ -72,6 +78,11 @@ int main(int argc, char **argv)
|
|||
for (i = 0; list[i]; i++)
|
||||
puts(list[i]);
|
||||
freeconary(list);
|
||||
} else {
|
||||
fprintf(stderr, "get_ordered_context_list%s failure: %d(%s)\n",
|
||||
level ? "_with_level" : "", errno, strerror(errno));
|
||||
free(level);
|
||||
return 4;
|
||||
}
|
||||
|
||||
free(level);
|
||||
|
|
Loading…
Reference in New Issue