Fossil SCM

Get "configuration push" working. Fix bugs in concealed-field processing of tickets.

drh 2008-10-25 20:43 trunk
Commit 31e94c0a04f2a50007ca6d4dc771cbb532fb4bf1
+1 -1
--- src/encode.c
+++ src/encode.c
@@ -291,11 +291,11 @@
291291
default: c = z[i]; break;
292292
}
293293
}
294294
z[j++] = c;
295295
}
296
- z[j] = 0;
296
+ if( z[j] ) z[j] = 0;
297297
}
298298
299299
300300
/*
301301
** The characters used for HTTP base64 encoding.
302302
--- src/encode.c
+++ src/encode.c
@@ -291,11 +291,11 @@
291 default: c = z[i]; break;
292 }
293 }
294 z[j++] = c;
295 }
296 z[j] = 0;
297 }
298
299
300 /*
301 ** The characters used for HTTP base64 encoding.
302
--- src/encode.c
+++ src/encode.c
@@ -291,11 +291,11 @@
291 default: c = z[i]; break;
292 }
293 }
294 z[j++] = c;
295 }
296 if( z[j] ) z[j] = 0;
297 }
298
299
300 /*
301 ** The characters used for HTTP base64 encoding.
302
+1 -1
--- src/main.c
+++ src/main.c
@@ -708,11 +708,11 @@
708708
int iPort;
709709
const char *zPort;
710710
char *zBrowser;
711711
char *zBrowserCmd = 0;
712712
713
- g.thTrace = find_option("th_trace", 0, 0)!=0;
713
+ g.thTrace = find_option("th-trace", 0, 0)!=0;
714714
if( g.thTrace ){
715715
blob_zero(&g.thLog);
716716
}
717717
zPort = find_option("port", "P", 1);
718718
if( zPort ){
719719
--- src/main.c
+++ src/main.c
@@ -708,11 +708,11 @@
708 int iPort;
709 const char *zPort;
710 char *zBrowser;
711 char *zBrowserCmd = 0;
712
713 g.thTrace = find_option("th_trace", 0, 0)!=0;
714 if( g.thTrace ){
715 blob_zero(&g.thLog);
716 }
717 zPort = find_option("port", "P", 1);
718 if( zPort ){
719
--- src/main.c
+++ src/main.c
@@ -708,11 +708,11 @@
708 int iPort;
709 const char *zPort;
710 char *zBrowser;
711 char *zBrowserCmd = 0;
712
713 g.thTrace = find_option("th-trace", 0, 0)!=0;
714 if( g.thTrace ){
715 blob_zero(&g.thLog);
716 }
717 zPort = find_option("port", "P", 1);
718 if( zPort ){
719
+5 -4
--- src/manifest.c
+++ src/manifest.c
@@ -317,21 +317,22 @@
317317
}
318318
break;
319319
}
320320
321321
/*
322
- ** J '+'?<name> <value>
322
+ ** J <name> ?<value>?
323323
**
324324
** Specifies a name value pair for ticket. If the first character
325
- ** of <name> is "+" then the value is appended to any preexisting
326
- ** value.
325
+ ** of <name> is "+" then the <value> is appended to any preexisting
326
+ ** value. If <value> is omitted then it is understood to be an
327
+ ** empty string.
327328
*/
328329
case 'J': {
329330
char *zName, *zValue;
330331
md5sum_step_text(blob_buffer(&line), blob_size(&line));
331332
if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
332
- if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
333
+ blob_token(&line, &a2);
333334
if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
334335
zName = blob_terminate(&a1);
335336
zValue = blob_terminate(&a2);
336337
defossilize(zValue);
337338
if( p->nField>=p->nFieldAlloc ){
338339
--- src/manifest.c
+++ src/manifest.c
@@ -317,21 +317,22 @@
317 }
318 break;
319 }
320
321 /*
322 ** J '+'?<name> <value>
323 **
324 ** Specifies a name value pair for ticket. If the first character
325 ** of <name> is "+" then the value is appended to any preexisting
326 ** value.
 
327 */
328 case 'J': {
329 char *zName, *zValue;
330 md5sum_step_text(blob_buffer(&line), blob_size(&line));
331 if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
332 if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
333 if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
334 zName = blob_terminate(&a1);
335 zValue = blob_terminate(&a2);
336 defossilize(zValue);
337 if( p->nField>=p->nFieldAlloc ){
338
--- src/manifest.c
+++ src/manifest.c
@@ -317,21 +317,22 @@
317 }
318 break;
319 }
320
321 /*
322 ** J <name> ?<value>?
323 **
324 ** Specifies a name value pair for ticket. If the first character
325 ** of <name> is "+" then the <value> is appended to any preexisting
326 ** value. If <value> is omitted then it is understood to be an
327 ** empty string.
328 */
329 case 'J': {
330 char *zName, *zValue;
331 md5sum_step_text(blob_buffer(&line), blob_size(&line));
332 if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
333 blob_token(&line, &a2);
334 if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
335 zName = blob_terminate(&a1);
336 zValue = blob_terminate(&a2);
337 defossilize(zValue);
338 if( p->nField>=p->nFieldAlloc ){
339
+9 -7
--- src/tkt.c
+++ src/tkt.c
@@ -98,12 +98,13 @@
9898
**
9999
** Only load those fields which do not already exist as
100100
** variables.
101101
**
102102
** Fields of the TICKET table that begin with "private_" are
103
-** expanded using the db_reveal() function. This function will
104
-** decode the content so that it is legable if g.okRdAddr is true.
103
+** expanded using the db_reveal() function. If g.okRdAddr is
104
+** true, then the db_reveal() function will decode the content
105
+** using the CONCEALED table so that the content legable.
105106
** Otherwise, db_reveal() is a no-op and the content remains
106107
** obscured.
107108
*/
108109
static void initializeVariablesFromDb(void){
109110
const char *zName;
@@ -417,16 +418,17 @@
417418
fossilize(azAppend[i], -1));
418419
}else{
419420
zValue = Th_Fetch(azField[i], &nValue);
420421
if( zValue ){
421422
while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }
422
- if( strncmp(azField[i], "private_", 8)==0 ){
423
- zValue = db_conceal(zValue, nValue);
424
- nValue = strlen(zValue);
425
- }
426423
if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
427
- blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
424
+ if( strncmp(azField[i], "private_", 8)==0 ){
425
+ zValue = db_conceal(zValue, nValue);
426
+ blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
427
+ }else{
428
+ blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
429
+ }
428430
}
429431
}
430432
}
431433
}
432434
if( *(char**)pUuid ){
433435
--- src/tkt.c
+++ src/tkt.c
@@ -98,12 +98,13 @@
98 **
99 ** Only load those fields which do not already exist as
100 ** variables.
101 **
102 ** Fields of the TICKET table that begin with "private_" are
103 ** expanded using the db_reveal() function. This function will
104 ** decode the content so that it is legable if g.okRdAddr is true.
 
105 ** Otherwise, db_reveal() is a no-op and the content remains
106 ** obscured.
107 */
108 static void initializeVariablesFromDb(void){
109 const char *zName;
@@ -417,16 +418,17 @@
417 fossilize(azAppend[i], -1));
418 }else{
419 zValue = Th_Fetch(azField[i], &nValue);
420 if( zValue ){
421 while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }
422 if( strncmp(azField[i], "private_", 8)==0 ){
423 zValue = db_conceal(zValue, nValue);
424 nValue = strlen(zValue);
425 }
426 if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
427 blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
 
 
 
 
 
428 }
429 }
430 }
431 }
432 if( *(char**)pUuid ){
433
--- src/tkt.c
+++ src/tkt.c
@@ -98,12 +98,13 @@
98 **
99 ** Only load those fields which do not already exist as
100 ** variables.
101 **
102 ** Fields of the TICKET table that begin with "private_" are
103 ** expanded using the db_reveal() function. If g.okRdAddr is
104 ** true, then the db_reveal() function will decode the content
105 ** using the CONCEALED table so that the content legable.
106 ** Otherwise, db_reveal() is a no-op and the content remains
107 ** obscured.
108 */
109 static void initializeVariablesFromDb(void){
110 const char *zName;
@@ -417,16 +418,17 @@
418 fossilize(azAppend[i], -1));
419 }else{
420 zValue = Th_Fetch(azField[i], &nValue);
421 if( zValue ){
422 while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }
 
 
 
 
423 if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
424 if( strncmp(azField[i], "private_", 8)==0 ){
425 zValue = db_conceal(zValue, nValue);
426 blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
427 }else{
428 blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
429 }
430 }
431 }
432 }
433 }
434 if( *(char**)pUuid ){
435
+3 -2
--- src/xfer.c
+++ src/xfer.c
@@ -390,11 +390,11 @@
390390
g.userUid = db_column_int(&q, 2);
391391
g.zLogin = mprintf("%b", pLogin);
392392
g.zNonce = mprintf("%b", pNonce);
393393
}
394394
}
395
- db_reset(&q);
395
+ db_finalize(&q);
396396
}
397397
398398
/*
399399
** Send the content of all files in the unsent table.
400400
**
@@ -720,11 +720,11 @@
720720
Blob content;
721721
blob_zero(&content);
722722
blob_extract(xfer.pIn, size, &content);
723723
if( !g.okAdmin ){
724724
cgi_reset_content();
725
- @ error not\sauthorized\sto\spush\sconfiguration\data
725
+ @ error not\sauthorized\sto\spush\sconfiguration
726726
nErr++;
727727
break;
728728
}
729729
if( zName[0]!='@' ){
730730
if( !recvConfig ){
@@ -1077,10 +1077,11 @@
10771077
&& blob_is_int(&xfer.aToken[2], &size) ){
10781078
const char *zName = blob_str(&xfer.aToken[1]);
10791079
Blob content;
10801080
blob_zero(&content);
10811081
blob_extract(xfer.pIn, size, &content);
1082
+ g.okAdmin = g.okRdAddr = 1;
10821083
if( configure_is_exportable(zName) & origConfigRcvMask ){
10831084
if( zName[0]!='@' ){
10841085
db_multi_exec(
10851086
"REPLACE INTO config(name,value) VALUES(%Q,%Q)",
10861087
zName, blob_str(&content)
10871088
--- src/xfer.c
+++ src/xfer.c
@@ -390,11 +390,11 @@
390 g.userUid = db_column_int(&q, 2);
391 g.zLogin = mprintf("%b", pLogin);
392 g.zNonce = mprintf("%b", pNonce);
393 }
394 }
395 db_reset(&q);
396 }
397
398 /*
399 ** Send the content of all files in the unsent table.
400 **
@@ -720,11 +720,11 @@
720 Blob content;
721 blob_zero(&content);
722 blob_extract(xfer.pIn, size, &content);
723 if( !g.okAdmin ){
724 cgi_reset_content();
725 @ error not\sauthorized\sto\spush\sconfiguration\data
726 nErr++;
727 break;
728 }
729 if( zName[0]!='@' ){
730 if( !recvConfig ){
@@ -1077,10 +1077,11 @@
1077 && blob_is_int(&xfer.aToken[2], &size) ){
1078 const char *zName = blob_str(&xfer.aToken[1]);
1079 Blob content;
1080 blob_zero(&content);
1081 blob_extract(xfer.pIn, size, &content);
 
1082 if( configure_is_exportable(zName) & origConfigRcvMask ){
1083 if( zName[0]!='@' ){
1084 db_multi_exec(
1085 "REPLACE INTO config(name,value) VALUES(%Q,%Q)",
1086 zName, blob_str(&content)
1087
--- src/xfer.c
+++ src/xfer.c
@@ -390,11 +390,11 @@
390 g.userUid = db_column_int(&q, 2);
391 g.zLogin = mprintf("%b", pLogin);
392 g.zNonce = mprintf("%b", pNonce);
393 }
394 }
395 db_finalize(&q);
396 }
397
398 /*
399 ** Send the content of all files in the unsent table.
400 **
@@ -720,11 +720,11 @@
720 Blob content;
721 blob_zero(&content);
722 blob_extract(xfer.pIn, size, &content);
723 if( !g.okAdmin ){
724 cgi_reset_content();
725 @ error not\sauthorized\sto\spush\sconfiguration
726 nErr++;
727 break;
728 }
729 if( zName[0]!='@' ){
730 if( !recvConfig ){
@@ -1077,10 +1077,11 @@
1077 && blob_is_int(&xfer.aToken[2], &size) ){
1078 const char *zName = blob_str(&xfer.aToken[1]);
1079 Blob content;
1080 blob_zero(&content);
1081 blob_extract(xfer.pIn, size, &content);
1082 g.okAdmin = g.okRdAddr = 1;
1083 if( configure_is_exportable(zName) & origConfigRcvMask ){
1084 if( zName[0]!='@' ){
1085 db_multi_exec(
1086 "REPLACE INTO config(name,value) VALUES(%Q,%Q)",
1087 zName, blob_str(&content)
1088

Keyboard Shortcuts

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