@@ -24,18 +24,30 @@ static void can_authenticate(FlMethodCall* method_call) {
2424 GError* error = nullptr ;
2525 PolkitAuthority* authority = polkit_authority_get_sync (nullptr , &error);
2626 if (error) {
27- fl_method_call_respond (method_call, FL_METHOD_RESPONSE (fl_method_error_response_new ( " authCheckError " , error-> message , nullptr )), nullptr );
27+ fl_method_call_respond (method_call, FL_METHOD_RESPONSE (fl_method_success_response_new ( fl_value_new_bool ( false ) )), nullptr );
2828 g_clear_error (&error);
2929 return ;
3030 }
3131 if (authority == nullptr ) {
3232 fl_method_call_respond (method_call, FL_METHOD_RESPONSE (fl_method_success_response_new (fl_value_new_bool (false ))), nullptr );
3333 return ;
3434 }
35+
36+ const gchar* snap = g_getenv (" SNAP" );
37+ if (snap != nullptr ) {
38+ g_autofree gchar* snap_policy_path = g_build_filename (snap, " meta" , " polkit" , " polkit.app.openauthenticator.policy" , nullptr );
39+ gboolean success = g_file_test (snap_policy_path, G_FILE_TEST_IS_REGULAR);
40+
41+ g_object_unref (authority);
42+ fl_method_call_respond (method_call, FL_METHOD_RESPONSE (fl_method_success_response_new (fl_value_new_bool (success))), nullptr );
43+ return ;
44+ }
45+
3546 GList* actions = polkit_authority_enumerate_actions_sync (authority, nullptr , &error);
3647 if (error) {
3748 fl_method_call_respond (method_call, FL_METHOD_RESPONSE (fl_method_error_response_new (" authCheckError" , error->message , nullptr )), nullptr );
3849 g_clear_error (&error);
50+ g_object_unref (authority);
3951 return ;
4052 }
4153 bool hasOpenApp = false , hasSensible = false , hasEnable = false , hasDisable = false ;
@@ -61,6 +73,7 @@ static void can_authenticate(FlMethodCall* method_call) {
6173 break ;
6274 }
6375 }
76+
6477 gboolean success = hasOpenApp && hasSensible && hasEnable && hasDisable;
6578 g_list_free_full (actions, g_object_unref);
6679 g_object_unref (authority);
0 commit comments