diff --git a/tests/keys/Makefile b/tests/keys/Makefile
new file mode 100644
index 0000000..d3793db
--- /dev/null
+++ b/tests/keys/Makefile
@@ -0,0 +1,7 @@
+TARGETS = keyctl keyctl_relabel keyring_service request_keys
+LDLIBS += -lselinux -lkeyutils
+
+all: $(TARGETS)
+
+clean:
+ rm -f $(TARGETS)
diff --git a/tests/keys/keyctl.c b/tests/keys/keyctl.c
new file mode 100644
index 0000000..5aff8d8
--- /dev/null
+++ b/tests/keys/keyctl.c
@@ -0,0 +1,188 @@
+#include "keys_common.h"
+
+static void usage(char *progname)
+{
+ fprintf(stderr,
+ "usage: %s [-v]\n"
+ "Where:\n\t"
+ "-v Print information.\n", progname);
+ exit(-1);
+}
+
+int main(int argc, char *argv[])
+{
+ int opt, nr, result;
+ unsigned int timeout = 5;
+ char *context, *keycreate_con, type[20], desc[30];
+ char r_con[256];
+ bool verbose = false;
+ key_serial_t retrieved, search, link, compute,
+ private, prime, base, test_key;
+ struct keyctl_dh_params params;
+
+ while ((opt = getopt(argc, argv, "v")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose = true;
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ result = getcon(&context);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain process context\n");
+ exit(1);
+ }
+ if (verbose)
+ printf("Process context:\n\t%s\n", context);
+
+ result = getkeycreatecon(&keycreate_con);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain keycreate context\n");
+ exit(2);
+ }
+ if (verbose)
+ printf("Current keycreate context:\n\t%s\n", keycreate_con);
+ free(keycreate_con);
+
+ /* Set context requires key { create } and process { setkeycreate } */
+ result = setkeycreatecon(context);
+ if (result < 0) {
+ fprintf(stderr, "Failed setkeycreatecon(): %s\n",
+ strerror(errno));
+ exit(3);
+ }
+ if (verbose)
+ printf("Set keycreate context:\n\t%s\n", context);
+ free(context);
+
+ result = getkeycreatecon(&keycreate_con);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain keycreate context\n");
+ exit(4);
+ }
+ if (verbose)
+ printf("New keycreate context:\n\t%s\n", keycreate_con);
+ free(keycreate_con);
+
+ /*
+ * Add three keys to the KEY_SPEC_PROCESS_KEYRING as these will be
+ * required by the keyctl(KEYCTL_DH_COMPUTE, ..) function.
+ * These require key { create write } permissions.
+ */
+ private = add_key("user", "private", payload, strlen(payload),
+ KEY_SPEC_PROCESS_KEYRING);
+ if (private < 0) {
+ fprintf(stderr, "Failed add_key(private): %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ prime = add_key("user", "prime", payload, strlen(payload),
+ KEY_SPEC_PROCESS_KEYRING);
+ if (prime < 0) {
+ fprintf(stderr, "Failed add_key(prime): %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ base = add_key("user", "base", payload, strlen(payload),
+ KEY_SPEC_PROCESS_KEYRING);
+ if (base < 0) {
+ fprintf(stderr, "Failed add_key(base): %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ if (verbose) {
+ printf("Private key ID: 0x%x\n", private);
+ printf("Prime key ID: 0x%x\n", prime);
+ printf("Base key ID: 0x%x\n", base);
+ }
+
+ /* Requires key { search }. From kernel 5.3 requires { link } */
+ retrieved = request_key("user", "private", NULL,
+ KEY_SPEC_PROCESS_KEYRING);
+ if (retrieved < 0) {
+ fprintf(stderr, "Failed to request 'private' key: %s\n",
+ strerror(errno));
+ exit(6);
+ }
+
+ /* Requires key { search } */
+ search = keyctl(KEYCTL_SEARCH, KEY_SPEC_PROCESS_KEYRING,
+ "user", "base", 0);
+ if (search < 0) {
+ fprintf(stderr, "Failed to find 'base' key: %s\n",
+ strerror(errno));
+ exit(7);
+ }
+
+ /* Requires key { view } */
+ result = keyctl(KEYCTL_GET_SECURITY, private, r_con, sizeof(r_con));
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain 'private' key context: %s\n",
+ strerror(errno));
+ exit(8);
+ }
+
+ if (verbose) {
+ printf("Requested 'private' key ID: 0x%x\n", retrieved);
+ printf("Searched 'base' key ID: 0x%x\n", search);
+ printf("Searched 'base' key context:\n\t%s\n", r_con);
+ }
+
+ /* Compute DH key, only obtain the length for test, not the key. */
+ params.priv = private;
+ params.prime = prime;
+ params.base = base;
+
+ /* Requires key { create read write } */
+ compute = keyctl(KEYCTL_DH_COMPUTE, ¶ms, NULL, 0, 0);
+ if (compute < 0) {
+ fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
+ strerror(errno));
+ exit(9);
+ }
+ if (verbose)
+ printf("KEYCTL_DH_COMPUTE key ID size: %d\n", compute);
+
+ /* Requires key { write link } */
+ link = keyctl(KEYCTL_LINK, base, KEY_SPEC_PROCESS_KEYRING);
+ if (link < 0) {
+ fprintf(stderr, "Failed KEYCTL_LINK: %s\n",
+ strerror(errno));
+ exit(10);
+ }
+ if (verbose)
+ printf("Link key ID: 0x%x\n", KEY_SPEC_PROCESS_KEYRING);
+
+ /* Requires key { setattr } */
+ link = keyctl(KEYCTL_SET_TIMEOUT, base, timeout);
+ if (link < 0) {
+ fprintf(stderr, "Failed KEYCTL_SET_TIMEOUT: %s\n",
+ strerror(errno));
+ exit(11);
+ }
+ if (verbose) {
+ test_key = keyctl(KEYCTL_DESCRIBE, base, r_con, sizeof(r_con));
+ if (test_key < 0) {
+ fprintf(stderr, "Failed KEYCTL_DESCRIBE: %s\n",
+ strerror(errno));
+ exit(11);
+ }
+ result = sscanf(r_con, "%[^;];%d;%d;%x;%s",
+ type, &nr, &nr, &nr, desc);
+ if (result < 0) {
+ fprintf(stderr, "Failed sscanf(): %s\n",
+ strerror(errno));
+ exit(11);
+ }
+ printf("Set %d second timeout on key Type: '%s' Description: '%s'\n",
+ timeout, type, desc);
+ }
+
+ return 0;
+}
diff --git a/tests/keys/keyctl_relabel.c b/tests/keys/keyctl_relabel.c
new file mode 100644
index 0000000..7bab510
--- /dev/null
+++ b/tests/keys/keyctl_relabel.c
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <keyutils.h>
+#include <selinux/selinux.h>
+
+static void usage(char *progname)
+{
+ fprintf(stderr,
+ "usage: %s [-v] newcon\n"
+ "Where:\n\t"
+ "-v Print information.\n\t"
+ "newcon New keyring context.\n", progname);
+ exit(-1);
+}
+
+int main(int argc, char *argv[])
+{
+ int opt, result;
+ char *context, *keycreate_con;
+ char r_con[256];
+ bool verbose = false;
+ key_serial_t newring;
+
+ while ((opt = getopt(argc, argv, "v")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose = true;
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ if (optind >= argc)
+ usage(argv[0]);
+
+ result = getcon(&context);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain process context\n");
+ exit(1);
+ }
+ if (verbose)
+ printf("Process context: %s\n", context);
+ free(context);
+
+ result = setkeycreatecon(argv[optind]);
+ if (result < 0) {
+ fprintf(stderr, "Failed setkeycreatecon(): %s\n",
+ strerror(errno));
+ exit(2);
+ }
+
+ result = getkeycreatecon(&keycreate_con);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain keycreate context\n");
+ exit(3);
+ }
+ if (verbose)
+ printf("New keycreate context: %s\n", keycreate_con);
+ free(keycreate_con);
+
+ newring = add_key("keyring", "my-keyring", NULL, 0,
+ KEY_SPEC_PROCESS_KEYRING);
+ if (newring < 0) {
+ fprintf(stderr, "Failed to add new keyring: %s\n",
+ strerror(errno));
+ exit(4);
+ }
+
+ result = keyctl(KEYCTL_GET_SECURITY, newring, r_con, sizeof(r_con));
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain key context: %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ if (strcmp(argv[optind], r_con)) {
+ fprintf(stderr, "Relabel error - expected: %s got: %s\n",
+ argv[optind], r_con);
+ exit(6);
+ }
+
+ if (verbose) {
+ printf("'my-keyring' key ID: 0x%x\n", newring);
+ printf("'my-keyring' context:\n\t%s\n", r_con);
+ }
+
+ return 0;
+}
diff --git a/tests/keys/keyring_service.c b/tests/keys/keyring_service.c
new file mode 100644
index 0000000..e5dcab0
--- /dev/null
+++ b/tests/keys/keyring_service.c
@@ -0,0 +1,166 @@
+#include "keys_common.h"
+
+static void usage(char *progname)
+{
+ fprintf(stderr,
+ "usage: %s [-v] newdomain program\n"
+ "Where:\n\t"
+ "newdomain Type for new domain.\n\t"
+ "program Program to be exec'd.\n\t"
+ "-v Print information.\n", progname);
+ exit(-1);
+}
+
+int main(int argc, char **argv)
+{
+ int opt, pid, result, status;
+ bool verbose;
+ char *context_s, *request_keys_argv[4] = { NULL };
+ context_t context;
+ key_serial_t private, prime, base, newring;
+
+ verbose = false;
+
+ while ((opt = getopt(argc, argv, "v")) != -1) {
+ switch (opt) {
+ case 'v':
+ verbose = true;
+ request_keys_argv[2] = strdup("-v");
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ if (argc - optind != 2)
+ usage(argv[0]);
+
+ if (verbose)
+ printf("%s process information:\n", argv[0]);
+
+ result = getcon(&context_s);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain process context\n");
+ exit(1);
+ }
+ if (verbose)
+ printf("\tProcess context:\n\t\t%s\n", context_s);
+
+ /* Set context requires process { setkeycreate } and key { create } */
+ result = setkeycreatecon(context_s);
+ if (result < 0) {
+ fprintf(stderr, "Failed setkeycreatecon(): %s\n",
+ strerror(errno));
+ exit(3);
+ }
+ if (verbose)
+ printf("\tSet keycreate context:\n\t\t%s\n", context_s);
+
+ context = context_new(context_s);
+ if (!context) {
+ fprintf(stderr, "Unable to create context structure\n");
+ exit(2);
+ }
+ free(context_s);
+
+ if (context_type_set(context, argv[optind])) {
+ fprintf(stderr, "Unable to set new type\n");
+ exit(3);
+ }
+
+ context_s = context_str(context);
+ if (!context_s) {
+ fprintf(stderr, "Unable to obtain new context string\n");
+ exit(4);
+ }
+ if (verbose)
+ printf("\t%s process context will transition to:\n\t\t%s\n",
+ argv[optind], context_s);
+
+ /*
+ * This sets up the environment the for 'request_keys' service when it
+ * calls: keyctl(KEYCTL_SESSION_TO_PARENT)
+ */
+ newring = keyctl(KEYCTL_JOIN_SESSION_KEYRING, "test-session");
+ if (newring < 0) {
+ fprintf(stderr, "Failed KEYCTL_JOIN_SESSION_KEYRING,: %s\n",
+ strerror(errno));
+ exit(5);
+ }
+ if (verbose)
+ printf("\tKEYCTL_JOIN_SESSION_KEYRING newkey ID: 0x%x\n",
+ newring);
+
+ private = add_key("user", "private", payload, strlen(payload),
+ KEY_SPEC_SESSION_KEYRING);
+ if (private < 0) {
+ fprintf(stderr, "Failed add_key(private): %s\n",
+ strerror(errno));
+ exit(6);
+ }
+
+ prime = add_key("user", "prime", payload, strlen(payload),
+ KEY_SPEC_SESSION_KEYRING);
+ if (prime < 0) {
+ fprintf(stderr, "Failed add_key(prime): %s\n",
+ strerror(errno));
+ exit(6);
+ }
+
+ base = add_key("user", "base", payload, strlen(payload),
+ KEY_SPEC_SESSION_KEYRING);
+ if (base < 0) {
+ fprintf(stderr, "Failed add_key(base): %s\n",
+ strerror(errno));
+ exit(6);
+ }
+ if (verbose) {
+ printf("\tAdded 'private' key ID: 0x%x\n", private);
+ printf("\tAdded 'prime' key ID: 0x%x\n", prime);
+ printf("\tAdded 'base' key ID: 0x%x\n", base);
+ }
+
+ pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "fork failed: %s\n", strerror(errno));
+ exit(9);
+ } else if (pid == 0) {
+ signal(SIGTRAP, SIG_IGN);
+ request_keys_argv[0] = strdup(argv[optind + 1]);
+ request_keys_argv[1] = strdup(context_s);
+ if (verbose)
+ printf("\tExec parameters:\n\t\t%s\n\t\t%s\n\t\t%s\n",
+ request_keys_argv[0],
+ request_keys_argv[1],
+ request_keys_argv[2]);
+
+ execv(request_keys_argv[0], request_keys_argv);
+ fprintf(stderr, "execv of: %s failed: %s\n",
+ request_keys_argv[0], strerror(errno));
+ exit(10);
+ }
+
+ pid = wait(&status);
+ if (pid < 0) {
+ fprintf(stderr, "wait() failed: %s\n", strerror(errno));
+ exit(11);
+ }
+
+ if (WIFEXITED(status)) {
+ fprintf(stderr, "%s exited with status: %d\n",
+ argv[optind + 1], WEXITSTATUS(status));
+ exit(WEXITSTATUS(status));
+ }
+
+ if (WIFSIGNALED(status)) {
+ fprintf(stderr, "%s terminated by signal: %d\n",
+ argv[optind + 1], WTERMSIG(status));
+ fprintf(stderr,
+ "..This is consistent with a %s permission denial - check the audit log.\n",
+ argv[optind + 1]);
+ exit(12);
+ }
+
+ fprintf(stderr, "Unexpected exit status 0x%x\n", status);
+ exit(-1);
+}
diff --git a/tests/keys/keys_common.h b/tests/keys/keys_common.h
new file mode 100644
index 0000000..df15280
--- /dev/null
+++ b/tests/keys/keys_common.h
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <sys/wait.h>
+#include <keyutils.h>
+#include <selinux/selinux.h>
+#include <selinux/context.h>
+
+/* This is used as the payload for each add_key() */
+static const char payload[] =
+ " -----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDN4FHsPjlJf03r9KfNt1Ma9/D6\nQDEiR/cfhZrNUPgHRresult+E4dj52VJSonPFJ6HaLlUi5pZq2t1LqPNrMfFKCNn12m+\nWw4aduBJM7u1RUPSNxrlfDAJZkdtNALOO/ds3U93hZrxOYNetzbnjILDu5JT1nbI\n4aC60SkdlCw1TxmvXwIDAQAB\n-----END PUBLIC KEY-----\n";
diff --git a/tests/keys/request_keys.c b/tests/keys/request_keys.c
new file mode 100644
index 0000000..43b20d9
--- /dev/null
+++ b/tests/keys/request_keys.c
@@ -0,0 +1,138 @@
+#include "keys_common.h"
+
+int main(int argc, char **argv)
+{
+ int result, nr;
+ unsigned int timeout = 5;
+ char r_con[512], type[20], desc[30], *context;
+ bool verbose = false;
+ key_serial_t private, prime, base, compute, test_key;
+ struct keyctl_dh_params params;
+
+ /*
+ * There are two parameters passed:
+ * 1 - The security context for setcon(3)
+ * 2 - Verbose mode
+ */
+ if (argv[2] != NULL)
+ verbose = true;
+
+ if (verbose)
+ printf("%s process information:\n", argv[0]);
+
+ /*
+ * Use setcon() as policy will not allow multiple type_transition
+ * statements using the same target with different process types.
+ */
+ result = setcon(argv[1]);
+ if (result < 0) {
+ fprintf(stderr, "setcon() failed to set process context: %s\n",
+ argv[1]);
+ exit(1);
+ }
+
+ result = getcon(&context);
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain process context\n");
+ exit(2);
+ }
+ if (verbose)
+ printf("\tProcess context:\n\t\t%s\n", context);
+
+ free(context);
+
+ /*
+ * Join this session to the parent as ./keyring_service executed:
+ * keyctl(KEYCTL_JOIN_SESSION_KEYRING, "test-session")
+ *
+ * Requires key { link }
+ */
+ test_key = keyctl(KEYCTL_SESSION_TO_PARENT);
+ if (test_key < 0) {
+ fprintf(stderr, "Failed KEYCTL_SESSION_TO_PARENT: %s\n",
+ strerror(errno));
+ exit(3);
+ }
+
+ /* Requires key { view } */
+ result = keyctl(KEYCTL_GET_SECURITY, KEY_SPEC_SESSION_KEYRING,
+ r_con, sizeof(r_con));
+ if (result < 0) {
+ fprintf(stderr, "Failed to obtain parent session context: %s\n",
+ strerror(errno));
+ exit(4);
+ }
+ if (verbose)
+ printf("\tJoined session to parent. Parent keyring context:\n\t\t%s\n",
+ r_con);
+
+ /* Requires key { search write }. From kernel 5.3 requires { link } */
+ private = request_key("user", "private", NULL,
+ KEY_SPEC_SESSION_KEYRING);
+ if (private < 0) {
+ fprintf(stderr, "Failed to request 'private' key: %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ prime = request_key("user", "prime", NULL, KEY_SPEC_SESSION_KEYRING);
+ if (prime < 0) {
+ fprintf(stderr, "Failed to request 'prime' key: %s\n",
+ strerror(errno));
+ exit(5);
+ }
+
+ base = request_key("user", "base", NULL, KEY_SPEC_SESSION_KEYRING);
+ if (base < 0) {
+ fprintf(stderr, "Failed to request 'base' key: %s\n",
+ strerror(errno));
+ exit(5);
+ }
+ if (verbose) {
+ printf("\tRequested 'private' key ID: 0x%x\n", private);
+ printf("\tRequested 'prime' key ID: 0x%x\n", prime);
+ printf("\tRequested 'base' key ID: 0x%x\n", base);
+ }
+
+ /* Requires key { setattr } */
+ test_key = keyctl(KEYCTL_SET_TIMEOUT, base, timeout);
+ if (test_key < 0) {
+ fprintf(stderr, "Failed KEYCTL_SET_TIMEOUT: %s\n",
+ strerror(errno));
+ exit(6);
+ }
+ if (verbose) {
+ test_key = keyctl(KEYCTL_DESCRIBE, base, r_con, sizeof(r_con));
+ if (test_key < 0) {
+ fprintf(stderr, "Failed KEYCTL_DESCRIBE: %s\n",
+ strerror(errno));
+ exit(7);
+ }
+ result = sscanf(r_con, "%[^;];%d;%d;%x;%s",
+ type, &nr, &nr, &nr, desc);
+ if (result < 0) {
+ fprintf(stderr, "Failed sscanf(): %s\n",
+ strerror(errno));
+ exit(7);
+ }
+ printf("\tSet %d second timeout on key Type: '%s' Description: '%s'\n",
+ timeout, type, desc);
+ }
+
+ /* Compute DH key, only obtain the length for test, not the key. */
+ params.priv = private;
+ params.prime = prime;
+ params.base = base;
+
+ /* Requires key { read write } */
+ compute = keyctl(KEYCTL_DH_COMPUTE, ¶ms, NULL, 0, 0);
+ if (compute < 0) {
+ fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
+ strerror(errno));
+ exit(8);
+ }
+ if (verbose)
+ printf("\tKEYCTL_DH_COMPUTE key ID size: %d\n", compute);
+
+ exit(0);
+}
diff --git a/tests/keys/test b/tests/keys/test
new file mode 100755
index 0000000..2dafb17
--- /dev/null
+++ b/tests/keys/test
@@ -0,0 +1,109 @@
+#!/usr/bin/perl
+use Test::More;
+
+BEGIN {
+ $basedir = $0;
+ $basedir =~ s|(.*)/[^/]*|$1|;
+
+ $test_count = 17;
+
+ # allow info to be shown during tests
+ $v = $ARGV[0];
+ if ($v) {
+ if ( $v ne "-v" ) {
+ plan skip_all => "Invalid option (use -v)";
+ }
+ }
+ else {
+ $v = " ";
+ }
+
+ # From kernel 5.3 request_key() requires { link } not { search } perm
+ $kvercur = `uname -r`;
+ chomp($kvercur);
+ $kverminstream = "5.3";
+ $test_link_53 = 0;
+
+ $result = `$basedir/../kvercmp $kvercur $kverminstream`;
+ if ( $result > 0 ) {
+ $test_link_53 = 1;
+ }
+
+ plan tests => $test_count;
+}
+
+print "Test key class permissions\n";
+$result = system "runcon -t test_key_t $basedir/keyctl $v";
+ok( $result eq 0 );
+
+$result = system "runcon -t test_no_setkeycreate_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 3 );
+
+$result = system "runcon -t test_key_no_create_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 3 );
+
+$result = system "runcon -t test_key_no_write_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 5 );
+
+$result = system "runcon -t test_key_no_search_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 6 );
+
+$result = system "runcon -t test_key_no_view_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 8 );
+
+$result = system "runcon -t test_key_no_read_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 9 );
+
+$result = system "runcon -t test_key_no_link_t $basedir/keyctl $v 2>&1";
+if ($test_link_53) {
+ ok( $result >> 8 eq 6 );
+}
+else {
+ ok( $result >> 8 eq 10 );
+}
+
+$result = system "runcon -t test_key_no_setattr_t $basedir/keyctl $v 2>&1";
+ok( $result >> 8 eq 11 );
+
+print "Change keyring context\n";
+$result = system
+"runcon -t test_key_t $basedir/keyctl_relabel $v system_u:system_r:test_newcon_key_t:s0";
+ok( $result eq 0 );
+
+print "Test permission checks between a keyring created by another process\n";
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_t $basedir/request_keys 2>&1"
+);
+ok( $result eq 0 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_link_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 3 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_write_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 5 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_view_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 4 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_search_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 5 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_setattr_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 6 );
+
+$result = system(
+"runcon -t test_keyring_service_t $basedir/keyring_service $v test_request_keys_no_read_t $basedir/request_keys 2>&1"
+);
+ok( $result >> 8 eq 8 );
+
+exit;