mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add support for the extra parameter on the sqlite3_set_authorizer() callback
and support for failing an ATTACH with an authentication-required database using bad credentials. The extension is now feature complete, but much testing and bug-fixing remains. FossilOrigin-Name: 596e728b0eb19a34c888e33d4d37978ca2bf1e00
This commit is contained in:
@@ -872,6 +872,9 @@ static int auth_callback(
|
||||
const char *zArg2,
|
||||
const char *zArg3,
|
||||
const char *zArg4
|
||||
#ifdef SQLITE_USER_AUTHENTICATION
|
||||
,const char *zArg5
|
||||
#endif
|
||||
){
|
||||
const char *zCode;
|
||||
Tcl_DString str;
|
||||
@@ -924,6 +927,9 @@ static int auth_callback(
|
||||
Tcl_DStringAppendElement(&str, zArg2 ? zArg2 : "");
|
||||
Tcl_DStringAppendElement(&str, zArg3 ? zArg3 : "");
|
||||
Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : "");
|
||||
#ifdef SQLITE_USER_AUTHENTICATION
|
||||
Tcl_DStringAppendElement(&str, zArg5 ? zArg5 : "");
|
||||
#endif
|
||||
rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str));
|
||||
Tcl_DStringFree(&str);
|
||||
zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : "SQLITE_DENY";
|
||||
@@ -1700,8 +1706,11 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
|
||||
pDb->zAuth = 0;
|
||||
}
|
||||
if( pDb->zAuth ){
|
||||
typedef int (*sqlite3_auth_cb)(
|
||||
void*,int,const char*,const char*,
|
||||
const char*,const char*);
|
||||
pDb->interp = interp;
|
||||
sqlite3_set_authorizer(pDb->db, auth_callback, pDb);
|
||||
sqlite3_set_authorizer(pDb->db,(sqlite3_auth_cb)auth_callback,pDb);
|
||||
}else{
|
||||
sqlite3_set_authorizer(pDb->db, 0, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user