| 361 | |
| 362 | typedef struct { bool deny_restore, deny_pin, pin_seen, restore_armed; int restore_denied; } ss_auth_t; |
| 363 | static int ss_authorize(void *opaque,int action,const char *a,const char *b,const char *db,const char *trigger) { |
| 364 | (void)trigger; ss_auth_t *auth=opaque; |
| 365 | if (action==SQLITE_READ && ss_eq(a,"nodes") && ss_eq(db,"main") && auth->deny_pin) { |
| 366 | auth->pin_seen=true; auth->restore_armed=true; return SQLITE_DENY; |
| 367 | } |
| 368 | if (action==SQLITE_PRAGMA && a && sqlite3_stricmp(a,"query_only")==0 && b && |
| 369 | auth->deny_restore && auth->restore_armed) { |
| 370 | auth->restore_denied++; return SQLITE_DENY; |
| 371 | } |
| 372 | return SQLITE_OK; |
| 373 | } |
| 374 | TEST(store_scope_close_restore_denial_requires_connection_discard) { |
| 375 | cbm_store_t *s=cbm_store_open_memory(); ss_ids_t id={0}; |
| 376 | bool setup=ss_seed(s,&id) && ss_sql(s,"PRAGMA query_only=0; PRAGMA busy_timeout=2468")==SQLITE_OK; |