diff --git a/src/lightdm-webkit2-greeter-ext.c b/src/lightdm-webkit2-greeter-ext.c index 52e57d0..b8ef073 100644 --- a/src/lightdm-webkit2-greeter-ext.c +++ b/src/lightdm-webkit2-greeter-ext.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -233,7 +235,24 @@ get_user_image_cb(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef *exception) { - return string_or_null(context, lightdm_user_get_image(USER)); + const gchar *image_uri = lightdm_user_get_image(USER); + gchar *image_path; + gint result; + + image_path = g_filename_from_uri(image_uri, NULL, NULL); + if (image_path) { + result = g_access(image_path, R_OK); + g_free(image_path); + } else { + result = g_access(image_uri, R_OK); + } + + if (result) { + /* Couldn't access */ + return JSValueMakeNull(context); + } else { + return string_or_null(context, image_uri); + } }