summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Crowley <paulcrowley@google.com>2015-07-13 22:35:00 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-13 22:35:00 +0000
commitb8e5034ab0a3172d61af84842ebd123520c1137f (patch)
treed3acd1bbf262369d109fabc92eab927e5ea16738
parent7b5b1667674453ae04474f853245a6a671066bd2 (diff)
parentfa584713c935572966cf86529bbba9e011e001e9 (diff)
downloadextras-b8e5034ab0a3172d61af84842ebd123520c1137f.tar.gz
am fa584713: Merge changes If63f439d,I697ec4ef into mnc-dr-dev
* commit 'fa584713c935572966cf86529bbba9e011e001e9': Add keyctl_revoke Improve error logging.
-rw-r--r--ext4_utils/ext4_crypt_init_extensions.cpp10
-rw-r--r--ext4_utils/key_control.cpp7
-rw-r--r--ext4_utils/key_control.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/ext4_utils/ext4_crypt_init_extensions.cpp b/ext4_utils/ext4_crypt_init_extensions.cpp
index 5e167a54..6e8695e8 100644
--- a/ext4_utils/ext4_crypt_init_extensions.cpp
+++ b/ext4_utils/ext4_crypt_init_extensions.cpp
@@ -36,7 +36,7 @@ static std::string vold_command(std::string const& command)
}
if (sock < 0) {
- KLOG_INFO(TAG, "Cannot open vold, failing command\n");
+ KLOG_INFO(TAG, "Cannot open vold, failing command (%s)\n", strerror(errno));
return "";
}
@@ -54,7 +54,7 @@ static std::string vold_command(std::string const& command)
// framework is down, so this is (mostly) OK.
std::string actual_command = arbitrary_sequence_number + " " + command;
if (write(sock, actual_command.c_str(), actual_command.size() + 1) < 0) {
- KLOG_ERROR(TAG, "Cannot write command\n");
+ KLOG_ERROR(TAG, "Cannot write command (%s)\n", strerror(errno));
return "";
}
@@ -62,7 +62,7 @@ static std::string vold_command(std::string const& command)
int rc = TEMP_FAILURE_RETRY(poll(&poll_sock, 1, vold_command_timeout_ms));
if (rc < 0) {
- KLOG_ERROR(TAG, "Error in poll %s\n", strerror(errno));
+ KLOG_ERROR(TAG, "Error in poll (%s)\n", strerror(errno));
return "";
}
@@ -103,7 +103,7 @@ int e4crypt_create_device_key(const char* dir,
// Make sure folder exists. Use make_dir to set selinux permissions.
if (ensure_dir_exists(UnencryptedProperties::GetPath(dir).c_str())) {
- KLOG_ERROR(TAG, "Failed to create %s with error %s\n",
+ KLOG_ERROR(TAG, "Failed to create %s (%s)\n",
UnencryptedProperties::GetPath(dir).c_str(),
strerror(errno));
return -1;
@@ -123,7 +123,7 @@ int e4crypt_install_keyring()
KEY_SPEC_SESSION_KEYRING);
if (device_keyring == -1) {
- KLOG_ERROR(TAG, "Failed to create keyring\n");
+ KLOG_ERROR(TAG, "Failed to create keyring (%s)\n", strerror(errno));
return -1;
}
diff --git a/ext4_utils/key_control.cpp b/ext4_utils/key_control.cpp
index 3d775b7f..39bd1401 100644
--- a/ext4_utils/key_control.cpp
+++ b/ext4_utils/key_control.cpp
@@ -5,8 +5,8 @@
#include <sys/syscall.h>
/* keyring keyctl commands */
+#define KEYCTL_REVOKE 3 /* revoke a key */
#define KEYCTL_SETPERM 5 /* set permissions for a key in a keyring */
-#define KEYCTL_UNLINK 9 /* unlink a key from a keyring */
#define KEYCTL_SEARCH 10 /* search for a key in a keyring */
static long keyctl(int cmd, ...)
@@ -32,6 +32,11 @@ key_serial_t add_key(const char *type,
return syscall(__NR_add_key, type, description, payload, plen, ringid);
}
+long keyctl_revoke(key_serial_t id)
+{
+ return keyctl(KEYCTL_REVOKE, id);
+}
+
long keyctl_setperm(key_serial_t id, int permissions)
{
return keyctl(KEYCTL_SETPERM, id, permissions);
diff --git a/ext4_utils/key_control.h b/ext4_utils/key_control.h
index 8e6e32ba..bbf0acec 100644
--- a/ext4_utils/key_control.h
+++ b/ext4_utils/key_control.h
@@ -21,6 +21,8 @@ key_serial_t add_key(const char *type,
size_t plen,
key_serial_t ringid);
+long keyctl_revoke(key_serial_t id);
+
long keyctl_setperm(key_serial_t id, int permissions);
long keyctl_search(key_serial_t ringid, const char *type,