changeset 1634:aabde6f57fce

Add a sanity check for DROPBEAR_SVR_MULTIUSER==0 mode
author Matt Johnston <matt@ucc.asn.au>
date Wed, 20 Mar 2019 22:57:06 +0800
parents 592a18dac250
children c9b5017b0a7b
files common-session.c default_options.h
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/common-session.c	Wed Mar 20 14:44:49 2019 +0000
+++ b/common-session.c	Wed Mar 20 22:57:06 2019 +0800
@@ -68,6 +68,16 @@
 	/* Sets it to lowdelay */
 	update_channel_prio();
 
+#if !DROPBEAR_SVR_MULTIUSER
+	/* A sanity check to prevent an accidental configuration option
+	   leaving multiuser systems exposed */
+	errno = 0;
+	getuid();
+	if (errno != ENOSYS) {
+		dropbear_exit("Non-multiuser Dropbear requires a non-multiuser kernel");
+	}
+#endif
+
 	now = monotonic_now();
 	ses.connect_time = now;
 	ses.last_packet_time_keepalive_recv = now;
--- a/default_options.h	Wed Mar 20 14:44:49 2019 +0000
+++ b/default_options.h	Wed Mar 20 22:57:06 2019 +0800
@@ -196,7 +196,9 @@
  * authorized_keys file into account */
 #define DROPBEAR_SVR_PUBKEY_OPTIONS 1
 
-/* Disable if your kernel does not have multiple user support */
+/* Set this to 0 if your system does not have multiple user support.
+   (Linux kernel CONFIG_MULTIUSER option)
+   The resulting binary will not run on a normal system. */
 #define DROPBEAR_SVR_MULTIUSER 1
 
 /* Client authentication options */