vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Dmitry Belyavskiy 6ec986
diff -up openssh-9.9p1/log.c.xxx openssh-9.9p1/log.c
Dmitry Belyavskiy 6ec986
--- openssh-9.9p1/log.c.xxx	2024-10-22 11:55:44.281939275 +0200
Dmitry Belyavskiy 6ec986
+++ openssh-9.9p1/log.c	2024-10-22 11:56:16.709676267 +0200
Dmitry Belyavskiy 6ec986
@@ -52,6 +52,9 @@
Dmitry Belyavskiy 6ec986
 
Dmitry Belyavskiy 6ec986
 #include "log.h"
Dmitry Belyavskiy 6ec986
 #include "match.h"
Dmitry Belyavskiy 6ec986
+#ifdef WITH_OPENSSL
Dmitry Belyavskiy 6ec986
+#include <openssl/err.h>
Dmitry Belyavskiy 6ec986
+#endif
Dmitry Belyavskiy 6ec986
 
Dmitry Belyavskiy 6ec986
 static LogLevel log_level = SYSLOG_LEVEL_INFO;
Dmitry Belyavskiy 6ec986
 static int log_on_stderr = 1;
Dmitry Belyavskiy 6ec986
@@ -438,6 +438,26 @@ sshlog(const char *file, const char *fun
Dmitry Belyavskiy 6ec986
 	va_end(args);
Dmitry Belyavskiy 6ec986
 }
Dmitry Belyavskiy 6ec986
 
Dmitry Belyavskiy 6ec986
+#ifdef WITH_OPENSSL
Dmitry Belyavskiy 6ec986
+static int
Dmitry Belyavskiy 6ec986
+openssl_error_print_cb(const char *str, size_t len, void *u)
Dmitry Belyavskiy 6ec986
+{
Dmitry Belyavskiy 6ec986
+	sshlogdirect(SYSLOG_LEVEL_DEBUG1, 0, "openssl error %s", str);
Dmitry Belyavskiy 6ec986
+	return 0;
Dmitry Belyavskiy 6ec986
+}
Dmitry Belyavskiy 6ec986
+#endif
Dmitry Belyavskiy 6ec986
+
Dmitry Belyavskiy 6ec986
+void
Dmitry Belyavskiy 6ec986
+sshlog_openssl(int r)
Dmitry Belyavskiy 6ec986
+{
Dmitry Belyavskiy 6ec986
+#ifdef WITH_OPENSSL
Dmitry Belyavskiy 6ec986
+	if (r != SSH_ERR_LIBCRYPTO_ERROR) return;
Dmitry Belyavskiy 6ec986
+
Dmitry Belyavskiy 6ec986
+	ERR_print_errors_cb(openssl_error_print_cb, NULL);
Dmitry Belyavskiy 6ec986
+#endif
Dmitry Belyavskiy 6ec986
+	return;
Dmitry Belyavskiy 6ec986
+}
Dmitry Belyavskiy 6ec986
+
Dmitry Belyavskiy 6ec986
 void
Dmitry Belyavskiy 6ec986
 sshlogdie(const char *file, const char *func, int line, int showfunc,
Dmitry Belyavskiy 6ec986
     LogLevel level, const char *suffix, const char *fmt, ...)
Dmitry Belyavskiy 6ec986
diff -up openssh-8.7p1/log.h.xxx openssh-8.7p1/log.h
Dmitry Belyavskiy 6ec986
--- openssh-8.7p1/log.h.xxx	2024-10-18 12:56:18.944971946 +0200
Dmitry Belyavskiy 6ec986
+++ openssh-8.7p1/log.h	2024-10-18 13:03:38.324351416 +0200
Dmitry Belyavskiy 6ec986
@@ -71,6 +71,7 @@ void	 cleanup_exit(int) __attribute__((n
Dmitry Belyavskiy 6ec986
 void	 sshlog(const char *, const char *, int, int,
Dmitry Belyavskiy 6ec986
     LogLevel, const char *, const char *, ...)
Dmitry Belyavskiy 6ec986
     __attribute__((format(printf, 7, 8)));
Dmitry Belyavskiy 6ec986
+void	 sshlog_openssl(int);
Dmitry Belyavskiy 6ec986
 void	 sshlogv(const char *, const char *, int, int,
Dmitry Belyavskiy 6ec986
     LogLevel, const char *, const char *, va_list);
Dmitry Belyavskiy 6ec986
 void	 sshlogdie(const char *, const char *, int, int,
Dmitry Belyavskiy 6ec986
diff -up openssh-8.7p1/auth2-pubkey.c.yyy openssh-8.7p1/auth2-pubkey.c
Dmitry Belyavskiy 6ec986
--- openssh-8.7p1/auth2-pubkey.c.yyy	2024-10-18 13:27:00.709055845 +0200
Dmitry Belyavskiy 6ec986
+++ openssh-8.7p1/auth2-pubkey.c	2024-10-18 13:27:31.638784460 +0200
Dmitry Belyavskiy 6ec986
@@ -131,6 +131,7 @@ userauth_pubkey(struct ssh *ssh)
Dmitry Belyavskiy 6ec986
 		goto done;
Dmitry Belyavskiy 6ec986
 	}
Dmitry Belyavskiy 6ec986
 	if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {
Dmitry Belyavskiy 6ec986
+		sshlog_openssl(r);
Dmitry Belyavskiy 6ec986
 		error_fr(r, "parse key");
Dmitry Belyavskiy 6ec986
 		goto done;
Dmitry Belyavskiy 6ec986
 	}
Dmitry Belyavskiy 6ec986
diff -up openssh-8.7p1/dispatch.c.yyy openssh-8.7p1/dispatch.c
Dmitry Belyavskiy 6ec986
--- openssh-8.7p1/dispatch.c.yyy	2024-10-18 13:27:56.349366570 +0200
Dmitry Belyavskiy 6ec986
+++ openssh-8.7p1/dispatch.c	2024-10-18 13:28:17.921874757 +0200
Dmitry Belyavskiy 6ec986
@@ -130,6 +130,8 @@ ssh_dispatch_run_fatal(struct ssh *ssh,
Dmitry Belyavskiy 6ec986
 {
Dmitry Belyavskiy 6ec986
 	int r;
Dmitry Belyavskiy 6ec986
 
Dmitry Belyavskiy 6ec986
-	if ((r = ssh_dispatch_run(ssh, mode, done)) != 0)
Dmitry Belyavskiy 6ec986
+	if ((r = ssh_dispatch_run(ssh, mode, done)) != 0) {
Dmitry Belyavskiy 6ec986
+		sshlog_openssl(r);
Dmitry Belyavskiy 6ec986
 		sshpkt_fatal(ssh, r, "%s", __func__);
Dmitry Belyavskiy 6ec986
+	}
Dmitry Belyavskiy 6ec986
 }