Fossil SCM
Make sure the built-in "now()" function is available to peer-repository connections for single-signon operations. Ticket [3233c3dad99d57ad].
Commit
74ecc4d646ba781deb06abf0900878eee42675e9
Parent
d5b9674ec5232df…
2 files changed
+1
-1
+4
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -615,11 +615,11 @@ | ||
| 615 | 615 | |
| 616 | 616 | /* |
| 617 | 617 | ** Function to return the number of seconds since 1970. This is |
| 618 | 618 | ** the same as strftime('%s','now') but is more compact. |
| 619 | 619 | */ |
| 620 | -static void db_now_function( | |
| 620 | +void db_now_function( | |
| 621 | 621 | sqlite3_context *context, |
| 622 | 622 | int argc, |
| 623 | 623 | sqlite3_value **argv |
| 624 | 624 | ){ |
| 625 | 625 | sqlite3_result_int64(context, time(0)); |
| 626 | 626 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -615,11 +615,11 @@ | |
| 615 | |
| 616 | /* |
| 617 | ** Function to return the number of seconds since 1970. This is |
| 618 | ** the same as strftime('%s','now') but is more compact. |
| 619 | */ |
| 620 | static void db_now_function( |
| 621 | sqlite3_context *context, |
| 622 | int argc, |
| 623 | sqlite3_value **argv |
| 624 | ){ |
| 625 | sqlite3_result_int64(context, time(0)); |
| 626 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -615,11 +615,11 @@ | |
| 615 | |
| 616 | /* |
| 617 | ** Function to return the number of seconds since 1970. This is |
| 618 | ** the same as strftime('%s','now') but is more compact. |
| 619 | */ |
| 620 | void db_now_function( |
| 621 | sqlite3_context *context, |
| 622 | int argc, |
| 623 | sqlite3_value **argv |
| 624 | ){ |
| 625 | sqlite3_result_int64(context, time(0)); |
| 626 |
+4
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -480,10 +480,12 @@ | ||
| 480 | 480 | ); |
| 481 | 481 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 482 | 482 | |
| 483 | 483 | rc = sqlite3_open(zOtherRepo, &pOther); |
| 484 | 484 | if( rc==SQLITE_OK ){ |
| 485 | + sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0); | |
| 486 | + sqlite3_busy_timeout(pOther, 5000); | |
| 485 | 487 | zSQL = mprintf( |
| 486 | 488 | "SELECT cexpire FROM user" |
| 487 | 489 | " WHERE cookie=%Q" |
| 488 | 490 | " AND ipaddr=%Q" |
| 489 | 491 | " AND login=%Q" |
| @@ -1127,10 +1129,12 @@ | ||
| 1127 | 1129 | sqlite3_close(pPeer); |
| 1128 | 1130 | continue; |
| 1129 | 1131 | } |
| 1130 | 1132 | sqlite3_create_function(pPeer, "shared_secret", 3, SQLITE_UTF8, |
| 1131 | 1133 | 0, sha1_shared_secret_sql_function, 0, 0); |
| 1134 | + sqlite3_create_function(pPeer, "now", 0,SQLITE_ANY,0,db_now_function,0,0); | |
| 1135 | + sqlite3_busy_timeout(pPeer, 5000); | |
| 1132 | 1136 | zErr = 0; |
| 1133 | 1137 | rc = sqlite3_exec(pPeer, zSql, 0, 0, &zErr); |
| 1134 | 1138 | if( zErr ){ |
| 1135 | 1139 | blob_appendf(&err, "%s%s: %s%s", zPrefix, zRepoName, zErr, zSuffix); |
| 1136 | 1140 | sqlite3_free(zErr); |
| 1137 | 1141 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -480,10 +480,12 @@ | |
| 480 | ); |
| 481 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 482 | |
| 483 | rc = sqlite3_open(zOtherRepo, &pOther); |
| 484 | if( rc==SQLITE_OK ){ |
| 485 | zSQL = mprintf( |
| 486 | "SELECT cexpire FROM user" |
| 487 | " WHERE cookie=%Q" |
| 488 | " AND ipaddr=%Q" |
| 489 | " AND login=%Q" |
| @@ -1127,10 +1129,12 @@ | |
| 1127 | sqlite3_close(pPeer); |
| 1128 | continue; |
| 1129 | } |
| 1130 | sqlite3_create_function(pPeer, "shared_secret", 3, SQLITE_UTF8, |
| 1131 | 0, sha1_shared_secret_sql_function, 0, 0); |
| 1132 | zErr = 0; |
| 1133 | rc = sqlite3_exec(pPeer, zSql, 0, 0, &zErr); |
| 1134 | if( zErr ){ |
| 1135 | blob_appendf(&err, "%s%s: %s%s", zPrefix, zRepoName, zErr, zSuffix); |
| 1136 | sqlite3_free(zErr); |
| 1137 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -480,10 +480,12 @@ | |
| 480 | ); |
| 481 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 482 | |
| 483 | rc = sqlite3_open(zOtherRepo, &pOther); |
| 484 | if( rc==SQLITE_OK ){ |
| 485 | sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0); |
| 486 | sqlite3_busy_timeout(pOther, 5000); |
| 487 | zSQL = mprintf( |
| 488 | "SELECT cexpire FROM user" |
| 489 | " WHERE cookie=%Q" |
| 490 | " AND ipaddr=%Q" |
| 491 | " AND login=%Q" |
| @@ -1127,10 +1129,12 @@ | |
| 1129 | sqlite3_close(pPeer); |
| 1130 | continue; |
| 1131 | } |
| 1132 | sqlite3_create_function(pPeer, "shared_secret", 3, SQLITE_UTF8, |
| 1133 | 0, sha1_shared_secret_sql_function, 0, 0); |
| 1134 | sqlite3_create_function(pPeer, "now", 0,SQLITE_ANY,0,db_now_function,0,0); |
| 1135 | sqlite3_busy_timeout(pPeer, 5000); |
| 1136 | zErr = 0; |
| 1137 | rc = sqlite3_exec(pPeer, zSql, 0, 0, &zErr); |
| 1138 | if( zErr ){ |
| 1139 | blob_appendf(&err, "%s%s: %s%s", zPrefix, zRepoName, zErr, zSuffix); |
| 1140 | sqlite3_free(zErr); |
| 1141 |