mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 06:24:04 +00:00
add DisallowSqliteAttach feature
This commit is contained in:
parent
613ab5bbc8
commit
9bb06afc57
10 changed files with 275 additions and 1 deletions
22
extensions/noattach.c
Normal file
22
extensions/noattach.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "sqlite3ext.h"
|
||||
SQLITE_EXTENSION_INIT1
|
||||
|
||||
static int deny_attach_authorizer(void *user_data, int action_code, const char *param1, const char *param2, const char *dbname, const char *trigger) {
|
||||
return action_code == SQLITE_ATTACH // 24
|
||||
? SQLITE_DENY // 1
|
||||
: SQLITE_OK; // 0
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int sqlite3_noattach_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) {
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
|
||||
int rc = sqlite3_set_authorizer(db, deny_attach_authorizer, 0);
|
||||
if (rc != SQLITE_OK) {
|
||||
*pzErrMsg = sqlite3_mprintf("Tenancy: Failed to set authorizer");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue