OSDN Git Service

Switch to libkeyutils.
authorElliott Hughes <enh@google.com>
Wed, 10 May 2017 00:04:14 +0000 (17:04 -0700)
committerElliott Hughes <enh@google.com>
Wed, 10 May 2017 00:04:14 +0000 (17:04 -0700)
Bug: http://b/37991155
Test: builds+boots
Change-Id: Iba763eccc0768f58ce7b51d861f13e51d91ec382

ext4_utils/Android.bp
ext4_utils/ext4_crypt_init_extensions.cpp
ext4_utils/include/ext4_utils/key_control.h [deleted file]
ext4_utils/key_control.cpp [deleted file]

index a2987aa..493fae5 100644 (file)
@@ -41,11 +41,11 @@ cc_library {
 
         android: {
             srcs: [
-                "key_control.cpp",
                 "ext4_crypt.cpp",
             ],
             shared_libs: [
                 "libbase",
+                "libkeyutils",
                 "libselinux",
             ],
 
index 732060d..04d7119 100644 (file)
 #include <android-base/stringprintf.h>
 #include <cutils/properties.h>
 #include <cutils/sockets.h>
+#include <keyutils.h>
 #include <logwrap/logwrap.h>
 
 #include "ext4_utils/ext4_crypt.h"
-#include "ext4_utils/key_control.h"
 
 #define TAG "ext4_utils"
 
diff --git a/ext4_utils/include/ext4_utils/key_control.h b/ext4_utils/include/ext4_utils/key_control.h
deleted file mode 100644 (file)
index fe6a6b5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _KEY_CONTROL_H_
-#define _KEY_CONTROL_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-__BEGIN_DECLS
-
-// ext4enc:TODO - get these keyring standard definitions from proper system file
-// keyring serial number type
-typedef int32_t key_serial_t;
-
-// special process keyring shortcut IDs
-#define KEY_SPEC_THREAD_KEYRING       (-1) // key ID for thread-specific keyring
-#define KEY_SPEC_PROCESS_KEYRING      (-2) // key ID for process-specific keyring
-#define KEY_SPEC_SESSION_KEYRING      (-3) // key ID for session-specific keyring
-#define KEY_SPEC_USER_KEYRING         (-4) // key ID for UID-specific keyring
-#define KEY_SPEC_USER_SESSION_KEYRING (-5) // key ID for UID-session keyring
-#define KEY_SPEC_GROUP_KEYRING        (-6) // key ID for GID-specific keyring
-
-key_serial_t add_key(const char *type,
-                     const char *description,
-                     const void *payload,
-                     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,
-                   const char *description, key_serial_t destringid);
-
-__END_DECLS
-
-#endif // _KEY_CONTROL_H_
diff --git a/ext4_utils/key_control.cpp b/ext4_utils/key_control.cpp
deleted file mode 100644 (file)
index de6bde2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "ext4_utils/key_control.h"
-
-#include <stdarg.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <linux/keyctl.h>
-
-static long keyctl(int cmd, ...)
-{
-    va_list va;
-    unsigned long arg2, arg3, arg4, arg5;
-
-    va_start(va, cmd);
-    arg2 = va_arg(va, unsigned long);
-    arg3 = va_arg(va, unsigned long);
-    arg4 = va_arg(va, unsigned long);
-    arg5 = va_arg(va, unsigned long);
-    va_end(va);
-    return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
-}
-
-key_serial_t add_key(const char *type,
-                     const char *description,
-                     const void *payload,
-                     size_t plen,
-                     key_serial_t ringid)
-{
-    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);
-}
-
-long keyctl_search(key_serial_t ringid, const char *type,
-                   const char *description, key_serial_t destringid)
-{
-    return keyctl(KEYCTL_SEARCH, ringid, type, description, destringid);
-}