Define symbolic keyring name

Currently evmctl supports importing keys onto a particular keyring
based on a numeric keyring identifier.  This patch adds support
for importing keys based special values as defined by keyctl.

   Thread keyring: @t (-1)
   Process keyring: @p (-2)
   Session keyring: @s (-3)
   User specific keyring: @u (-4)
   User default session keyring: @us (-5)
   Group specific keyring: @g (-6)

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
This commit is contained in:
Mimi Zohar 2014-03-05 13:00:48 +02:00 committed by Dmitry Kasatkin
parent bed3cc06f1
commit b0da7e69e0

View File

@ -887,10 +887,26 @@ static int cmd_import(struct command *cmd)
} else } else
ring = g_argv[optind++]; ring = g_argv[optind++];
if (!ring) id = KEY_SPEC_USER_KEYRING; /* default keyring */
id = KEY_SPEC_USER_KEYRING;
else if (ring) {
id = atoi(ring); if (ring[0] != '@') {
id = atoi(ring);
} else {
if (strcmp(ring, "@t") == 0)
id = -1;
else if (strcmp(ring, "@p") == 0)
id = -2;
else if (strcmp(ring, "@s") == 0)
id = -3;
else if (strcmp(ring, "@u") == 0)
id = -4;
else if (strcmp(ring, "@us") == 0)
id = -5;
else if (strcmp(ring, "@g") == 0)
id = -6;
}
}
key = read_pub_key(inkey, x509); key = read_pub_key(inkey, x509);
if (!key) if (!key)