Whamcloud - gitweb
e4crypt: fix error handling for KEYCTL_GET_KEYRING_ID
authorJoe Richey <joerichey@google.com>
Mon, 3 Apr 2017 16:52:50 +0000 (16:52 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 13 Apr 2017 15:47:17 +0000 (11:47 -0400)
commit1b13ca5ffaab574153e14140a69d574ba41287ed
tree41111383d08544622dbb0ab4528c7e56ebee49a9
parent971269316b8064ce648e0f9b95ab2163ab04568c
e4crypt: fix error handling for KEYCTL_GET_KEYRING_ID

Due to some interesting behaviour in keyctl (as described in the
comments), we use KEYCTL_GET_KEYRING_ID to translate the special value
of KEY_SPEC_SESSION_KEYRING to a real keyring id. However, how we
currently do this is flawed in two ways.

First, if KEYCTL_GET_KEYRING_ID fails, we don't detect it as it returns
-1 and zero is used for an error value in get_keyring_id. Second, if the
user specifies "-k @s" the translation never runs and the undesireable
behavior occurs.

These are both fixed by doing the translation outside of get_keyring_id.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/e4crypt.c