summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/capabilities/validate_cap.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/capabilities/validate_cap.c')
-rw-r--r--tools/testing/selftests/capabilities/validate_cap.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/tools/testing/selftests/capabilities/validate_cap.c b/tools/testing/selftests/capabilities/validate_cap.c
index dd3c45f7b23c..694cd73d4493 100644
--- a/tools/testing/selftests/capabilities/validate_cap.c
+++ b/tools/testing/selftests/capabilities/validate_cap.c
@@ -1,5 +1,4 @@
#include <cap-ng.h>
-#include <err.h>
#include <linux/capability.h>
#include <stdbool.h>
#include <string.h>
@@ -7,6 +6,8 @@
#include <sys/prctl.h>
#include <sys/auxv.h>
+#include "../kselftest.h"
+
#ifndef PR_CAP_AMBIENT
#define PR_CAP_AMBIENT 47
# define PR_CAP_AMBIENT_IS_SET 1
@@ -25,8 +26,10 @@ static bool bool_arg(char **argv, int i)
return false;
else if (!strcmp(argv[i], "1"))
return true;
- else
- errx(1, "wrong argv[%d]", i);
+ else {
+ ksft_exit_fail_msg("wrong argv[%d]\n", i);
+ return false;
+ }
}
int main(int argc, char **argv)
@@ -39,7 +42,7 @@ int main(int argc, char **argv)
*/
if (argc != 5)
- errx(1, "wrong argc");
+ ksft_exit_fail_msg("wrong argc\n");
#ifdef HAVE_GETAUXVAL
if (getauxval(AT_SECURE))
@@ -51,23 +54,26 @@ int main(int argc, char **argv)
capng_get_caps_process();
if (capng_have_capability(CAPNG_EFFECTIVE, CAP_NET_BIND_SERVICE) != bool_arg(argv, 1)) {
- printf("[FAIL]\tWrong effective state%s\n", atsec);
+ ksft_print_msg("Wrong effective state%s\n", atsec);
return 1;
}
+
if (capng_have_capability(CAPNG_PERMITTED, CAP_NET_BIND_SERVICE) != bool_arg(argv, 2)) {
- printf("[FAIL]\tWrong permitted state%s\n", atsec);
+ ksft_print_msg("Wrong permitted state%s\n", atsec);
return 1;
}
+
if (capng_have_capability(CAPNG_INHERITABLE, CAP_NET_BIND_SERVICE) != bool_arg(argv, 3)) {
- printf("[FAIL]\tWrong inheritable state%s\n", atsec);
+ ksft_print_msg("Wrong inheritable state%s\n", atsec);
return 1;
}
if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, CAP_NET_BIND_SERVICE, 0, 0, 0) != bool_arg(argv, 4)) {
- printf("[FAIL]\tWrong ambient state%s\n", atsec);
+ ksft_print_msg("Wrong ambient state%s\n", atsec);
return 1;
}
- printf("[OK]\tCapabilities after execve were correct\n");
+ ksft_print_msg("%s: Capabilities after execve were correct\n",
+ "validate_cap:");
return 0;
}
an Corbet <corbet@lwn.net> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2016-07-20docs: deprecate kernel-doc-nano-HOWTO.txtJonathan Corbet Now that the new Sphinx world order is taking over, the information in kernel-doc-nano-HOWTO.txt is outmoded. I hate to remove it altogether, since it's one of those files that people expect to find. But we can add a warning and fix all the other pointers to it. Reminded-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2016-01-25Documentation/CodingStyle: add space before parenthesis in example macroThomas Gardner Signed-off-by: Thomas Gardner <tmg@fastmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2016-01-11Documentation: fix typo in CodingStyleManuel Pégourié-Gonnard Simple typo: "it" for "is". Signed-off-by: Manuel Pégourié-Gonnard <mpg@elzevir.fr> Cc: Trivial Patch Monkey <trivial@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2015-07-10Documentation: CodingStyle: remove broken links in the References sectionOlivier C. Larocque Remove 2 broken links for programming reference books in Appendix I. After a lookup on an Internet archives web site, it seems that these links have been broken for around 3 months. We can then assume that they will not be back up and safely remove them from the documentation. Signed-off-by: Olivier C. Larocque <olivier.c.larocque@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2015-05-07Documentation/CodingStyle: fix example macro parenthesis imbalanceBaruch Siach Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Andrew Morton <akpm@linux-foundation.org> Fixes: f2027543b9 ('documentation: update CodingStyle on local variables naming in macros') Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2015-04-18Merge tag 'docs-for-linus' of git://git.lwn.net/linux-2.6Linus Torvalds Pull documentation updates from Jonathan Corbet: "Numerous fixes, the overdue removal of the i2o docs, some new Chinese translations, and, hopefully, the README fix that will end the flow of identical patches to that file" * tag 'docs-for-linus' of git://git.lwn.net/linux-2.6: (34 commits) Documentation/memcg: update memcg/kmem status Documentation: blackfin: Makefile: Typo building issue Documentation/vm/pagemap.txt: correct location of page-types tool Documentation/memory-barriers.txt: typo fix doc: Add guest_nice column to example output of `cat /proc/stat' Documentation/kernel-parameters: Move "eagerfpu" to its right place Documentation: gpio: Update ACPI part of the document to mention _DSD docs/completion.txt: Various tweaks and corrections doc: completion: context, scope and language fixes Documentation:Update Documentation/zh_CN/arm64/memory.txt Documentation:Update Documentation/zh_CN/arm64/booting.txt Documentation: Chinese translation of arm64/legacy_instructions.txt DocBook media: fix broken EIA hyperlink Documentation: tweak the maintainers entry README: Change gzip/bzip2 to xz compression format README: Update version number reference doc:pci: Fix typo in Documentation/PCI Documentation: drm: Use '->' when describing access through pointers. Documentation: Remove mentioning of block barriers Documentation/email-clients.txt: Fix one grammar mistake, add extra info about TB ... 2015-04-17documentation: update CodingStyle on local variables naming in macrosBartosz Golaszewski Describe proper naming convention for local variables in macros resembling functions. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 2015-02-27Documentation/CodingStyle: improve text layoutPavel Kretov Try to make coding style documentation look a bit more readable and consistent with the following: - indent every code example in C to first tab-stop; - surround every code example with empty lines, both top and bottom; - remove empty lines where text looked way too spare; - do not indent examples in elisp and kconfig; - do not do any non-whitespace changes. Signed-off-by: Pavel Kretov <firegurafiku@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2015-02-27Documentation/CodingStyle: fix tab-spaces mixturePavel Kretov Coding style description has a irregular mixture of tabs and spaces in two places which is bad by any means and can possibly hurt somebody's sense of beauty. Signed-off-by: Pavel Kretov <firegurafiku@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2015-01-28CodingStyle: enable emacs display of trailing whitespaceAlison Chaiken Suggest to developers who use emacs that they turn on the instantaneous trailing-whitespace warning feature. Signed-off-by: Alison Chaiken <alison_chaiken@mentor.com> [jc: untabified to match its surroundings] Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2014-12-02CodingStyle: add some more error handling guidelinesDan Carpenter I added a paragraph on choosing label names, and updated the example code to use a better label name. I also cleaned up the example code to more modern style by moving the allocation out of the initializer and changing the NULL check. Perhaps the most common type of error handling bug in the kernel is "one err bugs". CodingStyle already says that we should "avoid nesting" by using error labels and one err style error handling tends to have multiple indent levels, so this was already bad style. But I've added a new paragraph explaining how to avoid one err bugs by using multiple error labels which is, hopefully, more clear. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> [jc: added GFP_KERNEL to kmalloc() call] Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2014-11-03CodingStyle: Add a chapter on conditional compilationJosh Triplett Document several common practices and conventions regarding conditional compilation, most notably the preference for ifdefs in headers rather than .c files. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> 2014-08-26CodingStyle: fix a minor typoRaymond L. Rivera There was a minor typo in the CodingStyle document where the word 'section' had been spelled as 'secton'. Signed-off-by: Raymond L. Rivera <ray.l.rivera@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> 2014-06-04Documentation: expand/clarify debug documentationDan Streetman The pr_debug() and related debug print macros all differ from the normal pr_XXX() macros, in that the normal ones print unconditionally, while the debug macros are compiled out unless DEBUG is defined or CONFIG_DYNAMIC_DEBUG is set. This isn't obvious, and the only way to find this out is either to review the actual printk.h code or to read CodingStyle, and the message there doesn't highlight the fact. Change Documentation/CodingStyle to clearly indicate that pr_debug() and related debug printing macros behave differently than all other pr_XXX() macros, and attempt to clarify when and where the different debug printing methods might be used. Add short comment to printk.h above the pr_XXX() macros indicating that while these macros print unconditionally, pr_debug() does not. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Cc: Joe Perches <joe@perches.com> Cc: Fabian Frederick <fabf@skynet.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 2013-07-03Documentation/CodingStyle: allow multiple return statements per functionDan Carpenter A surprising number of newbies interpret this section to mean that only one return statement is allowed per function. Part of the problem is that the "one return statement per function" rule is an actual style guideline that people are used to from other projects. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Eduardo Valentin <eduardo.valentin@ti.com> Cc: Rob Landley <rob@landley.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 2013-01-11Documentation: remove depends on CONFIG_EXPERIMENTALKees Cook The CONFIG_EXPERIMENTAL config item has not carried much meaning for a while now and is almost always enabled by default. As agreed during the Linux kernel summit, remove it from any "depends on" lines in Kconfigs. CC: Rob Landley <rob@landley.net> CC: Jiri Kosina <jkosina@suse.cz> CC: Masanari Iida <standby24x7@gmail.com> CC: Jason Wessel <jason.wessel@windriver.com> CC: Richard L Maliszewski <richard.l.maliszewski@intel.com> CC: Gang Wei <gang.wei@intel.com> CC: Shane Wang <shane.wang@intel.com> CC: Harry Wei <harryxiyou@gmail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Jason Wessel <jason.wessel@windriver.com> 2012-10-06CodingStyle: add networking specific block comment styleJoe Perches The block comment style in net/ and drivers/net is non-standard. Document it. Signed-off-by: Joe Perches <joe@perches.com> Cc: "Allan, Bruce W" <bruce.w.allan@intel.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 2012-05-31CodingStyle: add kmalloc_array() to memory allocatorsXi Wang Add the new kmalloc_array() to the list of general-purpose memory allocators in chapter 14. Signed-off-by: Xi Wang <xi.wang@gmail.com> Acked-by: Jesper Juhl <jj@chaosbits.net> Acked-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 2012-03-30Documentation: CodingStyle: add inline assembly guidelinesJosh Triplett Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>