Fossil SCM
Allow a path to the ssh-keygen in the pgp-command setting.
Commit
121093b8351de663e634a37866b8938be016b517fd32bec239e8501a0e319439
Parent
decad8811e9e464…
2 files changed
+4
-2
+21
+4
-2
| --- src/clearsign.c | ||
| +++ src/clearsign.c | ||
| @@ -29,19 +29,21 @@ | ||
| 29 | 29 | int clearsign(Blob *pIn, Blob *pOut){ |
| 30 | 30 | char *zRand; |
| 31 | 31 | char *zIn; |
| 32 | 32 | char *zOut; |
| 33 | 33 | char *zBase = db_get("pgp-command", "gpg --clearsign -o "); |
| 34 | + const char *zTail; | |
| 34 | 35 | char *zCmd; |
| 35 | 36 | int rc; |
| 36 | 37 | if( is_false(zBase) ){ |
| 37 | 38 | return 0; |
| 38 | 39 | } |
| 39 | 40 | zRand = db_text(0, "SELECT hex(randomblob(10))"); |
| 40 | 41 | zOut = mprintf("out-%s", zRand); |
| 41 | 42 | blob_write_to_file(pIn, zOut); |
| 42 | - if( fossil_strncmp(zBase, "ssh", 3)==0 ){ | |
| 43 | + zTail = command_tail(zBase); | |
| 44 | + if( fossil_strncmp(zTail, "ssh", 3)==0 ){ | |
| 43 | 45 | zIn = mprintf("out-%s.sig", zRand); |
| 44 | 46 | zCmd = mprintf("%s %s", zBase, zOut); |
| 45 | 47 | }else{ |
| 46 | 48 | zIn = mprintf("in-%z", zRand); |
| 47 | 49 | zCmd = mprintf("%s %s %s", zBase, zIn, zOut); |
| @@ -51,11 +53,11 @@ | ||
| 51 | 53 | if( rc==0 ){ |
| 52 | 54 | if( pOut==pIn ){ |
| 53 | 55 | blob_reset(pIn); |
| 54 | 56 | } |
| 55 | 57 | blob_zero(pOut); |
| 56 | - if( fossil_strncmp(zBase, "ssh", 3)==0 ){ | |
| 58 | + if( fossil_strncmp(zTail, "ssh", 3)==0 ){ | |
| 57 | 59 | /* SSH cannot currently (2024) create non-detached SSH signatures */ |
| 58 | 60 | /* We put one together */ |
| 59 | 61 | Blob tmpBlob; |
| 60 | 62 | blob_zero(&tmpBlob); |
| 61 | 63 | blob_read_from_file(&tmpBlob, zOut, ExtFILE); |
| 62 | 64 |
| --- src/clearsign.c | |
| +++ src/clearsign.c | |
| @@ -29,19 +29,21 @@ | |
| 29 | int clearsign(Blob *pIn, Blob *pOut){ |
| 30 | char *zRand; |
| 31 | char *zIn; |
| 32 | char *zOut; |
| 33 | char *zBase = db_get("pgp-command", "gpg --clearsign -o "); |
| 34 | char *zCmd; |
| 35 | int rc; |
| 36 | if( is_false(zBase) ){ |
| 37 | return 0; |
| 38 | } |
| 39 | zRand = db_text(0, "SELECT hex(randomblob(10))"); |
| 40 | zOut = mprintf("out-%s", zRand); |
| 41 | blob_write_to_file(pIn, zOut); |
| 42 | if( fossil_strncmp(zBase, "ssh", 3)==0 ){ |
| 43 | zIn = mprintf("out-%s.sig", zRand); |
| 44 | zCmd = mprintf("%s %s", zBase, zOut); |
| 45 | }else{ |
| 46 | zIn = mprintf("in-%z", zRand); |
| 47 | zCmd = mprintf("%s %s %s", zBase, zIn, zOut); |
| @@ -51,11 +53,11 @@ | |
| 51 | if( rc==0 ){ |
| 52 | if( pOut==pIn ){ |
| 53 | blob_reset(pIn); |
| 54 | } |
| 55 | blob_zero(pOut); |
| 56 | if( fossil_strncmp(zBase, "ssh", 3)==0 ){ |
| 57 | /* SSH cannot currently (2024) create non-detached SSH signatures */ |
| 58 | /* We put one together */ |
| 59 | Blob tmpBlob; |
| 60 | blob_zero(&tmpBlob); |
| 61 | blob_read_from_file(&tmpBlob, zOut, ExtFILE); |
| 62 |
| --- src/clearsign.c | |
| +++ src/clearsign.c | |
| @@ -29,19 +29,21 @@ | |
| 29 | int clearsign(Blob *pIn, Blob *pOut){ |
| 30 | char *zRand; |
| 31 | char *zIn; |
| 32 | char *zOut; |
| 33 | char *zBase = db_get("pgp-command", "gpg --clearsign -o "); |
| 34 | const char *zTail; |
| 35 | char *zCmd; |
| 36 | int rc; |
| 37 | if( is_false(zBase) ){ |
| 38 | return 0; |
| 39 | } |
| 40 | zRand = db_text(0, "SELECT hex(randomblob(10))"); |
| 41 | zOut = mprintf("out-%s", zRand); |
| 42 | blob_write_to_file(pIn, zOut); |
| 43 | zTail = command_tail(zBase); |
| 44 | if( fossil_strncmp(zTail, "ssh", 3)==0 ){ |
| 45 | zIn = mprintf("out-%s.sig", zRand); |
| 46 | zCmd = mprintf("%s %s", zBase, zOut); |
| 47 | }else{ |
| 48 | zIn = mprintf("in-%z", zRand); |
| 49 | zCmd = mprintf("%s %s %s", zBase, zIn, zOut); |
| @@ -51,11 +53,11 @@ | |
| 53 | if( rc==0 ){ |
| 54 | if( pOut==pIn ){ |
| 55 | blob_reset(pIn); |
| 56 | } |
| 57 | blob_zero(pOut); |
| 58 | if( fossil_strncmp(zTail, "ssh", 3)==0 ){ |
| 59 | /* SSH cannot currently (2024) create non-detached SSH signatures */ |
| 60 | /* We put one together */ |
| 61 | Blob tmpBlob; |
| 62 | blob_zero(&tmpBlob); |
| 63 | blob_read_from_file(&tmpBlob, zOut, ExtFILE); |
| 64 |
+21
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -550,10 +550,31 @@ | ||
| 550 | 550 | */ |
| 551 | 551 | const char *file_tail(const char *z){ |
| 552 | 552 | const char *zTail = z; |
| 553 | 553 | if( !zTail ) return 0; |
| 554 | 554 | while( z[0] ){ |
| 555 | + if( fossil_isdirsep(z[0]) ) zTail = &z[1]; | |
| 556 | + z++; | |
| 557 | + } | |
| 558 | + return zTail; | |
| 559 | +} | |
| 560 | + | |
| 561 | +/* | |
| 562 | +** Return the tail of a command: the basename of the putative executable (which | |
| 563 | +** could be quoted when containing spaces) and the following arguments. | |
| 564 | +*/ | |
| 565 | +const char *command_tail(const char *z){ | |
| 566 | + const char *zTail = z; | |
| 567 | + char chQuote = 0; | |
| 568 | + if( !zTail ) return 0; | |
| 569 | + while( z[0] && (!fossil_isspace(z[0]) || | |
| 570 | + chQuote) ){ | |
| 571 | + if( z[0]=='"' || z[0]=='\'' ){ | |
| 572 | + if( chQuote && chQuote==z[0] ) | |
| 573 | + chQuote = 0; | |
| 574 | + else chQuote = z[0]; | |
| 575 | + } | |
| 555 | 576 | if( fossil_isdirsep(z[0]) ) zTail = &z[1]; |
| 556 | 577 | z++; |
| 557 | 578 | } |
| 558 | 579 | return zTail; |
| 559 | 580 | } |
| 560 | 581 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -550,10 +550,31 @@ | |
| 550 | */ |
| 551 | const char *file_tail(const char *z){ |
| 552 | const char *zTail = z; |
| 553 | if( !zTail ) return 0; |
| 554 | while( z[0] ){ |
| 555 | if( fossil_isdirsep(z[0]) ) zTail = &z[1]; |
| 556 | z++; |
| 557 | } |
| 558 | return zTail; |
| 559 | } |
| 560 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -550,10 +550,31 @@ | |
| 550 | */ |
| 551 | const char *file_tail(const char *z){ |
| 552 | const char *zTail = z; |
| 553 | if( !zTail ) return 0; |
| 554 | while( z[0] ){ |
| 555 | if( fossil_isdirsep(z[0]) ) zTail = &z[1]; |
| 556 | z++; |
| 557 | } |
| 558 | return zTail; |
| 559 | } |
| 560 | |
| 561 | /* |
| 562 | ** Return the tail of a command: the basename of the putative executable (which |
| 563 | ** could be quoted when containing spaces) and the following arguments. |
| 564 | */ |
| 565 | const char *command_tail(const char *z){ |
| 566 | const char *zTail = z; |
| 567 | char chQuote = 0; |
| 568 | if( !zTail ) return 0; |
| 569 | while( z[0] && (!fossil_isspace(z[0]) || |
| 570 | chQuote) ){ |
| 571 | if( z[0]=='"' || z[0]=='\'' ){ |
| 572 | if( chQuote && chQuote==z[0] ) |
| 573 | chQuote = 0; |
| 574 | else chQuote = z[0]; |
| 575 | } |
| 576 | if( fossil_isdirsep(z[0]) ) zTail = &z[1]; |
| 577 | z++; |
| 578 | } |
| 579 | return zTail; |
| 580 | } |
| 581 |