Fossil SCM

Make sure the built-in "now()" function is available to peer-repository connections for single-signon operations. Ticket [3233c3dad99d57ad].

drh 2011-06-02 14:56 trunk
Commit 74ecc4d646ba781deb06abf0900878eee42675e9
2 files changed +1 -1 +4
+1 -1
--- src/db.c
+++ src/db.c
@@ -615,11 +615,11 @@
615615
616616
/*
617617
** Function to return the number of seconds since 1970. This is
618618
** the same as strftime('%s','now') but is more compact.
619619
*/
620
-static void db_now_function(
620
+void db_now_function(
621621
sqlite3_context *context,
622622
int argc,
623623
sqlite3_value **argv
624624
){
625625
sqlite3_result_int64(context, time(0));
626626
--- 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
--- src/login.c
+++ src/login.c
@@ -480,10 +480,12 @@
480480
);
481481
if( zOtherRepo==0 ) return 0; /* No such peer repository */
482482
483483
rc = sqlite3_open(zOtherRepo, &pOther);
484484
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);
485487
zSQL = mprintf(
486488
"SELECT cexpire FROM user"
487489
" WHERE cookie=%Q"
488490
" AND ipaddr=%Q"
489491
" AND login=%Q"
@@ -1127,10 +1129,12 @@
11271129
sqlite3_close(pPeer);
11281130
continue;
11291131
}
11301132
sqlite3_create_function(pPeer, "shared_secret", 3, SQLITE_UTF8,
11311133
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);
11321136
zErr = 0;
11331137
rc = sqlite3_exec(pPeer, zSql, 0, 0, &zErr);
11341138
if( zErr ){
11351139
blob_appendf(&err, "%s%s: %s%s", zPrefix, zRepoName, zErr, zSuffix);
11361140
sqlite3_free(zErr);
11371141
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button