iface-modem: the Command() method is only allowed when running in debug mode

This commit is contained in:
Aleksander Morgado
2012-02-28 23:24:53 +01:00
parent 952b9164b9
commit 64f49c0c72
2 changed files with 18 additions and 3 deletions

View File

@@ -148,11 +148,14 @@
<!-- <!--
Command Command
@cmd The command string, e.g. "AT+GCAP" or "+GCAP" (leading AT is inserted if necessary) @cmd The command string, e.g. "AT+GCAP" or "+GCAP" (leading AT is inserted if necessary).
@timeout The number of seconds to wait for a response @timeout The number of seconds to wait for a response.
@response The modem's response @response The modem's response.
Send an arbitrary AT command to a modem and get the response. Send an arbitrary AT command to a modem and get the response.
Note that using this interface call is only allowed when running
ModemManager in debug mode.
--> -->
<method name="Command"> <method name="Command">
<arg name="cmd" type="s" direction="in" /> <arg name="cmd" type="s" direction="in" />

View File

@@ -24,6 +24,7 @@
#include "mm-sim.h" #include "mm-sim.h"
#include "mm-bearer-list.h" #include "mm-bearer-list.h"
#include "mm-log.h" #include "mm-log.h"
#include "mm-context.h"
#define SIGNAL_QUALITY_RECENT_TIMEOUT_SEC 60 #define SIGNAL_QUALITY_RECENT_TIMEOUT_SEC 60
#define SIGNAL_QUALITY_CHECK_TIMEOUT_SEC 30 #define SIGNAL_QUALITY_CHECK_TIMEOUT_SEC 30
@@ -367,6 +368,17 @@ handle_command_auth_ready (MMBaseModem *self,
return; return;
} }
/* If we are not in Debug mode, report an error */
if (!mm_context_get_debug ()) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_UNAUTHORIZED,
"Cannot send AT command to modem: "
"operation only allowed in debug mode");
handle_command_context_free (ctx);
return;
}
/* If command is not implemented, report an error */ /* If command is not implemented, report an error */
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command || if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command ||
!MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) { !MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) {