summaryrefslogtreecommitdiff
path: root/keyctl.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-02-26 20:27:56 +0000
committerDavid Howells <dhowells@redhat.com>2010-02-26 20:27:56 +0000
commit3a8cc353e0cc88a84f5425bfef1be82933f3646d (patch)
tree7f27338f2a2b865b0eaeccbac928bee8bc25945e /keyctl.c
parentc983bb36ffdb0ac6ad8e34f5446971a9be5d8eb1 (diff)
downloadkeyutils-3a8cc353e0cc88a84f5425bfef1be82933f3646d.tar.gz
Add a keyctl command to get the security label on a key
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'keyctl.c')
-rw-r--r--keyctl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/keyctl.c b/keyctl.c
index dc11805..6b79542 100644
--- a/keyctl.c
+++ b/keyctl.c
@@ -55,6 +55,7 @@ static int act_keyctl_instantiate(int argc, char *argv[]);
static int act_keyctl_pinstantiate(int argc, char *argv[]);
static int act_keyctl_negate(int argc, char *argv[]);
static int act_keyctl_timeout(int argc, char *argv[]);
+static int act_keyctl_security(int argc, char *argv[]);
const struct command commands[] = {
{ act_keyctl_show, "show", "" },
@@ -88,6 +89,7 @@ const struct command commands[] = {
{ act_keyctl_pinstantiate, "pinstantiate","<key> <keyring>" },
{ act_keyctl_negate, "negate", "<key> <timeout> <keyring>" },
{ act_keyctl_timeout, "timeout", "<key> <timeout>" },
+ { act_keyctl_security, "security", "<key>" },
{ NULL, NULL, NULL }
};
@@ -1176,6 +1178,30 @@ static int act_keyctl_timeout(int argc, char *argv[])
/*****************************************************************************/
/*
+ * get a key's security label
+ */
+static int act_keyctl_security(int argc, char *argv[])
+{
+ key_serial_t key;
+ char *buffer;
+ int ret;
+
+ if (argc != 2)
+ format();
+
+ key = get_key_id(argv[1]);
+
+ /* get key description */
+ ret = keyctl_get_security_alloc(key, &buffer);
+ if (ret < 0)
+ error("keyctl_getsecurity");
+
+ printf("%s\n", buffer);
+ return 0;
+}
+
+/*****************************************************************************/
+/*
* parse a key identifier
*/
static key_serial_t get_key_id(const char *arg)