1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00
tenancy/extensions/noattach.c
Samuel Štancl a88a42fbbf
[4.x] Add DisallowSqliteAttach feature (#1283)
* queue.yml: remove TENANCY_VERSION env var from test.sh

* add DisallowSqliteAttach feature

* Fix code style (php-cs-fixer)

* ci: add cd to each step

* ci: simpler solution to race conditions, proper os/arch matrix

* ci: fix runs-on matrix

* ci: fix workflow on windows, fix makefile

* Auto-build: Update extensions [skip ci]

* Auto-build: Update extensions [skip ci]

* ci: try fixing retry logic, make makefile use cl on Windows

* ci: use the current branch for rebase

* ci: try calling vcvars64

* ci: misc minor fixes

* ci: try fixing c compiler on windows

* ci: misc minor fixes

* ci: add debug steps

* ci: try to fix windows build

* ci: try using clang on windows

* ci: windows fixes, makefile fix

* Auto-build: Update extensions [skip ci]

* ci: dont produce .exp .lib on Windows

* ci: try forcing shell: bash on commit step

* ci: try to get linux cross-compilation working

* ci: reformulate condition

* ci: fix syntax error

* ci: correct debian image name

* Auto-build: Update extensions [skip ci]

* ci: try to set up macOS cross-compilation

* ci: add ARCH variable to makefile, override it during cross-compilation

* Auto-build: Update extensions [skip ci]

* ci: X64 -> x64

* ci: only trigger extensions.yml on pushes to extensions/

* fix tests on x64

* ci: try using bash for pushing on windows; ignore phpstan error

* fix test failing in ci but passing locally

* bump php version in composer.json, trigger extensions.yml build

* remove comment

* noattach: more explicit return values, avoid potential non-bool return values

* makefile: use -Os on Windows

* ci: use make -B

* ci: try triggering extensions build on extensions.yml file changes

* Auto-build: Update extensions [skip ci]

* Auto-build: Update extensions [skip ci]

* ci: remove windows linker flag, use a whitelist for git add

* Auto-build: Update extensions [skip ci]

* Auto-build: Update extensions [skip ci]

* Auto-build: Update extensions [skip ci]

* fix path in feature class, minor refactor

* Fix code style (php-cs-fixer)

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-01-04 15:34:37 +01:00

22 lines
699 B
C

#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);
if (sqlite3_set_authorizer(db, deny_attach_authorizer, 0) != SQLITE_OK) {
*pzErrMsg = sqlite3_mprintf("Tenancy: Failed to set authorizer");
return SQLITE_ERROR;
} else {
return SQLITE_OK;
}
}