Use the sqlite authorizer for async requests, too.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4401 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		@@ -927,7 +927,7 @@ static JSValue _tf_ssb_sqlite_row_to_json(JSContext* context, sqlite3_stmt* row)
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _tf_ssb_sqlite_authorizer(void* user_data, int action_code, const char* arg0, const char* arg1, const char* arg2, const char* arg3)
 | 
			
		||||
int tf_ssb_sqlite_authorizer(void* user_data, int action_code, const char* arg0, const char* arg1, const char* arg2, const char* arg3)
 | 
			
		||||
{
 | 
			
		||||
	int result = SQLITE_DENY;
 | 
			
		||||
	switch (action_code)
 | 
			
		||||
@@ -973,7 +973,7 @@ JSValue tf_ssb_db_visit_query(tf_ssb_t* ssb, const char* query, const JSValue bi
 | 
			
		||||
	sqlite3* db = tf_ssb_acquire_db_reader(ssb);
 | 
			
		||||
	JSContext* context = tf_ssb_get_context(ssb);
 | 
			
		||||
	sqlite3_stmt* statement;
 | 
			
		||||
	sqlite3_set_authorizer(db, _tf_ssb_sqlite_authorizer, ssb);
 | 
			
		||||
	sqlite3_set_authorizer(db, tf_ssb_sqlite_authorizer, ssb);
 | 
			
		||||
	if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK)
 | 
			
		||||
	{
 | 
			
		||||
		JSValue bind_result = _tf_ssb_sqlite_bind_json(context, db, statement, binds);
 | 
			
		||||
 
 | 
			
		||||
@@ -58,3 +58,5 @@ typedef struct _tf_ssb_db_stored_connection_t
 | 
			
		||||
 | 
			
		||||
tf_ssb_db_stored_connection_t* tf_ssb_db_get_stored_connections(tf_ssb_t* ssb, int* out_count);
 | 
			
		||||
void tf_ssb_db_forget_stored_connection(tf_ssb_t* ssb, const char* address, int port, const char* pubkey);
 | 
			
		||||
 | 
			
		||||
int tf_ssb_sqlite_authorizer(void* user_data, int action_code, const char* arg0, const char* arg1, const char* arg2, const char* arg3);
 | 
			
		||||
 
 | 
			
		||||
@@ -411,6 +411,7 @@ static void _tf_ssb_sqlAsync_work(uv_work_t* work)
 | 
			
		||||
	sql_work->start_time = uv_hrtime();
 | 
			
		||||
	sql_work->thread_id = uv_thread_self();
 | 
			
		||||
	sqlite3* db = tf_ssb_acquire_db_reader(sql_work->ssb);
 | 
			
		||||
	sqlite3_set_authorizer(db, tf_ssb_sqlite_authorizer, sql_work->ssb);
 | 
			
		||||
	sqlite3_stmt* statement = NULL;
 | 
			
		||||
	sql_work->result = sqlite3_prepare(db, sql_work->query, -1, &statement, NULL);
 | 
			
		||||
	if (sql_work->result == SQLITE_OK)
 | 
			
		||||
@@ -504,6 +505,7 @@ static void _tf_ssb_sqlAsync_work(uv_work_t* work)
 | 
			
		||||
	{
 | 
			
		||||
		sql_work->error = tf_strdup(sqlite3_errmsg(db));
 | 
			
		||||
	}
 | 
			
		||||
	sqlite3_set_authorizer(db, NULL, NULL);
 | 
			
		||||
	tf_ssb_release_db_reader(sql_work->ssb, db);
 | 
			
		||||
	sql_work->end_time = uv_hrtime();
 | 
			
		||||
	tf_trace_end(trace);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user