public static ARC Check(Parse parse, AUTH code, string arg1, string arg2, string arg3) { Context ctx = parse.Ctx; // Don't do any authorization checks if the database is initialising or if the parser is being invoked from within sqlite3_declare_vtab. if (ctx.Init.Busy || E.INDECLARE_VTABLE(parse)) { return(ARC.OK); } if (ctx.Auth == null) { return(ARC.OK); } ARC rc = ctx.Auth(ctx.AuthArg, code, arg1, arg2, arg3, parse.AuthContext); if (rc == ARC.DENY) { parse.ErrorMsg("not authorized"); parse.RC = RC.AUTH; } else if (rc != ARC.OK && rc != ARC.IGNORE) { rc = ARC.DENY; BadReturnCode(parse); } return(rc); }
public static ARC ReadColumn(Parse parse, string table, string column, int db) { Context ctx = parse.Ctx; // Database handle string dbName = ctx.DBs[db].Name; // Name of attached database ARC rc = ctx.Auth(ctx.AuthArg, (int)AUTH.READ, table, column, dbName, parse.AuthContext); // Auth callback return code if (rc == ARC.DENY) { if (ctx.DBs.length > 2 || db != 0) { parse.ErrorMsg("access to %s.%s.%s is prohibited", dbName, table, column); } else { parse.ErrorMsg("access to %s.%s is prohibited", table, column); } parse.RC = RC.AUTH; } else if (rc != ARC.IGNORE && rc != ARC.OK) { BadReturnCode(parse); } return(rc); }