Fossil SCM

Allow a path to the ssh-keygen in the pgp-command setting.

danield 2025-01-02 00:12 ssh-signing
Commit 121093b8351de663e634a37866b8938be016b517fd32bec239e8501a0e319439
2 files changed +4 -2 +21
+4 -2
--- src/clearsign.c
+++ src/clearsign.c
@@ -29,19 +29,21 @@
2929
int clearsign(Blob *pIn, Blob *pOut){
3030
char *zRand;
3131
char *zIn;
3232
char *zOut;
3333
char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
34
+ const char *zTail;
3435
char *zCmd;
3536
int rc;
3637
if( is_false(zBase) ){
3738
return 0;
3839
}
3940
zRand = db_text(0, "SELECT hex(randomblob(10))");
4041
zOut = mprintf("out-%s", zRand);
4142
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 ){
4345
zIn = mprintf("out-%s.sig", zRand);
4446
zCmd = mprintf("%s %s", zBase, zOut);
4547
}else{
4648
zIn = mprintf("in-%z", zRand);
4749
zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
@@ -51,11 +53,11 @@
5153
if( rc==0 ){
5254
if( pOut==pIn ){
5355
blob_reset(pIn);
5456
}
5557
blob_zero(pOut);
56
- if( fossil_strncmp(zBase, "ssh", 3)==0 ){
58
+ if( fossil_strncmp(zTail, "ssh", 3)==0 ){
5759
/* SSH cannot currently (2024) create non-detached SSH signatures */
5860
/* We put one together */
5961
Blob tmpBlob;
6062
blob_zero(&tmpBlob);
6163
blob_read_from_file(&tmpBlob, zOut, ExtFILE);
6264
--- 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 @@
550550
*/
551551
const char *file_tail(const char *z){
552552
const char *zTail = z;
553553
if( !zTail ) return 0;
554554
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
+ }
555576
if( fossil_isdirsep(z[0]) ) zTail = &z[1];
556577
z++;
557578
}
558579
return zTail;
559580
}
560581
--- 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

Keyboard Shortcuts

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