** This authorizer runs in safe mode. */
| 17128 | ** This authorizer runs in safe mode. |
| 17129 | */ |
| 17130 | static int safeModeAuth( |
| 17131 | void *pClientData, |
| 17132 | int op, |
| 17133 | const char *zA1, |
| 17134 | const char *zA2, |
| 17135 | const char *zA3, |
| 17136 | const char *zA4 |
| 17137 | ){ |
| 17138 | ShellState *p = (ShellState*)pClientData; |
| 17139 | static const char *azProhibitedFunctions[] = { |
| 17140 | "edit", |
| 17141 | "fts3_tokenizer", |
| 17142 | "load_extension", |
| 17143 | "readfile", |
| 17144 | "writefile", |
| 17145 | "zipfile", |
| 17146 | "zipfile_cds", |
| 17147 | }; |
| 17148 | UNUSED_PARAMETER(zA1); |
| 17149 | UNUSED_PARAMETER(zA3); |
| 17150 | UNUSED_PARAMETER(zA4); |
| 17151 | switch( op ){ |
| 17152 | case SQLITE_ATTACH: { |
| 17153 | #ifndef SQLITE_SHELL_FIDDLE |
| 17154 | /* In WASM builds the filesystem is a virtual sandbox, so |
| 17155 | ** there's no harm in using ATTACH. */ |
| 17156 | failIfSafeMode(p, "cannot run ATTACH in safe mode"); |
| 17157 | #endif |
| 17158 | break; |
| 17159 | } |
| 17160 | case SQLITE_FUNCTION: { |
| 17161 | int i; |
| 17162 | for(i=0; i<ArraySize(azProhibitedFunctions); i++){ |
| 17163 | if( sqlite3_stricmp(zA2, azProhibitedFunctions[i])==0 ){ |
| 17164 | failIfSafeMode(p, "cannot use the %s() function in safe mode", |
| 17165 | azProhibitedFunctions[i]); |
| 17166 | } |
| 17167 | } |
| 17168 | break; |
| 17169 | } |
| 17170 | } |
| 17171 | return SQLITE_OK; |
| 17172 | } |
| 17173 | |
| 17174 | /* |
| 17175 | ** When the ".auth ON" is set, the following authorizer callback is |
no test coverage detected