Fossil

Check-in [31e94c0a04]
Login

Check-in [31e94c0a04]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Get "configuration push" working. Fix bugs in concealed-field processing of tickets.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 31e94c0a04f2a50007ca6d4dc771cbb532fb4bf1
User & Date: drh 2008-10-25 20:43:28.000
Context
2008-10-26
02:16
Change the default subsystem list for tickets to an empty set. Update documentation to begin making a clearer distinction between local state and global state. ... (check-in: efb759a07d user: drh tags: trunk)
2008-10-25
20:43
Get "configuration push" working. Fix bugs in concealed-field processing of tickets. ... (check-in: 31e94c0a04 user: drh tags: trunk)
17:51
Add logic to do a configuration push. Add logic to synchronize the CONCEALED table containing hidden email addresses (assuming appropriate permissions). Additional testng is needed; this check-in is to transfer the work to another machine. ... (check-in: 6b0b57a924 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/encode.c.
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
        case '0':  c = 0;     break;
        case '\\': c = '\\';  break;
        default:   c = z[i];  break;
      }
    }
    z[j++] = c;
  }
  z[j] = 0;
}


/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] = 







|







289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
        case '0':  c = 0;     break;
        case '\\': c = '\\';  break;
        default:   c = z[i];  break;
      }
    }
    z[j++] = c;
  }
  if( z[j] ) z[j] = 0;
}


