aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-sim.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-08-01 09:59:16 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-08-28 14:59:06 +0000
commit842ad4bd64404e4a98d089c9a8fa60715c7018c6 (patch)
tree8b9ecb9ddc411b3b69d5b0276fffa292de466d2c /src/mm-base-sim.c
parent86a183778b5b123f6556ecbe53ec7d06d6e7c575 (diff)
base-sim: only allow operations on active SIMs
If a SIM is inactive we cannot perform any SIM-PIN or SIM-PUK related operation with it.
Diffstat (limited to 'src/mm-base-sim.c')
-rw-r--r--src/mm-base-sim.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/src/mm-base-sim.c b/src/mm-base-sim.c
index 0a91d385..1c0443ba 100644
--- a/src/mm-base-sim.c
+++ b/src/mm-base-sim.c
@@ -221,11 +221,21 @@ handle_change_pin_auth_ready (MMBaseModem *modem,
return;
}
+ if (!mm_gdbus_sim_get_active (MM_GDBUS_SIM (ctx->self))) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot change PIN: "
+ "SIM not currently active");
+ handle_change_pin_context_free (ctx);
+ return;
+ }
+
MM_BASE_SIM_GET_CLASS (ctx->self)->change_pin (ctx->self,
- ctx->old_pin,
- ctx->new_pin,
- (GAsyncReadyCallback)handle_change_pin_ready,
- ctx);
+ ctx->old_pin,
+ ctx->new_pin,
+ (GAsyncReadyCallback)handle_change_pin_ready,
+ ctx);
}
static gboolean
@@ -391,11 +401,21 @@ handle_enable_pin_auth_ready (MMBaseModem *modem,
return;
}
+ if (!mm_gdbus_sim_get_active (MM_GDBUS_SIM (ctx->self))) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot enable/disable PIN: "
+ "SIM not currently active");
+ handle_enable_pin_context_free (ctx);
+ return;
+ }
+
MM_BASE_SIM_GET_CLASS (ctx->self)->enable_pin (ctx->self,
- ctx->pin,
- ctx->enabled,
- (GAsyncReadyCallback)handle_enable_pin_ready,
- ctx);
+ ctx->pin,
+ ctx->enabled,
+ (GAsyncReadyCallback)handle_enable_pin_ready,
+ ctx);
}
static gboolean
@@ -782,6 +802,16 @@ handle_send_pin_auth_ready (MMBaseModem *modem,
return;
}
+ if (!mm_gdbus_sim_get_active (MM_GDBUS_SIM (ctx->self))) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot send PIN: "
+ "SIM not currently active");
+ handle_send_pin_context_free (ctx);
+ return;
+ }
+
mm_base_sim_send_pin (ctx->self,
ctx->pin,
(GAsyncReadyCallback)handle_send_pin_ready,
@@ -856,6 +886,16 @@ handle_send_puk_auth_ready (MMBaseModem *modem,
return;
}
+ if (!mm_gdbus_sim_get_active (MM_GDBUS_SIM (ctx->self))) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot send PUK: "
+ "SIM not currently active");
+ handle_send_puk_context_free (ctx);
+ return;
+ }
+
mm_base_sim_send_puk (ctx->self,
ctx->puk,
ctx->new_pin,