summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2021-01-25 13:54:37 -0800
committerMarco Nelissen <marcone@google.com>2021-01-25 17:52:05 -0800
commit686b46c0f0ff4aeae53c2cf3c4dd52dd6bf975e2 (patch)
treef417fb704b610011213a660bd2d566966441942f
parent0bf91436e5677d30739f027aff9f27caaab82939 (diff)
downloadgatekeeper-686b46c0f0ff4aeae53c2cf3c4dd52dd6bf975e2.tar.gz
Add DeleteUser and DeleteAllUsers to gatekeeper
Also fix a few places where gatekeeper error codes were interpreted as tipc error codes Bug: 160731903 Test: "atest VtsHalGatekeeperV1_0TargetTest" manual testing with added instrumentation Change-Id: I020464eb784a6dec698867f731760616ae945bc1
-rw-r--r--ipc/gatekeeper_ipc.cpp39
-rw-r--r--ipc/gatekeeper_ipc.h2
2 files changed, 26 insertions, 15 deletions
diff --git a/ipc/gatekeeper_ipc.cpp b/ipc/gatekeeper_ipc.cpp
index 2f9e32d..7fc5051 100644
--- a/ipc/gatekeeper_ipc.cpp
+++ b/ipc/gatekeeper_ipc.cpp
@@ -83,6 +83,10 @@ static gatekeeper_error_t exec_cmd(void (GateKeeper::*operation)(const Request&,
Response rsp;
(device->*operation)(req, &rsp);
+ if (rsp.error == ERROR_NOT_IMPLEMENTED) {
+ return ERROR_NOT_IMPLEMENTED;
+ }
+
*out_size = rsp.GetSerializedSize();
if (*out_size > GATEKEEPER_MAX_BUFFER_LENGTH) {
*out_size = 0;
@@ -117,6 +121,12 @@ static gatekeeper_error_t handle_request(uint32_t cmd,
case GK_VERIFY:
return exec_cmd(&GateKeeper::Verify, in_buf, in_buf_size, out_buf,
out_buf_size);
+ case GK_DELETE_USER:
+ return exec_cmd(&GateKeeper::DeleteUser, in_buf, in_buf_size, out_buf,
+ out_buf_size);
+ case GK_DELETE_ALL_USERS:
+ return exec_cmd(&GateKeeper::DeleteAllUsers, in_buf, in_buf_size,
+ out_buf, out_buf_size);
default:
return ERROR_INVALID;
}
@@ -162,7 +172,7 @@ static gatekeeper_error_t send_error_response(handle_t chan,
return rc;
}
-static long handle_msg(handle_t chan) {
+static gatekeeper_error_t handle_msg(handle_t chan) {
/* get message info */
ipc_msg_info_t msg_inf;
@@ -174,7 +184,7 @@ static long handle_msg(handle_t chan) {
if (rc != NO_ERROR) {
TLOGE("failed (%ld) to get_msg for chan (%d), closing connection\n", rc,
chan);
- return rc;
+ return tipc_err_to_gatekeeper_err(rc);
}
MessageDeleter md(chan, msg_inf.id);
@@ -189,7 +199,7 @@ static long handle_msg(handle_t chan) {
if (rc < 0) {
TLOGE("failed to read msg (%ld) for chan (%d)\n", rc, chan);
- return rc;
+ return tipc_err_to_gatekeeper_err(rc);
}
if (((size_t)rc) < sizeof(gatekeeper_message)) {
@@ -204,23 +214,22 @@ static long handle_msg(handle_t chan) {
UniquePtr<uint8_t[]> out_buf;
uint32_t out_buf_size = 0;
- rc = handle_request(gk_msg->cmd, gk_msg->payload,
- msg_inf.len - sizeof(gatekeeper_message), &out_buf,
- &out_buf_size);
+ gatekeeper_error_t err = handle_request(
+ gk_msg->cmd, gk_msg->payload,
+ msg_inf.len - sizeof(gatekeeper_message), &out_buf, &out_buf_size);
- if (rc < 0) {
+ if (err != ERROR_NONE) {
TLOGE("unable (%ld) to handle request", rc);
- return send_error_response(chan, gk_msg->cmd,
- tipc_err_to_gatekeeper_err(rc));
+ return send_error_response(chan, gk_msg->cmd, err);
}
- rc = send_response(chan, gk_msg->cmd, out_buf.get(), out_buf_size);
+ err = send_response(chan, gk_msg->cmd, out_buf.get(), out_buf_size);
- if (rc < 0) {
+ if (err != ERROR_NONE) {
TLOGE("unable (%ld) to send response", rc);
}
- return rc;
+ return err;
}
static void gatekeeper_handle_port(uevent_t* ev) {
@@ -255,10 +264,10 @@ static void gatekeeper_handle_channel(uevent_t* ev) {
handle_t chan = ev->handle;
if (ev->event & IPC_HANDLE_POLL_MSG) {
- long rc = handle_msg(chan);
- if (rc != NO_ERROR) {
+ gatekeeper_error_t rc = handle_msg(chan);
+ if (rc != ERROR_NONE) {
/* report an error and close channel */
- TLOGE("failed (%ld) to handle event on channel %d\n", rc,
+ TLOGE("failed (%u) to handle event on channel %d\n", rc,
ev->handle);
close(chan);
}
diff --git a/ipc/gatekeeper_ipc.h b/ipc/gatekeeper_ipc.h
index 086cf9c..f855d76 100644
--- a/ipc/gatekeeper_ipc.h
+++ b/ipc/gatekeeper_ipc.h
@@ -23,6 +23,8 @@ enum gatekeeper_command {
GK_ENROLL = (0 << GK_REQ_SHIFT),
GK_VERIFY = (1 << GK_REQ_SHIFT),
+ GK_DELETE_USER = (2 << GK_REQ_SHIFT),
+ GK_DELETE_ALL_USERS = (3 << GK_REQ_SHIFT),
};
/**