bmh10 / rpms / openssh

Forked from rpms/openssh 2 days ago
Clone

Blame SOURCES/openssh-8.7p1-scp-kill-switch.patch

5dbb6f
diff -up openssh-8.7p1/pathnames.h.kill-scp openssh-8.7p1/pathnames.h
5dbb6f
--- openssh-8.7p1/pathnames.h.kill-scp	2021-09-16 11:37:57.240171687 +0200
5dbb6f
+++ openssh-8.7p1/pathnames.h	2021-09-16 11:42:29.183427917 +0200
5dbb6f
@@ -42,6 +42,7 @@
5dbb6f
 #define _PATH_HOST_XMSS_KEY_FILE	SSHDIR "/ssh_host_xmss_key"
5dbb6f
 #define _PATH_HOST_RSA_KEY_FILE		SSHDIR "/ssh_host_rsa_key"
5dbb6f
 #define _PATH_DH_MODULI			SSHDIR "/moduli"
5dbb6f
+#define _PATH_SCP_KILL_SWITCH		SSHDIR "/disable_scp"
5dbb6f
 
5dbb6f
 #ifndef _PATH_SSH_PROGRAM
5dbb6f
 #define _PATH_SSH_PROGRAM		"/usr/bin/ssh"
5dbb6f
diff -up openssh-8.7p1/scp.1.kill-scp openssh-8.7p1/scp.1
5dbb6f
--- openssh-8.7p1/scp.1.kill-scp	2021-09-16 12:09:02.646714578 +0200
5dbb6f
+++ openssh-8.7p1/scp.1	2021-09-16 12:26:49.978628226 +0200
5dbb6f
@@ -278,6 +278,13 @@ to print debugging messages about their
5dbb6f
 This is helpful in
5dbb6f
 debugging connection, authentication, and configuration problems.
5dbb6f
 .El
5dbb6f
+.Pp
5dbb6f
+Usage of SCP protocol can be blocked by creating a world-readable
5dbb6f
+.Ar /etc/ssh/disable_scp
5dbb6f
+file. If this file exists, when SCP protocol is in use (either remotely or 
5dbb6f
+via the
5dbb6f
+.Fl O
5dbb6f
+option), the program will exit.
5dbb6f
 .Sh EXIT STATUS
5dbb6f
 .Ex -std scp
5dbb6f
 .Sh SEE ALSO
5dbb6f
diff -up openssh-8.7p1/scp.c.kill-scp openssh-8.7p1/scp.c
5dbb6f
--- openssh-8.7p1/scp.c.kill-scp	2021-09-16 11:42:56.013650519 +0200
5dbb6f
+++ openssh-8.7p1/scp.c	2021-09-16 11:53:03.249713836 +0200
5dbb6f
@@ -596,6 +596,14 @@ main(int argc, char **argv)
5dbb6f
 	if (iamremote)
5dbb6f
 		mode = MODE_SCP;
5dbb6f
 
5dbb6f
+	if (mode == MODE_SCP) {
5dbb6f
+		FILE *f = fopen(_PATH_SCP_KILL_SWITCH, "r");
5dbb6f
+		if (f != NULL) {
5dbb6f
+			fclose(f);
5dbb6f
+			fatal("SCP protocol is forbidden via %s", _PATH_SCP_KILL_SWITCH);
5dbb6f
+		}
5dbb6f
+	}
5dbb6f
+
5dbb6f
 	if ((pwd = getpwuid(userid = getuid())) == NULL)
5dbb6f
 		fatal("unknown user %u", (u_int) userid);
5dbb6f