summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2008-10-24 20:30:56 -0700
committerAndrew G. Morgan <morgan@kernel.org>2008-10-24 20:30:56 -0700
commit434e7fcb1d54b798850f2340e86ab85efa11d34a (patch)
tree74629aefad2f197bc4676dc67238e01123af7139
parent248361e809d6f2e64fb63d792ad1b3cb6d4d9bf6 (diff)
downloadlibcap2-434e7fcb1d54b798850f2340e86ab85efa11d34a.tar.gz
No longer need verify-caps since setcap -v performs this operation.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--progs/Makefile4
-rw-r--r--progs/verify-caps.c75
2 files changed, 2 insertions, 77 deletions
diff --git a/progs/Makefile b/progs/Makefile
index ef8f056..a2ebfe4 100644
--- a/progs/Makefile
+++ b/progs/Makefile
@@ -5,10 +5,10 @@ include $(topdir)/Make.Rules
# Programs: all of the examples that we will compile
#
PROGS=getpcaps getcap setcap capsh
-BUILD=$(PROGS) verify-caps
+BUILD=$(PROGS)
ifneq ($(DYNAMIC),yes)
-LDFLAGS += --static
+LDFLAGS += --static
endif
LDLIBS += -lcap
diff --git a/progs/verify-caps.c b/progs/verify-caps.c
deleted file mode 100644
index 2efef17..0000000
--- a/progs/verify-caps.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2008 Andrew G. Morgan <morgan@kernel.org>
- *
- * This is a simple script that attempts to verify a file has
- * a specific set of capabilities associated with it. This
- * code is intended to be a simple prototype for inclusion
- * in package manager applications.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/capability.h>
-
-static int caps_differ(const char *filename, const char *file_caps)
-{
- int cmp;
- cap_t in_effect, reference;
-
- in_effect = cap_get_file(filename);
- reference = cap_from_text(file_caps);
-
- if ((in_effect == NULL) || (reference == NULL)) {
- char *text;
-
- if (in_effect == reference) {
- return 0;
- } else if (in_effect != NULL) {
- text = cap_to_text(in_effect, NULL);
- printf("reference caps (empty) vs. current (%s)\n", text);
- } else {
- text = cap_to_text(reference, NULL);
- printf("reference caps (%s) vs. current (empty)\n", text);
- }
- cap_free(text);
- return 1;
- }
-
- cmp = cap_compare(in_effect, reference);
- if (cmp == 0) {
- return 0;
- } else {
- char *text_ref, *text_current;
-
- text_current = cap_to_text(in_effect, NULL);
- text_ref = cap_to_text(reference, NULL);
-
- printf("reference caps (%s) vs. current (%s) [differ:%s%s%s]\n",
- text_ref, text_current,
- CAP_DIFFERS(cmp, CAP_PERMITTED) ? "p" : "",
- CAP_DIFFERS(cmp, CAP_INHERITABLE) ? "i" : "",
- CAP_DIFFERS(cmp, CAP_EFFECTIVE) ? "e" : "");
-
- cap_free(text_ref);
- cap_free(text_current);
-
- return cmp;
- }
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 3) {
- fprintf(stderr, "usage: %s <filename> <expected-caps>\n", argv[0]);
- exit(1);
- }
-
- if (caps_differ(argv[1], argv[2])) {
- printf("capabilities differ\n");
- exit(1);
- } else {
- printf("capabibilities are as expected\n");
- }
-
- exit(0);
-}