/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] = 
Changes to src/main.c.
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
*/
void cmd_webserver(void){
  int iPort;
  const char *zPort;
  char *zBrowser;
  char *zBrowserCmd = 0;

  g.thTrace = find_option("th_trace", 0, 0)!=0;
  if( g.thTrace ){
    blob_zero(&g.thLog);
  }
  zPort = find_option("port", "P", 1);
  if( zPort ){
    iPort = atoi(zPort);
  }else{







|







706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
*/
void cmd_webserver(void){
  int iPort;
  const char *zPort;
  char *zBrowser;
  char *zBrowserCmd = 0;

  g.thTrace = find_option("th-trace", 0, 0)!=0;
  if( g.thTrace ){
    blob_zero(&g.thLog);
  }
  zPort = find_option("port", "P", 1);
  if( zPort ){
    iPort = atoi(zPort);
  }else{
Changes to src/manifest.c.
315
316
317
318
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
338
339
        if( i>0 && strcmp(p->aFile[i-1].zName, zName)>=0 ){
          goto manifest_syntax_error;
        }
        break;
      }

      /*
      **     J '+'?<name> <value>
      **
      ** Specifies a name value pair for ticket.  If the first character
      ** of <name> is "+" then the value is appended to any preexisting
      ** value.

      */
      case 'J': {
        char *zName, *zValue;
        md5sum_step_text(blob_buffer(&line), blob_size(&line));
        if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
        if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
        if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
        zName = blob_terminate(&a1);
        zValue = blob_terminate(&a2);
        defossilize(zValue);
        if( p->nField>=p->nFieldAlloc ){
          p->nFieldAlloc = p->nFieldAlloc*2 + 10;
          p->aField = realloc(p->aField,







|


|
|
>





|







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
        if( i>0 && strcmp(p->aFile[i-1].zName, zName)>=0 ){
          goto manifest_syntax_error;
        }
        break;
      }

      /*
      **     J <name> ?<value>?
      **
      ** Specifies a name value pair for ticket.  If the first character
      ** of <name> is "+" then the <value> is appended to any preexisting
      ** value.  If <value> is omitted then it is understood to be an
      ** empty string.
      */
      case 'J': {
        char *zName, *zValue;
        md5sum_step_text(blob_buffer(&line), blob_size(&line));
        if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
        blob_token(&line, &a2);
        if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
        zName = blob_terminate(&a1);
        zValue = blob_terminate(&a2);
        defossilize(zValue);
        if( p->nField>=p->nFieldAlloc ){
          p->nFieldAlloc = p->nFieldAlloc*2 + 10;
          p->aField = realloc(p->aField,
Changes to src/tkt.c.
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
** ticket whose name is given by the "name" CGI parameter.
** Load the values for all fields into the interpreter.
**
** Only load those fields which do not already exist as
** variables.
**
** Fields of the TICKET table that begin with "private_" are
** expanded using the db_reveal() function.  This function will

** decode the content so that it is legable if g.okRdAddr is true.
** Otherwise, db_reveal() is a no-op and the content remains
** obscured.
*/
static void initializeVariablesFromDb(void){
  const char *zName;
  Stmt q;
  int i, n, size, j;







|
>
|







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
** ticket whose name is given by the "name" CGI parameter.
** Load the values for all fields into the interpreter.
**
** Only load those fields which do not already exist as
** variables.
**
** Fields of the TICKET table that begin with "private_" are
** expanded using the db_reveal() function.  If g.okRdAddr is
** true, then the db_reveal() function will decode the content
** using the CONCEALED table so that the content legable.
** Otherwise, db_reveal() is a no-op and the content remains
** obscured.
*/
static void initializeVariablesFromDb(void){
  const char *zName;
  Stmt q;
  int i, n, size, j;
415
416
417
418
419
420
421

422
423
424
425
426
427

428
429
430
431
432
433
434
    if( azAppend[i] ){
      blob_appendf(&tktchng, "J +%s %z\n", azField[i],
                   fossilize(azAppend[i], -1));
    }else{
      zValue = Th_Fetch(azField[i], &nValue);
      if( zValue ){
        while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }

        if( strncmp(azField[i], "private_", 8)==0 ){
          zValue = db_conceal(zValue, nValue);
          nValue = strlen(zValue);
        }
        if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
          blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);

        }
      }
    }
  }
  if( *(char**)pUuid ){
    zUuid = db_text(0, 
       "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", P("name")







>
|
|
|
|
<
|
>







416
417
418
419
420
421
422
423
424
425
426
427

428
429
430
431
432
433
434
435
436
    if( azAppend[i] ){
      blob_appendf(&tktchng, "J +%s %z\n", azField[i],
                   fossilize(azAppend[i], -1));
    }else{
      zValue = Th_Fetch(azField[i], &nValue);
      if( zValue ){
        while( nValue>0 && isspace(zValue[nValue-1]) ){ nValue--; }
        if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
          if( strncmp(azField[i], "private_", 8)==0 ){
            zValue = db_conceal(zValue, nValue);
            blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
          }else{

            blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
          }
        }
      }
    }
  }
  if( *(char**)pUuid ){
    zUuid = db_text(0, 
       "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", P("name")
Changes to src/xfer.c.
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      zCap = db_column_text(&q, 1);
      login_set_capabilities(zCap);
      g.userUid = db_column_int(&q, 2);
      g.zLogin = mprintf("%b", pLogin);
      g.zNonce = mprintf("%b", pNonce);
    }
  }
  db_reset(&q);
}

/*
** Send the content of all files in the unsent table.
**
** This is really just an optimization.  If you clear the
** unsent table, all the right files will still get transferred.







|







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      zCap = db_column_text(&q, 1);
      login_set_capabilities(zCap);
      g.userUid = db_column_int(&q, 2);
      g.zLogin = mprintf("%b", pLogin);
      g.zNonce = mprintf("%b", pNonce);
    }
  }
  db_finalize(&q);
}

/*
** Send the content of all files in the unsent table.
**
** This is really just an optimization.  If you clear the
** unsent table, all the right files will still get transferred.
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
        && blob_is_int(&xfer.aToken[2], &size) ){
      const char *zName = blob_str(&xfer.aToken[1]);
      Blob content;
      blob_zero(&content);
      blob_extract(xfer.pIn, size, &content);
      if( !g.okAdmin ){
        cgi_reset_content();
        @ error not\sauthorized\sto\spush\sconfiguration\data
        nErr++;
        break;
      }
      if( zName[0]!='@' ){
        if( !recvConfig ){
          configure_prepare_to_receive(0);
          recvConfig = 1;







|







718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
        && blob_is_int(&xfer.aToken[2], &size) ){
      const char *zName = blob_str(&xfer.aToken[1]);
      Blob content;
      blob_zero(&content);
      blob_extract(xfer.pIn, size, &content);
      if( !g.okAdmin ){
        cgi_reset_content();
        @ error not\sauthorized\sto\spush\sconfiguration
        nErr++;
        break;
      }
      if( zName[0]!='@' ){
        if( !recvConfig ){
          configure_prepare_to_receive(0);
          recvConfig = 1;
1075
1076
1077
1078
1079
1080
1081

1082
1083
1084
1085
1086
1087
1088
      */
      if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
          && blob_is_int(&xfer.aToken[2], &size) ){
        const char *zName = blob_str(&xfer.aToken[1]);
        Blob content;
        blob_zero(&content);
        blob_extract(xfer.pIn, size, &content);

        if( configure_is_exportable(zName) & origConfigRcvMask ){
          if( zName[0]!='@' ){
            db_multi_exec(
                "REPLACE INTO config(name,value) VALUES(%Q,%Q)",
                zName, blob_str(&content)
            );
          }else{







>







1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
      */
      if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
          && blob_is_int(&xfer.aToken[2], &size) ){
        const char *zName = blob_str(&xfer.aToken[1]);
        Blob content;
        blob_zero(&content);
        blob_extract(xfer.pIn, size, &content);
        g.okAdmin = g.okRdAddr = 1;
        if( configure_is_exportable(zName) & origConfigRcvMask ){
          if( zName[0]!='@' ){
            db_multi_exec(
                "REPLACE INTO config(name,value) VALUES(%Q,%Q)",
                zName, blob_str(&content)
            );
          }else{