diff --git a/data/lightdm-webkit2-greeter.conf b/data/lightdm-webkit2-greeter.conf index fcefbb3..0a621b6 100644 --- a/data/lightdm-webkit2-greeter.conf +++ b/data/lightdm-webkit2-greeter.conf @@ -1,7 +1,7 @@ # # [greeter] # debug_mode = Greeter theme debug mode. -# secure_mode = Don't allow themes to make non-local http requests. +# secure_mode = Don't allow themes to make remote http requests. # screensaver-timeout = Blank the screen after this many seconds of inactivity. # webkit-theme = Webkit theme to use. # diff --git a/src/webkit2-extension.c b/src/webkit2-extension.c index f329660..bb83485 100644 --- a/src/webkit2-extension.c +++ b/src/webkit2-extension.c @@ -1779,16 +1779,22 @@ autologin_timer_expired_cb(LightDMGreeter *greeter, WebKitWebExtension *extensio } +static gboolean +get_config_option_as_bool(const gchar *section, const gchar *key, GError *err) { + return g_key_file_get_boolean(keyfile, section, key, &err); +} + static gchar* -get_config_option(const gchar *section, const gchar *key) { +get_config_option_as_string(const gchar *section, const gchar *key) { gchar *value; GError *err = NULL; value = g_key_file_get_string(keyfile, section, key, &err); - if (err) { + if (NULL != err) { g_error(err->message); g_error_free(err); + g_free(value); return ""; } @@ -1812,13 +1818,13 @@ should_block_request(const char *file_path) { paths = g_slist_prepend(paths, THEME_DIR); - background_images_dir = get_config_option("branding", "background_images"); + background_images_dir = get_config_option_as_string("branding", "background_images"); paths = g_slist_prepend(paths, background_images_dir); - user_image = get_config_option("branding", "user_image"); + user_image = get_config_option_as_string("branding", "user_image"); paths = g_slist_prepend(paths, user_image); - logo = get_config_option("branding", "logo"); + logo = get_config_option_as_string("branding", "logo"); paths = g_slist_prepend(paths, logo); canonical_path = canonicalize_file_name(file_path); @@ -1895,6 +1901,16 @@ page_created_cb(WebKitWebExtension *extension, WebKitWebPage *web_page, gpointer user_data) { + gboolean secure_mode; + GError *err = NULL; + + secure_mode = get_config_option_as_bool("greeter", "secure_mode", err); + + if (FALSE == secure_mode && NULL == err) { + // secure_mode is disabled in our config file. bail. + return; + } + page_id = webkit_web_page_get_id(web_page); g_signal_connect(