Commit a53740d6 authored by spiiroin's avatar spiiroin

[rescue] Disable rescue mode when/if init done is reached. Fixes MER#1678

The once/bootup mechanism used for terminating rescue mode leaves it
permanently active if usb moded is restarted after bootup has finished.

Do not activate rescue mode if init-done has been reached when usb-moded
is starting up.

Disable rescue mode if init-done is signaled on D-Bus SystemBus while
usb-moded is running.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 8714bf4d
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include "usb_moded-network.h" #include "usb_moded-network.h"
#include "usb_moded-log.h" #include "usb_moded-log.h"
#define INIT_DONE_INTERFACE "com.nokia.startup.signal"
#define INIT_DONE_SIGNAL "init_done"
#define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'"
static DBusConnection *dbus_connection_sys = NULL; static DBusConnection *dbus_connection_sys = NULL;
extern gboolean rescue_mode; extern gboolean rescue_mode;
...@@ -129,6 +133,18 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa ...@@ -129,6 +133,18 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
if(!interface || !member || !object) goto EXIT; if(!interface || !member || !object) goto EXIT;
if( type == DBUS_MESSAGE_TYPE_SIGNAL )
{
if( !strcmp(interface, INIT_DONE_INTERFACE) && !strcmp(member, INIT_DONE_SIGNAL) ) {
/* Auto-disable rescue mode when bootup is finished */
if( rescue_mode ) {
rescue_mode = FALSE;
log_debug("init done reached - rescue mode disabled");
}
}
goto EXIT;
}
if( type == DBUS_MESSAGE_TYPE_METHOD_CALL && !strcmp(interface, USB_MODE_INTERFACE) && !strcmp(object, USB_MODE_OBJECT)) if( type == DBUS_MESSAGE_TYPE_METHOD_CALL && !strcmp(interface, USB_MODE_INTERFACE) && !strcmp(object, USB_MODE_OBJECT))
{ {
status = DBUS_HANDLER_RESULT_HANDLED; status = DBUS_HANDLER_RESULT_HANDLED;
...@@ -403,6 +419,9 @@ gboolean usb_moded_dbus_init(void) ...@@ -403,6 +419,9 @@ gboolean usb_moded_dbus_init(void)
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error); dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/ */
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
dbus_threads_init_default(); dbus_threads_init_default();
/* Connect D-Bus to the mainloop */ /* Connect D-Bus to the mainloop */
......
...@@ -1052,6 +1052,16 @@ void delay_suspend(void) ...@@ -1052,6 +1052,16 @@ void delay_suspend(void)
allow_suspend_cb, 0); allow_suspend_cb, 0);
} }
/** Check if system has already been successfully booted up
*
* @return true if init-done has been reached, or false otherwise
*/
static bool init_done_p(void)
{
return access("/run/systemd/boot-status/init-done", F_OK) == 0;
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int result = EXIT_FAILURE; int result = EXIT_FAILURE;
...@@ -1146,6 +1156,12 @@ int main(int argc, char* argv[]) ...@@ -1146,6 +1156,12 @@ int main(int argc, char* argv[])
#endif #endif
mainloop = g_main_loop_new(NULL, FALSE); mainloop = g_main_loop_new(NULL, FALSE);
if (rescue_mode && init_done_p())
{
rescue_mode = FALSE;
log_warning("init done passed; rescue mode ignored");
}
/* init daemon into a clean state first, then dbus and hw_abstraction last */ /* init daemon into a clean state first, then dbus and hw_abstraction last */
usb_moded_init(); usb_moded_init();
if( !usb_moded_dbus_init() ) if( !usb_moded_dbus_init() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment