Commit Diff


commit - 0e23f911fba42726916fbd5ef96ef8f9d60aa9f1227e14de0054dac38d63c86d
commit + ed2f82904d5f4da047cb62aa90267fd0952836d2c65a51e84955f82fe8560d29
blob - da2a711d3f34f0d96399f4cd96d9e4ab92b671724d82145dcad1afbdd2abb83a
blob + a4661acb08b133c3f72fc9349bfae1e9fcd8f8a23158eac7bb5d983023bca5fb
--- gotwebd/auth.c	
+++ gotwebd/auth.c	
@@ -498,23 +498,12 @@ static const struct got_error *
 login_error_hint(struct request *c)
 {
 	struct server *srv;
-	char msg[512];
-	int ret;
 
 	srv = gotweb_get_server(c->fcgi_params.server_name);
 	if (srv == NULL || srv->login_hint_user[0] == '\0')
 		return got_error(GOT_ERR_LOGIN_FAILED);
 
-	ret = snprintf(msg, sizeof(msg),
-	    "Log in by running: ssh %s%s%s%s@%s \"weblogin %s\"",
-	    srv->login_hint_port[0] ? " -p " : "",
-	    srv->login_hint_port[0] ? srv->login_hint_port : "",
-	    srv->login_hint_port[0] ? " " : "",
-	    srv->login_hint_user, srv->name, srv->name);
-	if (ret == -1 || (size_t)ret >= sizeof(msg))
-		return got_error(GOT_ERR_LOGIN_FAILED);
-
-	return got_error_msg(GOT_ERR_LOGIN_FAILED, msg);
+	return got_error(GOT_ERR_LOGIN_HINT);
 }
 
 static void
blob - 78189fba8fb23c1b31d117093d25365f8266118d8872a25d50b51ff4c3a4cd2f
blob + 44fc61317317019cee43f8dccb61ccce547d8cfdf5134c77eaa70b3a5090553a
--- gotwebd/pages.tmpl	
+++ gotwebd/pages.tmpl	
@@ -271,10 +271,53 @@ nextsep(char *s, char **t)
 {!
 	struct request		*c = tp->tp_arg;
 	struct transport	*t = c->t;
+	struct server		*srv = NULL;
+	const char		*login_hint_user = NULL;
+	const char		*login_hint_port = NULL;
+
+	if (t->error && t->error->code == GOT_ERR_LOGIN_HINT) {
+		srv = gotweb_get_server(c->fcgi_params.server_name);
+		if (srv && srv->login_hint_user[0] != '\0') {
+			login_hint_user = srv->login_hint_user;
+			if (srv->login_hint_port[0] != '\0')
+				login_hint_port = srv->login_hint_port;
+		}
+	}
 !}
 <div id="err_content">
   {{ if t->error }}
-    {{ t->error->msg }}
+    {{ if t->error->code == GOT_ERR_LOGIN_HINT && login_hint_user }}
+      Log in by running: 
+      {{ if login_hint_port }}
+	ssh -p {{ login_hint_port }} {{" "}} {{ login_hint_user }}@{{ srv->name }} {{" "}} "weblogin {{ srv->name }}"
+	
+      {{ else }}
+	ssh {{ login_hint_user }}@{{ srv->name }} {{" "}} "weblogin {{ srv->name }}"
+      {{ end }}
+      {{ if srv->sshfp[GOTWEBD_SSHFP_ECDSA][0] != '\0' ||
+          srv->sshfp[GOTWEBD_SSHFP_ED25519][0] != '\0' ||
+          srv->sshfp[GOTWEBD_SSHFP_RSA][0] != '\0' }}
+	{{ if login_hint_port }}
+	  <p>The SSH host key fingerprints of {{ srv->name }}:{{ login_hint_port }} {{" "}} are:</p>
+	{{ else }}
+	  <p>The SSH host key fingerprints of {{ srv->name }} {{" "}} are:</p>
+	{{ end }}
+	<dl>
+        {{ if srv->sshfp[GOTWEBD_SSHFP_ECDSA][0] != '\0' }}
+          <dt>ECDSA</dt><dd><pre class="clone-url">{{ srv->sshfp[GOTWEBD_SSHFP_ECDSA] }}</pre></dd>
+        {{ end }}
+        {{ if srv->sshfp[GOTWEBD_SSHFP_ED25519][0] != '\0' }}
+          <dt>ED25519</dt><dd><pre class="clone-url">{{ srv->sshfp[GOTWEBD_SSHFP_ED25519] }}</pre></dd>
+        {{ end }}
+        {{ if srv->sshfp[GOTWEBD_SSHFP_RSA][0] != '\0' }}
+          <dt>RSA</dt><dd><pre class="clone-url">{{ srv->sshfp[GOTWEBD_SSHFP_RSA] }}</pre></dd>
+        {{ end }}
+	</dl>
+      {{ end }}
+
+    {{ else }}
+      {{ t->error->msg }}
+    {{ end }}
   {{ else }}
     See daemon logs for details
   {{ end }}
blob - e817adacd2a95cfa4a5c9aea593f3c6b46825b86a2c856f4172c63a9520f706d
blob + f04ac3299a04b6ab2e818462be5f3b64c2db58b5391aa12a095b1cdf14efb716
--- include/got_error.h	
+++ include/got_error.h	
@@ -202,6 +202,7 @@
 #define GOT_ERR_NOT_FOUND	194
 #define GOT_ERR_MEDIA_TYPE	195
 #define GOT_ERR_LOGOUT_FAILED	196
+#define GOT_ERR_LOGIN_HINT	197
 
 struct got_error {
         int code;
blob - 3ab249f0ce4e7433056ca49721fa2eab4b9eeaec9083ebdef9d4dd45cc84b8ff
blob + c7c107ac5a424802b7f84f847b4e04a0f7083e64573b21596765a104883088c3
--- lib/error.c	
+++ lib/error.c	
@@ -253,6 +253,7 @@ static const struct got_error got_errors[] = {
 	{ GOT_ERR_NOT_FOUND, "not found" },
 	{ GOT_ERR_MEDIA_TYPE,	"malformed media type" },
 	{ GOT_ERR_LOGOUT_FAILED, "logout failed" },
+	{ GOT_ERR_LOGIN_HINT, "login failed, see hint" },
 };
 
 static struct got_custom_error {