Fossil SCM

Some rephrasing and code cleanup.

jan 2011-03-31 15:30 UTC jan-clientcert
Commit cff102fe85949448d93305a246c02884fa5d76f0
+2 -2
--- src/clone.c
+++ src/clone.c
@@ -37,11 +37,11 @@
3737
**
3838
** Options:
3939
**
4040
** --admin-user|-A USERNAME Make USERNAME the administrator
4141
** --private Also clone private branches
42
-** --certgroup NAME Use certificate group NAME for https
42
+** --certbundle NAME Use certificate bundle NAME for https
4343
** connections
4444
**
4545
*/
4646
void clone_cmd(void){
4747
char *zPassword;
@@ -48,11 +48,11 @@
4848
const char *zDefaultUser; /* Optional name of the default user */
4949
int nErr = 0;
5050
int bPrivate; /* Also clone private branches */
5151
5252
bPrivate = find_option("private",0,0)!=0;
53
- g.urlCertGroup = find_option("certgroup",0,1);
53
+ g.urlCertBundle = find_option("certbundle",0,1);
5454
url_proxy_options();
5555
if( g.argc < 4 ){
5656
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
5757
}
5858
db_open_config(0);
5959
--- src/clone.c
+++ src/clone.c
@@ -37,11 +37,11 @@
37 **
38 ** Options:
39 **
40 ** --admin-user|-A USERNAME Make USERNAME the administrator
41 ** --private Also clone private branches
42 ** --certgroup NAME Use certificate group NAME for https
43 ** connections
44 **
45 */
46 void clone_cmd(void){
47 char *zPassword;
@@ -48,11 +48,11 @@
48 const char *zDefaultUser; /* Optional name of the default user */
49 int nErr = 0;
50 int bPrivate; /* Also clone private branches */
51
52 bPrivate = find_option("private",0,0)!=0;
53 g.urlCertGroup = find_option("certgroup",0,1);
54 url_proxy_options();
55 if( g.argc < 4 ){
56 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
57 }
58 db_open_config(0);
59
--- src/clone.c
+++ src/clone.c
@@ -37,11 +37,11 @@
37 **
38 ** Options:
39 **
40 ** --admin-user|-A USERNAME Make USERNAME the administrator
41 ** --private Also clone private branches
42 ** --certbundle NAME Use certificate bundle NAME for https
43 ** connections
44 **
45 */
46 void clone_cmd(void){
47 char *zPassword;
@@ -48,11 +48,11 @@
48 const char *zDefaultUser; /* Optional name of the default user */
49 int nErr = 0;
50 int bPrivate; /* Also clone private branches */
51
52 bPrivate = find_option("private",0,0)!=0;
53 g.urlCertBundle = find_option("certbundle",0,1);
54 url_proxy_options();
55 if( g.argc < 4 ){
56 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
57 }
58 db_open_config(0);
59
+44 -43
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -309,46 +309,46 @@
309309
}
310310
return total;
311311
}
312312
313313
/*
314
-** If an certgroup has been specified on the command line, then use it to look
315
-** up certificates and keys, and then store the URL-certgroup association in
316
-** the global database. If no certgroup has been specified on the command line,
317
-** see if there's an entry for the url in global_config, and use it if
314
+** If a certbundle has been specified on the command line, then use it to look
315
+** up certificates and keys, and then store the URL-certbundle association in
316
+** the global database. If no certbundle has been specified on the command
317
+** line, see if there's an entry for the url in global_config, and use it if
318318
** applicable.
319319
*/
320320
void ssl_load_client_authfiles(void){
321
- char *zGroupName = NULL;
321
+ char *zBundleName = NULL;
322322
char *cafile;
323323
char *capath;
324324
char *certfile;
325325
char *keyfile;
326326
327
- if( g.urlCertGroup ){
327
+ if( g.urlCertBundle ){
328328
char *zName;
329
- zName = mprintf("certgroup:%s", g.urlName);
330
- db_set(zName, g.urlCertGroup, 1);
329
+ zName = mprintf("certbundle:%s", g.urlName);
330
+ db_set(zName, g.urlCertBundle, 1);
331331
free(zName);
332
- zGroupName = strdup(g.urlCertGroup);
332
+ zBundleName = strdup(g.urlCertBundle);
333333
}else{
334334
db_swap_connections();
335
- zGroupName = db_text(0, "SELECT value FROM global_config"
336
- " WHERE name='certgroup:%q'", g.urlName);
335
+ zBundleName = db_text(0, "SELECT value FROM global_config"
336
+ " WHERE name='certbundle:%q'", g.urlName);
337337
db_swap_connections();
338338
}
339
- if( !zGroupName ){
340
- /* No cert group specified or found cached */
339
+ if( !zBundleName ){
340
+ /* No cert bundle specified on command line or found cached for URL */
341341
return;
342342
}
343343
344344
db_swap_connections();
345345
create_cert_table_if_not_exist();
346346
cafile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
347
- " AND type='cafile'", zGroupName);
347
+ " AND type='cafile'", zBundleName);
348348
capath = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
349
- " AND type='capath'", zGroupName);
349
+ " AND type='capath'", zBundleName);
350350
db_swap_connections();
351351
352352
if( cafile || capath ){
353353
/* The OpenSSL documentation warns that if several CA certificates match
354354
** the same name, key identifier and serial number conditions, only the
@@ -361,13 +361,13 @@
361361
}
362362
}
363363
364364
db_swap_connections();
365365
keyfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
366
- " AND type='ckey'", zGroupName);
366
+ " AND type='ckey'", zBundleName);
367367
certfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
368
- " AND type='ccert'", zGroupName);
368
+ " AND type='ccert'", zBundleName);
369369
db_swap_connections();
370370
371371
if( SSL_CTX_use_certificate_file(sslCtx, certfile, SSL_FILETYPE_PEM)<=0 ){
372372
fossil_fatal("SSL: Unable to open client certificate in %s.", certfile);
373373
}
@@ -391,39 +391,39 @@
391391
/*
392392
** COMMAND: cert
393393
**
394394
** Usage: %fossil cert SUBCOMMAND ...
395395
**
396
-** Manage/group PKI keys/certificates to be able to use client
397
-** certificates and register CA certificates for SSL verifications.
396
+** Manage/bundle PKI client keys/certificates and CA certificates for SSL
397
+** certificate chain verifications.
398398
**
399399
** %fossil cert add NAME ?--key KEYFILE? ?--cert CERTFILE?
400400
** ?--cafile CAFILE? ?--capath CAPATH?
401401
**
402
-** Create a certificate group NAME with the associated
402
+** Create a certificate bundle NAME with the associated
403403
** certificates/keys. If a client certificate is specified but no
404404
** key, it is assumed that the key is located in the client
405
-** certificate file. The file format must be PEM.
405
+** certificate file.
406
+** The file formats must be PEM.
406407
**
407408
** %fossil cert list
408409
**
409
-** List all credential groups, their values and their URL
410
+** List all certificate bundles, their values and their URL
410411
** associations.
411412
**
412413
** %fossil cert disassociate URL
413414
**
414
-** Disassociate URL from any credential group(s).
415
+** Disassociate URL from any certificate bundle.
415416
**
416417
** %fossil cert delete NAME
417418
**
418
-** Remove the credential group NAME and all it's associated URL
419
-** associations.
419
+** Remove the certificate bundle NAME and all its URL associations.
420420
**
421421
*/
422422
void cert_cmd(void){
423423
int n;
424
- const char *zCmd = "list";
424
+ const char *zCmd = "list"; /* Default sub-command */
425425
if( g.argc>=3 ){
426426
zCmd = g.argv[2];
427427
}
428428
n = strlen(zCmd);
429429
if( strncmp(zCmd, "add", n)==0 ){
@@ -431,22 +431,22 @@
431431
const char *zCKey;
432432
const char *zCCert;
433433
const char *zCAFile;
434434
const char *zCAPath;
435435
if( g.argc<5 ){
436
- usage("add NAME ?--key CLIENTKEY? ?--cert CLIENTCERT? ?--cafile CAFILE? "
436
+ usage("add NAME ?--key KEYFILE? ?--cert CERTFILE? ?--cafile CAFILE? "
437437
"?--capath CAPATH?");
438438
}
439439
zContainer = g.argv[3];
440440
zCKey = find_option("key",0,1);
441441
zCCert = find_option("cert",0,1);
442442
zCAFile = find_option("cafile",0,1);
443443
zCAPath = find_option("capath",0,1);
444444
445445
/* If a client certificate was specified, but a key was not, assume the
446
- * key is stored in the same file as the certificate.
447
- */
446
+ ** key is stored in the same file as the certificate.
447
+ */
448448
if( !zCKey && zCCert ){
449449
zCKey = zCCert;
450450
}
451451
452452
db_open_config(0);
@@ -453,11 +453,11 @@
453453
db_swap_connections();
454454
create_cert_table_if_not_exist();
455455
db_begin_transaction();
456456
if( db_exists("SELECT 1 FROM certs WHERE name='%q'", zContainer)!=0 ){
457457
db_end_transaction(0);
458
- fossil_fatal("certificate group \"%s\" already exists", zContainer);
458
+ fossil_fatal("certificate bundle \"%s\" already exists", zContainer);
459459
}
460460
if( zCKey ){
461461
db_multi_exec("INSERT INTO certs (name,type,filepath) "
462462
"VALUES(%Q,'ckey',%Q)",
463463
zContainer, zCKey);
@@ -479,11 +479,11 @@
479479
}
480480
db_end_transaction(0);
481481
db_swap_connections();
482482
}else if(strncmp(zCmd, "list", n)==0){
483483
Stmt q;
484
- char *grp = NULL;
484
+ char *bndl = NULL;
485485
486486
db_open_config(0);
487487
db_swap_connections();
488488
create_cert_table_if_not_exist();
489489
@@ -492,33 +492,33 @@
492492
" ORDER BY name,type");
493493
while( db_step(&q)==SQLITE_ROW ){
494494
const char *zCont = db_column_text(&q, 0);
495495
const char *zType = db_column_text(&q, 1);
496496
const char *zFilePath = db_column_text(&q, 2);
497
- if( fossil_strcmp(zCont, grp)!=0 ){
498
- free(grp);
499
- grp = strdup(zCont);
497
+ if( fossil_strcmp(zCont, bndl)!=0 ){
498
+ free(bndl);
499
+ bndl = strdup(zCont);
500500
puts(zCont);
501501
}
502502
printf("\t%s=%s\n", zType, zFilePath);
503503
}
504504
db_finalize(&q);
505505
506506
/* List the URL associations. */
507507
db_prepare(&q, "SELECT name FROM global_config"
508
- " WHERE name LIKE 'certgroup:%%' AND value=%Q"
509
- " ORDER BY name", grp);
510
- free(grp);
508
+ " WHERE name LIKE 'certbundle:%%' AND value=%Q"
509
+ " ORDER BY name", bndl);
510
+ free(bndl);
511511
512512
while( db_step(&q)==SQLITE_ROW ){
513513
const char *zName = db_column_text(&q, 0);
514514
static int first = 1;
515515
if( first ) {
516516
puts("\tAssociations");
517517
first = 0;
518518
}
519
- printf("\t\t%s\n", zName+10);
519
+ printf("\t\t%s\n", zName+11);
520520
}
521521
522522
db_swap_connections();
523523
}else if(strncmp(zCmd, "disassociate", n)==0){
524524
const char *zURL;
@@ -528,17 +528,17 @@
528528
zURL = g.argv[3];
529529
530530
db_open_config(0);
531531
db_swap_connections();
532532
db_begin_transaction();
533
- db_multi_exec("DELETE FROM global_config WHERE name='certgroup:%q'",
533
+ db_multi_exec("DELETE FROM global_config WHERE name='certbundle:%q'",
534534
zURL);
535535
if( db_changes() == 0 ){
536
- fossil_warning("No certificate group associated with URL \"%s\".",
536
+ fossil_warning("No certificate bundle associated with URL \"%s\".",
537537
zURL);
538538
}else{
539
- printf("%s disassociated from its certificate group.\n", zURL);
539
+ printf("%s disassociated from its certificate bundle.\n", zURL);
540540
}
541541
db_end_transaction(0);
542542
db_swap_connections();
543543
544544
}else if(strncmp(zCmd, "delete", n)==0){
@@ -548,19 +548,20 @@
548548
}
549549
zContainer = g.argv[3];
550550
551551
db_open_config(0);
552552
db_swap_connections();
553
+ create_cert_table_if_not_exist();
553554
db_begin_transaction();
554555
db_multi_exec("DELETE FROM certs WHERE name=%Q", zContainer);
555556
if( db_changes() == 0 ){
556
- fossil_warning("No certificate group named \"%s\" found",
557
+ fossil_warning("No certificate bundle named \"%s\" found",
557558
zContainer);
558559
}else{
559560
printf("%d entries removed\n", db_changes());
560561
}
561
- db_multi_exec("DELETE FROM global_config WHERE name LIKE 'certgroup:%%'"
562
+ db_multi_exec("DELETE FROM global_config WHERE name LIKE 'certbundle:%%'"
562563
" AND value=%Q", zContainer);
563564
if( db_changes() > 0 ){
564565
printf("%d associations removed\n", db_changes());
565566
}
566567
db_end_transaction(0);
567568
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -309,46 +309,46 @@
309 }
310 return total;
311 }
312
313 /*
314 ** If an certgroup has been specified on the command line, then use it to look
315 ** up certificates and keys, and then store the URL-certgroup association in
316 ** the global database. If no certgroup has been specified on the command line,
317 ** see if there's an entry for the url in global_config, and use it if
318 ** applicable.
319 */
320 void ssl_load_client_authfiles(void){
321 char *zGroupName = NULL;
322 char *cafile;
323 char *capath;
324 char *certfile;
325 char *keyfile;
326
327 if( g.urlCertGroup ){
328 char *zName;
329 zName = mprintf("certgroup:%s", g.urlName);
330 db_set(zName, g.urlCertGroup, 1);
331 free(zName);
332 zGroupName = strdup(g.urlCertGroup);
333 }else{
334 db_swap_connections();
335 zGroupName = db_text(0, "SELECT value FROM global_config"
336 " WHERE name='certgroup:%q'", g.urlName);
337 db_swap_connections();
338 }
339 if( !zGroupName ){
340 /* No cert group specified or found cached */
341 return;
342 }
343
344 db_swap_connections();
345 create_cert_table_if_not_exist();
346 cafile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
347 " AND type='cafile'", zGroupName);
348 capath = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
349 " AND type='capath'", zGroupName);
350 db_swap_connections();
351
352 if( cafile || capath ){
353 /* The OpenSSL documentation warns that if several CA certificates match
354 ** the same name, key identifier and serial number conditions, only the
@@ -361,13 +361,13 @@
361 }
362 }
363
364 db_swap_connections();
365 keyfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
366 " AND type='ckey'", zGroupName);
367 certfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
368 " AND type='ccert'", zGroupName);
369 db_swap_connections();
370
371 if( SSL_CTX_use_certificate_file(sslCtx, certfile, SSL_FILETYPE_PEM)<=0 ){
372 fossil_fatal("SSL: Unable to open client certificate in %s.", certfile);
373 }
@@ -391,39 +391,39 @@
391 /*
392 ** COMMAND: cert
393 **
394 ** Usage: %fossil cert SUBCOMMAND ...
395 **
396 ** Manage/group PKI keys/certificates to be able to use client
397 ** certificates and register CA certificates for SSL verifications.
398 **
399 ** %fossil cert add NAME ?--key KEYFILE? ?--cert CERTFILE?
400 ** ?--cafile CAFILE? ?--capath CAPATH?
401 **
402 ** Create a certificate group NAME with the associated
403 ** certificates/keys. If a client certificate is specified but no
404 ** key, it is assumed that the key is located in the client
405 ** certificate file. The file format must be PEM.
 
406 **
407 ** %fossil cert list
408 **
409 ** List all credential groups, their values and their URL
410 ** associations.
411 **
412 ** %fossil cert disassociate URL
413 **
414 ** Disassociate URL from any credential group(s).
415 **
416 ** %fossil cert delete NAME
417 **
418 ** Remove the credential group NAME and all it's associated URL
419 ** associations.
420 **
421 */
422 void cert_cmd(void){
423 int n;
424 const char *zCmd = "list";
425 if( g.argc>=3 ){
426 zCmd = g.argv[2];
427 }
428 n = strlen(zCmd);
429 if( strncmp(zCmd, "add", n)==0 ){
@@ -431,22 +431,22 @@
431 const char *zCKey;
432 const char *zCCert;
433 const char *zCAFile;
434 const char *zCAPath;
435 if( g.argc<5 ){
436 usage("add NAME ?--key CLIENTKEY? ?--cert CLIENTCERT? ?--cafile CAFILE? "
437 "?--capath CAPATH?");
438 }
439 zContainer = g.argv[3];
440 zCKey = find_option("key",0,1);
441 zCCert = find_option("cert",0,1);
442 zCAFile = find_option("cafile",0,1);
443 zCAPath = find_option("capath",0,1);
444
445 /* If a client certificate was specified, but a key was not, assume the
446 * key is stored in the same file as the certificate.
447 */
448 if( !zCKey && zCCert ){
449 zCKey = zCCert;
450 }
451
452 db_open_config(0);
@@ -453,11 +453,11 @@
453 db_swap_connections();
454 create_cert_table_if_not_exist();
455 db_begin_transaction();
456 if( db_exists("SELECT 1 FROM certs WHERE name='%q'", zContainer)!=0 ){
457 db_end_transaction(0);
458 fossil_fatal("certificate group \"%s\" already exists", zContainer);
459 }
460 if( zCKey ){
461 db_multi_exec("INSERT INTO certs (name,type,filepath) "
462 "VALUES(%Q,'ckey',%Q)",
463 zContainer, zCKey);
@@ -479,11 +479,11 @@
479 }
480 db_end_transaction(0);
481 db_swap_connections();
482 }else if(strncmp(zCmd, "list", n)==0){
483 Stmt q;
484 char *grp = NULL;
485
486 db_open_config(0);
487 db_swap_connections();
488 create_cert_table_if_not_exist();
489
@@ -492,33 +492,33 @@
492 " ORDER BY name,type");
493 while( db_step(&q)==SQLITE_ROW ){
494 const char *zCont = db_column_text(&q, 0);
495 const char *zType = db_column_text(&q, 1);
496 const char *zFilePath = db_column_text(&q, 2);
497 if( fossil_strcmp(zCont, grp)!=0 ){
498 free(grp);
499 grp = strdup(zCont);
500 puts(zCont);
501 }
502 printf("\t%s=%s\n", zType, zFilePath);
503 }
504 db_finalize(&q);
505
506 /* List the URL associations. */
507 db_prepare(&q, "SELECT name FROM global_config"
508 " WHERE name LIKE 'certgroup:%%' AND value=%Q"
509 " ORDER BY name", grp);
510 free(grp);
511
512 while( db_step(&q)==SQLITE_ROW ){
513 const char *zName = db_column_text(&q, 0);
514 static int first = 1;
515 if( first ) {
516 puts("\tAssociations");
517 first = 0;
518 }
519 printf("\t\t%s\n", zName+10);
520 }
521
522 db_swap_connections();
523 }else if(strncmp(zCmd, "disassociate", n)==0){
524 const char *zURL;
@@ -528,17 +528,17 @@
528 zURL = g.argv[3];
529
530 db_open_config(0);
531 db_swap_connections();
532 db_begin_transaction();
533 db_multi_exec("DELETE FROM global_config WHERE name='certgroup:%q'",
534 zURL);
535 if( db_changes() == 0 ){
536 fossil_warning("No certificate group associated with URL \"%s\".",
537 zURL);
538 }else{
539 printf("%s disassociated from its certificate group.\n", zURL);
540 }
541 db_end_transaction(0);
542 db_swap_connections();
543
544 }else if(strncmp(zCmd, "delete", n)==0){
@@ -548,19 +548,20 @@
548 }
549 zContainer = g.argv[3];
550
551 db_open_config(0);
552 db_swap_connections();
 
553 db_begin_transaction();
554 db_multi_exec("DELETE FROM certs WHERE name=%Q", zContainer);
555 if( db_changes() == 0 ){
556 fossil_warning("No certificate group named \"%s\" found",
557 zContainer);
558 }else{
559 printf("%d entries removed\n", db_changes());
560 }
561 db_multi_exec("DELETE FROM global_config WHERE name LIKE 'certgroup:%%'"
562 " AND value=%Q", zContainer);
563 if( db_changes() > 0 ){
564 printf("%d associations removed\n", db_changes());
565 }
566 db_end_transaction(0);
567
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -309,46 +309,46 @@
309 }
310 return total;
311 }
312
313 /*
314 ** If a certbundle has been specified on the command line, then use it to look
315 ** up certificates and keys, and then store the URL-certbundle association in
316 ** the global database. If no certbundle has been specified on the command
317 ** line, see if there's an entry for the url in global_config, and use it if
318 ** applicable.
319 */
320 void ssl_load_client_authfiles(void){
321 char *zBundleName = NULL;
322 char *cafile;
323 char *capath;
324 char *certfile;
325 char *keyfile;
326
327 if( g.urlCertBundle ){
328 char *zName;
329 zName = mprintf("certbundle:%s", g.urlName);
330 db_set(zName, g.urlCertBundle, 1);
331 free(zName);
332 zBundleName = strdup(g.urlCertBundle);
333 }else{
334 db_swap_connections();
335 zBundleName = db_text(0, "SELECT value FROM global_config"
336 " WHERE name='certbundle:%q'", g.urlName);
337 db_swap_connections();
338 }
339 if( !zBundleName ){
340 /* No cert bundle specified on command line or found cached for URL */
341 return;
342 }
343
344 db_swap_connections();
345 create_cert_table_if_not_exist();
346 cafile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
347 " AND type='cafile'", zBundleName);
348 capath = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
349 " AND type='capath'", zBundleName);
350 db_swap_connections();
351
352 if( cafile || capath ){
353 /* The OpenSSL documentation warns that if several CA certificates match
354 ** the same name, key identifier and serial number conditions, only the
@@ -361,13 +361,13 @@
361 }
362 }
363
364 db_swap_connections();
365 keyfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
366 " AND type='ckey'", zBundleName);
367 certfile = db_text(0, "SELECT filepath FROM certs WHERE name=%Q"
368 " AND type='ccert'", zBundleName);
369 db_swap_connections();
370
371 if( SSL_CTX_use_certificate_file(sslCtx, certfile, SSL_FILETYPE_PEM)<=0 ){
372 fossil_fatal("SSL: Unable to open client certificate in %s.", certfile);
373 }
@@ -391,39 +391,39 @@
391 /*
392 ** COMMAND: cert
393 **
394 ** Usage: %fossil cert SUBCOMMAND ...
395 **
396 ** Manage/bundle PKI client keys/certificates and CA certificates for SSL
397 ** certificate chain verifications.
398 **
399 ** %fossil cert add NAME ?--key KEYFILE? ?--cert CERTFILE?
400 ** ?--cafile CAFILE? ?--capath CAPATH?
401 **
402 ** Create a certificate bundle NAME with the associated
403 ** certificates/keys. If a client certificate is specified but no
404 ** key, it is assumed that the key is located in the client
405 ** certificate file.
406 ** The file formats must be PEM.
407 **
408 ** %fossil cert list
409 **
410 ** List all certificate bundles, their values and their URL
411 ** associations.
412 **
413 ** %fossil cert disassociate URL
414 **
415 ** Disassociate URL from any certificate bundle.
416 **
417 ** %fossil cert delete NAME
418 **
419 ** Remove the certificate bundle NAME and all its URL associations.
 
420 **
421 */
422 void cert_cmd(void){
423 int n;
424 const char *zCmd = "list"; /* Default sub-command */
425 if( g.argc>=3 ){
426 zCmd = g.argv[2];
427 }
428 n = strlen(zCmd);
429 if( strncmp(zCmd, "add", n)==0 ){
@@ -431,22 +431,22 @@
431 const char *zCKey;
432 const char *zCCert;
433 const char *zCAFile;
434 const char *zCAPath;
435 if( g.argc<5 ){
436 usage("add NAME ?--key KEYFILE? ?--cert CERTFILE? ?--cafile CAFILE? "
437 "?--capath CAPATH?");
438 }
439 zContainer = g.argv[3];
440 zCKey = find_option("key",0,1);
441 zCCert = find_option("cert",0,1);
442 zCAFile = find_option("cafile",0,1);
443 zCAPath = find_option("capath",0,1);
444
445 /* If a client certificate was specified, but a key was not, assume the
446 ** key is stored in the same file as the certificate.
447 */
448 if( !zCKey && zCCert ){
449 zCKey = zCCert;
450 }
451
452 db_open_config(0);
@@ -453,11 +453,11 @@
453 db_swap_connections();
454 create_cert_table_if_not_exist();
455 db_begin_transaction();
456 if( db_exists("SELECT 1 FROM certs WHERE name='%q'", zContainer)!=0 ){
457 db_end_transaction(0);
458 fossil_fatal("certificate bundle \"%s\" already exists", zContainer);
459 }
460 if( zCKey ){
461 db_multi_exec("INSERT INTO certs (name,type,filepath) "
462 "VALUES(%Q,'ckey',%Q)",
463 zContainer, zCKey);
@@ -479,11 +479,11 @@
479 }
480 db_end_transaction(0);
481 db_swap_connections();
482 }else if(strncmp(zCmd, "list", n)==0){
483 Stmt q;
484 char *bndl = NULL;
485
486 db_open_config(0);
487 db_swap_connections();
488 create_cert_table_if_not_exist();
489
@@ -492,33 +492,33 @@
492 " ORDER BY name,type");
493 while( db_step(&q)==SQLITE_ROW ){
494 const char *zCont = db_column_text(&q, 0);
495 const char *zType = db_column_text(&q, 1);
496 const char *zFilePath = db_column_text(&q, 2);
497 if( fossil_strcmp(zCont, bndl)!=0 ){
498 free(bndl);
499 bndl = strdup(zCont);
500 puts(zCont);
501 }
502 printf("\t%s=%s\n", zType, zFilePath);
503 }
504 db_finalize(&q);
505
506 /* List the URL associations. */
507 db_prepare(&q, "SELECT name FROM global_config"
508 " WHERE name LIKE 'certbundle:%%' AND value=%Q"
509 " ORDER BY name", bndl);
510 free(bndl);
511
512 while( db_step(&q)==SQLITE_ROW ){
513 const char *zName = db_column_text(&q, 0);
514 static int first = 1;
515 if( first ) {
516 puts("\tAssociations");
517 first = 0;
518 }
519 printf("\t\t%s\n", zName+11);
520 }
521
522 db_swap_connections();
523 }else if(strncmp(zCmd, "disassociate", n)==0){
524 const char *zURL;
@@ -528,17 +528,17 @@
528 zURL = g.argv[3];
529
530 db_open_config(0);
531 db_swap_connections();
532 db_begin_transaction();
533 db_multi_exec("DELETE FROM global_config WHERE name='certbundle:%q'",
534 zURL);
535 if( db_changes() == 0 ){
536 fossil_warning("No certificate bundle associated with URL \"%s\".",
537 zURL);
538 }else{
539 printf("%s disassociated from its certificate bundle.\n", zURL);
540 }
541 db_end_transaction(0);
542 db_swap_connections();
543
544 }else if(strncmp(zCmd, "delete", n)==0){
@@ -548,19 +548,20 @@
548 }
549 zContainer = g.argv[3];
550
551 db_open_config(0);
552 db_swap_connections();
553 create_cert_table_if_not_exist();
554 db_begin_transaction();
555 db_multi_exec("DELETE FROM certs WHERE name=%Q", zContainer);
556 if( db_changes() == 0 ){
557 fossil_warning("No certificate bundle named \"%s\" found",
558 zContainer);
559 }else{
560 printf("%d entries removed\n", db_changes());
561 }
562 db_multi_exec("DELETE FROM global_config WHERE name LIKE 'certbundle:%%'"
563 " AND value=%Q", zContainer);
564 if( db_changes() > 0 ){
565 printf("%d associations removed\n", db_changes());
566 }
567 db_end_transaction(0);
568
+1 -1
--- src/main.c
+++ src/main.c
@@ -102,11 +102,11 @@
102102
char *urlPasswd; /* Password for http: */
103103
char *urlCanonical; /* Canonical representation of the URL */
104104
char *urlProxyAuth; /* Proxy-Authorizer: string */
105105
char *urlFossil; /* The path of the ?fossil=path suffix on ssh: */
106106
int dontKeepUrl; /* Do not persist the URL */
107
- const char *urlCertGroup; /* Which ceritificate group to use for URL */
107
+ const char *urlCertBundle; /* Which ceritificate bundle to use for URL */
108108
109109
const char *zLogin; /* Login name. "" if not logged in. */
110110
int useLocalauth; /* No login required if from 127.0.0.1 */
111111
int noPswd; /* Logged in without password (on 127.0.0.1) */
112112
int userUid; /* Integer user id */
113113
--- src/main.c
+++ src/main.c
@@ -102,11 +102,11 @@
102 char *urlPasswd; /* Password for http: */
103 char *urlCanonical; /* Canonical representation of the URL */
104 char *urlProxyAuth; /* Proxy-Authorizer: string */
105 char *urlFossil; /* The path of the ?fossil=path suffix on ssh: */
106 int dontKeepUrl; /* Do not persist the URL */
107 const char *urlCertGroup; /* Which ceritificate group to use for URL */
108
109 const char *zLogin; /* Login name. "" if not logged in. */
110 int useLocalauth; /* No login required if from 127.0.0.1 */
111 int noPswd; /* Logged in without password (on 127.0.0.1) */
112 int userUid; /* Integer user id */
113
--- src/main.c
+++ src/main.c
@@ -102,11 +102,11 @@
102 char *urlPasswd; /* Password for http: */
103 char *urlCanonical; /* Canonical representation of the URL */
104 char *urlProxyAuth; /* Proxy-Authorizer: string */
105 char *urlFossil; /* The path of the ?fossil=path suffix on ssh: */
106 int dontKeepUrl; /* Do not persist the URL */
107 const char *urlCertBundle; /* Which ceritificate bundle to use for URL */
108
109 const char *zLogin; /* Login name. "" if not logged in. */
110 int useLocalauth; /* No login required if from 127.0.0.1 */
111 int noPswd; /* Logged in without password (on 127.0.0.1) */
112 int userUid; /* Integer user id */
113
+4 -4
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
9696
const char *zPw = 0;
9797
int configSync = 0;
9898
int urlOptional = find_option("autourl",0,0)!=0;
9999
g.dontKeepUrl = find_option("once",0,0)!=0;
100100
*pPrivate = find_option("private",0,0)!=0;
101
- g.urlCertGroup = find_option("certgroup",0,1);
101
+ g.urlCertBundle = find_option("certbundle",0,1);
102102
url_proxy_options();
103103
db_find_and_open_repository(0, 0);
104104
db_open_config(0);
105105
if( g.argc==2 ){
106106
zUrl = db_get("last-sync-url", 0);
@@ -151,11 +151,11 @@
151151
** saved.
152152
**
153153
** Use the --private option to pull private branches from the
154154
** remote repository.
155155
**
156
-** Use the "--certgroup NAME" option to specify the name of the
156
+** Use the "--certbundle NAME" option to specify the name of the
157157
** certificate/key bundle to use for https connections. If this option
158158
** is not specified, a cached value associated with the URL will be
159159
** used if it exists.
160160
**
161161
** See also: cert, clone, push, sync, remote-url
@@ -185,11 +185,11 @@
185185
** saved.
186186
**
187187
** Use the --private option to push private branches to the
188188
** remote repository.
189189
**
190
-** Use the "--certgroup NAME" option to specify the name of the
190
+** Use the "--certbundle NAME" option to specify the name of the
191191
** certificate/key bundle to use for https connections. If this option
192192
** is not specified, a cached value associated with the URL will be
193193
** used if it exists.
194194
**
195195
** See also: cert, clone, pull, sync, remote-url
@@ -225,11 +225,11 @@
225225
** saved.
226226
**
227227
** Use the --private option to sync private branches with the
228228
** remote repository.
229229
**
230
-** Use the "--certgroup NAME" option to specify the name of the
230
+** Use the "--certbundle NAME" option to specify the name of the
231231
** certificate/key bundle to use for https connections. If this option
232232
** is not specified, a cached value associated with the URL will be
233233
** used if it exists.
234234
**
235235
** See also: cert, clone, push, pull, remote-url
236236
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
96 const char *zPw = 0;
97 int configSync = 0;
98 int urlOptional = find_option("autourl",0,0)!=0;
99 g.dontKeepUrl = find_option("once",0,0)!=0;
100 *pPrivate = find_option("private",0,0)!=0;
101 g.urlCertGroup = find_option("certgroup",0,1);
102 url_proxy_options();
103 db_find_and_open_repository(0, 0);
104 db_open_config(0);
105 if( g.argc==2 ){
106 zUrl = db_get("last-sync-url", 0);
@@ -151,11 +151,11 @@
151 ** saved.
152 **
153 ** Use the --private option to pull private branches from the
154 ** remote repository.
155 **
156 ** Use the "--certgroup NAME" option to specify the name of the
157 ** certificate/key bundle to use for https connections. If this option
158 ** is not specified, a cached value associated with the URL will be
159 ** used if it exists.
160 **
161 ** See also: cert, clone, push, sync, remote-url
@@ -185,11 +185,11 @@
185 ** saved.
186 **
187 ** Use the --private option to push private branches to the
188 ** remote repository.
189 **
190 ** Use the "--certgroup NAME" option to specify the name of the
191 ** certificate/key bundle to use for https connections. If this option
192 ** is not specified, a cached value associated with the URL will be
193 ** used if it exists.
194 **
195 ** See also: cert, clone, pull, sync, remote-url
@@ -225,11 +225,11 @@
225 ** saved.
226 **
227 ** Use the --private option to sync private branches with the
228 ** remote repository.
229 **
230 ** Use the "--certgroup NAME" option to specify the name of the
231 ** certificate/key bundle to use for https connections. If this option
232 ** is not specified, a cached value associated with the URL will be
233 ** used if it exists.
234 **
235 ** See also: cert, clone, push, pull, remote-url
236
--- src/sync.c
+++ src/sync.c
@@ -96,11 +96,11 @@
96 const char *zPw = 0;
97 int configSync = 0;
98 int urlOptional = find_option("autourl",0,0)!=0;
99 g.dontKeepUrl = find_option("once",0,0)!=0;
100 *pPrivate = find_option("private",0,0)!=0;
101 g.urlCertBundle = find_option("certbundle",0,1);
102 url_proxy_options();
103 db_find_and_open_repository(0, 0);
104 db_open_config(0);
105 if( g.argc==2 ){
106 zUrl = db_get("last-sync-url", 0);
@@ -151,11 +151,11 @@
151 ** saved.
152 **
153 ** Use the --private option to pull private branches from the
154 ** remote repository.
155 **
156 ** Use the "--certbundle NAME" option to specify the name of the
157 ** certificate/key bundle to use for https connections. If this option
158 ** is not specified, a cached value associated with the URL will be
159 ** used if it exists.
160 **
161 ** See also: cert, clone, push, sync, remote-url
@@ -185,11 +185,11 @@
185 ** saved.
186 **
187 ** Use the --private option to push private branches to the
188 ** remote repository.
189 **
190 ** Use the "--certbundle NAME" option to specify the name of the
191 ** certificate/key bundle to use for https connections. If this option
192 ** is not specified, a cached value associated with the URL will be
193 ** used if it exists.
194 **
195 ** See also: cert, clone, pull, sync, remote-url
@@ -225,11 +225,11 @@
225 ** saved.
226 **
227 ** Use the --private option to sync private branches with the
228 ** remote repository.
229 **
230 ** Use the "--certbundle NAME" option to specify the name of the
231 ** certificate/key bundle to use for https connections. If this option
232 ** is not specified, a cached value associated with the URL will be
233 ** used if it exists.
234 **
235 ** See also: cert, clone, push, pull, remote-url
236

Keyboard Shortcuts

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