Fossil SCM
If there is a need to do lazy updates of the full text index during a request that is not from the same origin, then allow database writes for the duration of that update. Also, allow changes to USER and CONFIG tables when explicitly authorized by db_unprotect() even if the request that prompted the change is not from the same origin.
Commit
8e85d6ca2281b8dd2472ceab37449ef831b97c9eac67fc4337f26cbceb252288
Parent
db1626281796e93…
2 files changed
+1
-1
+2
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -459,11 +459,11 @@ | ||
| 459 | 459 | void db_unprotect(unsigned flags){ |
| 460 | 460 | if( db.nProtect>=count(db.aProtect)-2 ){ |
| 461 | 461 | fossil_panic("too many db_unprotect() calls"); |
| 462 | 462 | } |
| 463 | 463 | db.aProtect[db.nProtect++] = db.protectMask; |
| 464 | - db.protectMask &= ~flags; | |
| 464 | + db.protectMask &= ~(flags|PROTECT_READONLY); | |
| 465 | 465 | } |
| 466 | 466 | void db_protect_pop(void){ |
| 467 | 467 | if( db.nProtect<1 ){ |
| 468 | 468 | fossil_panic("too many db_protect_pop() calls"); |
| 469 | 469 | } |
| 470 | 470 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -459,11 +459,11 @@ | |
| 459 | void db_unprotect(unsigned flags){ |
| 460 | if( db.nProtect>=count(db.aProtect)-2 ){ |
| 461 | fossil_panic("too many db_unprotect() calls"); |
| 462 | } |
| 463 | db.aProtect[db.nProtect++] = db.protectMask; |
| 464 | db.protectMask &= ~flags; |
| 465 | } |
| 466 | void db_protect_pop(void){ |
| 467 | if( db.nProtect<1 ){ |
| 468 | fossil_panic("too many db_protect_pop() calls"); |
| 469 | } |
| 470 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -459,11 +459,11 @@ | |
| 459 | void db_unprotect(unsigned flags){ |
| 460 | if( db.nProtect>=count(db.aProtect)-2 ){ |
| 461 | fossil_panic("too many db_unprotect() calls"); |
| 462 | } |
| 463 | db.aProtect[db.nProtect++] = db.protectMask; |
| 464 | db.protectMask &= ~(flags|PROTECT_READONLY); |
| 465 | } |
| 466 | void db_protect_pop(void){ |
| 467 | if( db.nProtect<1 ){ |
| 468 | fossil_panic("too many db_protect_pop() calls"); |
| 469 | } |
| 470 |
+2
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -1814,10 +1814,11 @@ | ||
| 1814 | 1814 | */ |
| 1815 | 1815 | void search_update_index(unsigned int srchFlags){ |
| 1816 | 1816 | if( !search_index_exists() ) return; |
| 1817 | 1817 | if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return; |
| 1818 | 1818 | search_sql_setup(g.db); |
| 1819 | + db_unprotect(PROTECT_READONLY); | |
| 1819 | 1820 | if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){ |
| 1820 | 1821 | search_update_doc_index(); |
| 1821 | 1822 | search_update_checkin_index(); |
| 1822 | 1823 | } |
| 1823 | 1824 | if( srchFlags & SRCH_TKT ){ |
| @@ -1830,10 +1831,11 @@ | ||
| 1830 | 1831 | search_update_technote_index(); |
| 1831 | 1832 | } |
| 1832 | 1833 | if( srchFlags & SRCH_FORUM ){ |
| 1833 | 1834 | search_update_forum_index(); |
| 1834 | 1835 | } |
| 1836 | + db_protect_pop(); | |
| 1835 | 1837 | } |
| 1836 | 1838 | |
| 1837 | 1839 | /* |
| 1838 | 1840 | ** Construct, prepopulate, and then update the full-text index. |
| 1839 | 1841 | */ |
| 1840 | 1842 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1814,10 +1814,11 @@ | |
| 1814 | */ |
| 1815 | void search_update_index(unsigned int srchFlags){ |
| 1816 | if( !search_index_exists() ) return; |
| 1817 | if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return; |
| 1818 | search_sql_setup(g.db); |
| 1819 | if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){ |
| 1820 | search_update_doc_index(); |
| 1821 | search_update_checkin_index(); |
| 1822 | } |
| 1823 | if( srchFlags & SRCH_TKT ){ |
| @@ -1830,10 +1831,11 @@ | |
| 1830 | search_update_technote_index(); |
| 1831 | } |
| 1832 | if( srchFlags & SRCH_FORUM ){ |
| 1833 | search_update_forum_index(); |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | /* |
| 1838 | ** Construct, prepopulate, and then update the full-text index. |
| 1839 | */ |
| 1840 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1814,10 +1814,11 @@ | |
| 1814 | */ |
| 1815 | void search_update_index(unsigned int srchFlags){ |
| 1816 | if( !search_index_exists() ) return; |
| 1817 | if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return; |
| 1818 | search_sql_setup(g.db); |
| 1819 | db_unprotect(PROTECT_READONLY); |
| 1820 | if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){ |
| 1821 | search_update_doc_index(); |
| 1822 | search_update_checkin_index(); |
| 1823 | } |
| 1824 | if( srchFlags & SRCH_TKT ){ |
| @@ -1830,10 +1831,11 @@ | |
| 1831 | search_update_technote_index(); |
| 1832 | } |
| 1833 | if( srchFlags & SRCH_FORUM ){ |
| 1834 | search_update_forum_index(); |
| 1835 | } |
| 1836 | db_protect_pop(); |
| 1837 | } |
| 1838 | |
| 1839 | /* |
| 1840 | ** Construct, prepopulate, and then update the full-text index. |
| 1841 | */ |
| 1842 |