Commit Diff


commit - 7a6b6eeeda8091da897a1e5b68e132e655969c66794ba0416f34932d80575508
commit + b020191856790430c1c6f94a76a5d0fb01564db563a08e703bd0895aff1f11ea
blob - afb941d11c2f4b76ca11d027bd0e6017a1fadbbf73be6829ab48f7c3eddba93d
blob + c7cfa23095b2ce95bce29d79969042cdb233b3ffdf5a5f0bf7e2be72c26515d5
--- gotwebd/gotweb.c	
+++ gotwebd/gotweb.c	
@@ -1124,11 +1124,15 @@ gotweb_free_repo_commit(struct repo_commit *rc)
 static void
 gotweb_free_repo_dir(struct repo_dir *repo_dir)
 {
+	size_t i;
+
 	if (repo_dir != NULL) {
 		free(repo_dir->name);
 		free(repo_dir->owner);
 		free(repo_dir->description);
 		free(repo_dir->url);
+		for (i = 0; i < nitems(repo_dir->sshfp); i++)
+			free(repo_dir->sshfp[i]);
 		free(repo_dir->path);
 	}
 	free(repo_dir);
@@ -1708,6 +1712,23 @@ gotweb_load_got_path(struct repo_dir **rp, const char 
 		error = gotweb_get_clone_url(&repo_dir->url, srv,
 		    repo_dir->path, dirfd(dt));
 	}
+
+	if (srv->show_repo_cloneurl && repo) {
+		size_t i;
+
+		for (i = 0; i < nitems(repo->clone_url_hostkey); i++) {
+			if (repo->clone_url_hostkey[i][0] == '\0')
+				continue;
+
+			repo_dir->sshfp[i] = strdup(repo->clone_url_hostkey[i]);
+			if (repo_dir->sshfp[i] == NULL) {
+				error = got_error_from_errno("strdup");
+				goto err;
+			}
+		}
+
+	}
+
 err:
 	free(dir_test);
 	if (dt != NULL && closedir(dt) == EOF && error == NULL)
blob - 7bfc78da3b956a3db5dfeea9fc8f830e8d205d836e6d41dcaa34c072942d56d0
blob + d4b1395baa34b604ad92778435057efad6a77c246a0701d6c57ca37763281299
--- gotwebd/gotwebd.conf.5	
+++ gotwebd/gotwebd.conf.5	
@@ -497,6 +497,18 @@ then URLs stored in the repository's
 .Pa cloneurl
 file will be shown instead.
 This file may contain multiple URLs, one per line.
+.It Ic ssh_hostkey_ecdsa Ar string
+Set the server's SSH ECDSA host key fingerprint to be displayed beneath
+the clone URL.
+Should be set when the clone URL uses the SSH protocol.
+.It Ic ssh_hostkey_ed25519 Ar string
+Set the server's SSH ED25519 host key fingerprint to be displayed beneath
+the clone URL.
+Should be set when the clone URL uses the SSH protocol.
+.It Ic ssh_hostkey_rsa Ar string
+Set the server's SSH RSA host key fingerprint to be displayed beneath
+the clone URL.
+Should be set when the clone URL uses the SSH protocol.
 .It Ic description Ar string
 Sets the repository description shown on the repository listing page.
 The
blob - 2fafef4bd410c374c62aa416c81e871b4f13e74eec560433e690e13a13510fa5
blob + c1c0a092fbc961e59b48974215ecfed6ba9eb2276b81d944f2fe815d3c26becb
--- gotwebd/gotwebd.h	
+++ gotwebd/gotwebd.h	
@@ -54,7 +54,13 @@
 #define GOTWEBD_MAXPORT		 6
 #define GOTWEBD_NUMPROC		 3
 #define GOTWEBD_SOCK_FILENO	 3
+#define GOTWEBD_MAX_SSHFP	 64
 
+#define GOTWEBD_SSHFP_ECDSA	0
+#define GOTWEBD_SSHFP_ED25519	1
+#define GOTWEBD_SSHFP_RSA	2
+#define GOTWEBD_NUM_SSHFP	3
+
 #define PROC_MAX_INSTANCES	 32
 
 /* GOTWEB DEFAULTS */
@@ -206,6 +212,7 @@ struct repo_dir {
 	char			*owner;
 	char			*description;
 	char			*url;
+	char			*sshfp[GOTWEBD_NUM_SSHFP];
 	time_t			 age;
 	char			*path;
 };
@@ -398,6 +405,7 @@ struct gotwebd_repo {
 	char name[NAME_MAX];
 	char description[GOTWEBD_MAXDESCRSZ];
 	char clone_url[GOTWEBD_MAXCLONEURLSZ];
+	char clone_url_hostkey[GOTWEBD_NUM_SSHFP][GOTWEBD_MAX_SSHFP];
 
 	enum gotwebd_auth_config	auth_config;
 	struct gotwebd_access_rule_list access_rules;
blob - 8c1b73c4cb0672342907d9ff0975e54b37e95d45ba1553e52a3c18ed5cd8d199
blob + a4bad372b8576feafe17b31d6421969fab67cedd5586cf063670ceac3655f130
--- gotwebd/pages.tmpl	
+++ gotwebd/pages.tmpl	
@@ -1133,7 +1133,19 @@ nextsep(char *s, char **t)
   {{ if srv->show_repo_cloneurl }}
     <dt>Clone URL:</dt>
     <dd><pre class="clone-url">{{ t->repo_dir->url }}</pre></dd>
+  {{ if t->repo_dir->sshfp[GOTWEBD_SSHFP_ECDSA] }}
+    <dt>ECDSA:</dt>
+    <dd><pre class="clone-url">{{ t->repo_dir->sshfp[GOTWEBD_SSHFP_ECDSA] }}</pre></dd>
   {{ end }}
+  {{ if t->repo_dir->sshfp[GOTWEBD_SSHFP_ED25519] }}
+    <dt>ED25519:</dt>
+    <dd><pre class="clone-url">{{ t->repo_dir->sshfp[GOTWEBD_SSHFP_ED25519] }}</pre></dd>
+  {{ end }}
+  {{ if t->repo_dir->sshfp[GOTWEBD_SSHFP_RSA] }}
+    <dt>RSA:</dt>
+    <dd><pre class="clone-url">{{ t->repo_dir->sshfp[GOTWEBD_SSHFP_RSA] }}</pre></dd>
+  {{ end }}
+  {{ end }}
 </dl>
 <div class="summary-briefs">
   {{ render gotweb_render_briefs(tp) }}
blob - 4c1860a2ed56a660388fd7001629ed5662e7baa2027e97108e3faf9331502481
blob + dcaae7ec4a6954f2f977527fe14a9187faec968610731805bb2f832f1b83f3f4
--- gotwebd/parse.y	
+++ gotwebd/parse.y	
@@ -157,6 +157,7 @@ mediatype_ok(const char *s)
 %token	ENABLE DISABLE INSECURE REPOSITORY REPOSITORIES PERMIT DENY HIDE
 %token	WEBSITE PATH BRANCH REPOS_URL_PATH DESCRIPTION
 %token	TYPES INCLUDE GOTWEBD_CONTROL
+%token	SSH_HOSTKEY_ECDSA SSH_HOSTKEY_ED25519 SSH_HOSTKEY_RSA
 
 %token	<v.string>	STRING
 %token	<v.number>	NUMBER
@@ -978,6 +979,72 @@ repoopts1	: DISABLE AUTHENTICATION {
 				YYERROR;
 			}
 		}
+		| SSH_HOSTKEY_ECDSA STRING {
+			int i = GOTWEBD_SSHFP_ECDSA;
+
+			if (*$2 == '\0') {
+				yyerror("ssh host key fingerprint cannot be "
+				    "an empty string");
+				free($2);
+				YYERROR;
+			}
+
+			if (strlcpy(new_repo->clone_url_hostkey[i], $2,
+			    sizeof(new_repo->clone_url_hostkey[i])) >=
+			    sizeof(new_repo->clone_url_hostkey[i])) {
+				yyerror("ssh host key fingerprint too long, "
+				    "exceeds " "%zd bytes: %s",
+				    sizeof(new_repo->clone_url_hostkey[i]), $2);
+				free($2);
+				YYERROR;
+			}
+
+			free($2);
+		}
+		| SSH_HOSTKEY_ED25519 STRING {
+			int i = GOTWEBD_SSHFP_ED25519;
+
+			if (*$2 == '\0') {
+				yyerror("ssh host key fingerprint cannot be "
+				    "an empty string");
+				free($2);
+				YYERROR;
+			}
+
+			if (strlcpy(new_repo->clone_url_hostkey[i], $2,
+			    sizeof(new_repo->clone_url_hostkey[i])) >=
+			    sizeof(new_repo->clone_url_hostkey[i])) {
+				yyerror("ssh host key fingerprint too long, "
+				    "exceeds " "%zd bytes: %s",
+				    sizeof(new_repo->clone_url_hostkey[i]), $2);
+				free($2);
+				YYERROR;
+			}
+
+			free($2);
+		}
+		| SSH_HOSTKEY_RSA STRING {
+			int i = GOTWEBD_SSHFP_RSA;
+
+			if (*$2 == '\0') {
+				yyerror("ssh host key fingerprint cannot be "
+				    "an empty string");
+				free($2);
+				YYERROR;
+			}
+
+			if (strlcpy(new_repo->clone_url_hostkey[i], $2,
+			    sizeof(new_repo->clone_url_hostkey[i])) >=
+			    sizeof(new_repo->clone_url_hostkey[i])) {
+				yyerror("ssh host key fingerprint too long, "
+				    "exceeds " "%zd bytes: %s",
+				    sizeof(new_repo->clone_url_hostkey[i]), $2);
+				free($2);
+				YYERROR;
+			}
+
+			free($2);
+		}
 		;
 
 types		: TYPES	'{' optnl mediaopts_l '}'
@@ -1129,6 +1196,9 @@ lookup(char *s)
 		{ "site_name",			SITE_NAME },
 		{ "site_owner",			SITE_OWNER },
 		{ "socket",			SOCKET },
+		{ "ssh_hostkey_ecdsa",		SSH_HOSTKEY_ECDSA},
+		{ "ssh_hostkey_ed25519",	SSH_HOSTKEY_ED25519},
+		{ "ssh_hostkey_rsa",		SSH_HOSTKEY_RSA},
 		{ "summary_commits_display",	SUMMARY_COMMITS_DISPLAY },
 		{ "summary_tags_display",	SUMMARY_TAGS_DISPLAY },
 		{ "types",			TYPES },