| | @@ -424,10 +424,12 @@ |
| 424 | 424 | /* Create the triggers needed to protect sensitive settings from |
| 425 | 425 | ** being created or modified the first time that PROTECT_SENSITIVE |
| 426 | 426 | ** is enabled. Deleting a sensitive setting is harmless, so there |
| 427 | 427 | ** is not trigger to block deletes. After being created once, the |
| 428 | 428 | ** triggers persist for the life of the database connection. */ |
| 429 | + unsigned savedProtectMask = db.protectMask; |
| 430 | + db.protectMask = 0; |
| 429 | 431 | db_multi_exec( |
| 430 | 432 | "CREATE TEMP TRIGGER protect_1 BEFORE INSERT ON config" |
| 431 | 433 | " WHEN protected_setting(new.name) BEGIN" |
| 432 | 434 | " SELECT raise(abort,'not authorized');" |
| 433 | 435 | "END;\n" |
| | @@ -435,10 +437,11 @@ |
| 435 | 437 | " WHEN protected_setting(new.name) BEGIN" |
| 436 | 438 | " SELECT raise(abort,'not authorized');" |
| 437 | 439 | "END;\n" |
| 438 | 440 | ); |
| 439 | 441 | db.bProtectTriggers = 1; |
| 442 | + db.protectMask = savedProtectMask; |
| 440 | 443 | } |
| 441 | 444 | db.protectMask = flags; |
| 442 | 445 | } |
| 443 | 446 | void db_protect(unsigned flags){ |
| 444 | 447 | db_protect_only(db.protectMask | flags); |
| | @@ -454,10 +457,13 @@ |
| 454 | 457 | if( db.nProtect<1 ){ |
| 455 | 458 | fossil_panic("too many db_protect_pop() calls"); |
| 456 | 459 | } |
| 457 | 460 | db.protectMask = db.aProtect[--db.nProtect]; |
| 458 | 461 | } |
| 462 | +int db_is_protected(unsigned flags){ |
| 463 | + return (db.protectMask & flags)!=0; |
| 464 | +} |
| 459 | 465 | |
| 460 | 466 | /* |
| 461 | 467 | ** Verify that the desired database write protections are in place. |
| 462 | 468 | ** Throw a fatal error if not. |
| 463 | 469 | */ |
| | @@ -536,11 +542,11 @@ |
| 536 | 542 | "SECURITY: authorizer blocks DML on protected GLOBAL_CONFIG table\n"); |
| 537 | 543 | rc = SQLITE_DENY; |
| 538 | 544 | }else if( (db.protectMask & PROTECT_READONLY)!=0 |
| 539 | 545 | && sqlite3_stricmp(z2,"temp")!=0 ){ |
| 540 | 546 | fossil_errorlog( |
| 541 | | - "SECURITY: authorizer blocks DML on table \"%s\" due to the\n" |
| 547 | + "SECURITY: authorizer blocks DML on table \"%s\" due to the " |
| 542 | 548 | "request coming from a different origin\n", z0); |
| 543 | 549 | rc = SQLITE_DENY; |
| 544 | 550 | } |
| 545 | 551 | break; |
| 546 | 552 | } |
| | @@ -2318,14 +2324,16 @@ |
| 2318 | 2324 | if( g.eHashPolicy<0 ){ |
| 2319 | 2325 | g.eHashPolicy = hname_default_policy(); |
| 2320 | 2326 | db_set_int("hash-policy", g.eHashPolicy, 0); |
| 2321 | 2327 | } |
| 2322 | 2328 | |
| 2329 | +#if 0 /* No longer automatic. Need to run "fossil rebuild" to migrate */ |
| 2323 | 2330 | /* Make a change to the CHECK constraint on the BLOB table for |
| 2324 | 2331 | ** version 2.0 and later. |
| 2325 | 2332 | */ |
| 2326 | 2333 | rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */ |
| 2334 | +#endif |
| 2327 | 2335 | |
| 2328 | 2336 | /* Additional checks that occur when opening the check-out database */ |
| 2329 | 2337 | if( g.localOpen ){ |
| 2330 | 2338 | |
| 2331 | 2339 | /* If the repository database that was just opened has been |
| 2332 | 2340 | |