From 4cb4fc6eac621196ce30c5506b5e36b94b643354 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Sun, 16 Feb 2020 10:10:14 -0500 Subject: [PATCH 1/4] Use CPPFLAGS in the Makefile (closes #43) Debian uses CPPFLAGS to pass arguments like -D_FORTIFY_SOURCE=2. --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 507b2f7..119347a 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,15 @@ .POSIX: -CC = cc -CFLAGS = -std=c99 -Wall -Wextra -Wno-missing-field-initializers -Os -LDFLAGS = -ggdb3 -LDLIBS = -PREFIX = /usr/local +CC = cc +CFLAGS = -std=c99 -Wall -Wextra -Wno-missing-field-initializers -Os +CPPFLAGS = +LDFLAGS = -ggdb3 +LDLIBS = +PREFIX = /usr/local all: endlessh endlessh: endlessh.c - $(CC) $(LDFLAGS) $(CFLAGS) -o $@ endlessh.c $(LDLIBS) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ endlessh.c $(LDLIBS) install: endlessh install -d $(DESTDIR)$(PREFIX)/bin -- 2.39.0 From a5913cbbb297d379893337e6281b6412339b5098 Mon Sep 17 00:00:00 2001 From: "Peter H. Froehlich" Date: Thu, 24 Dec 2020 00:43:20 +0100 Subject: [PATCH 2/4] Three notes on OpenBSD. --- README.md | 21 +++++++++++++++++++++ util/openbsd/README.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 util/openbsd/README.md diff --git a/README.md b/README.md index d7e9ef1..16debcd 100644 --- a/README.md +++ b/README.md @@ -108,5 +108,26 @@ to remove GCC-specific options. For example, on Solaris: The feature test macros on these systems isn't reliable, so you may also need to use `-D__EXTENSIONS__` in `CFLAGS`. +### OpenBSD + +The man page needs to go into a different path for OpenBSD's `man` command: + +``` +diff --git a/Makefile b/Makefile +index 119347a..dedf69d 100644 +--- a/Makefile ++++ b/Makefile +@@ -14,8 +14,8 @@ endlessh: endlessh.c + install: endlessh + install -d $(DESTDIR)$(PREFIX)/bin + install -m 755 endlessh $(DESTDIR)$(PREFIX)/bin/ +- install -d $(DESTDIR)$(PREFIX)/share/man/man1 +- install -m 644 endlessh.1 $(DESTDIR)$(PREFIX)/share/man/man1/ ++ install -d $(DESTDIR)$(PREFIX)/man/man1 ++ install -m 644 endlessh.1 $(DESTDIR)$(PREFIX)/man/man1/ + + clean: + rm -rf endlessh +``` [np]: https://nullprogram.com/blog/2019/03/22/ diff --git a/util/openbsd/README.md b/util/openbsd/README.md new file mode 100644 index 0000000..d3e24bc --- /dev/null +++ b/util/openbsd/README.md @@ -0,0 +1,34 @@ +# Running `endlessh` on OpenBSD + +## Covering IPv4 and IPv6 + +If you want to cover both IPv4 and IPv6 you'll need to run *two* instances of +`endlessh` due to OpenBSD limitations. Here's how I did it: + +- copy the `endlessh` script to `rc.d` twice, as `endlessh` and `endlessh6` +- copy the `config` file to `/etc/endlessh` twice, as `config` and `config6` + - use `BindFamily 4` in `config` + - use `BindFamily 6` in `config6` +- in `rc.conf.local` force `endlessh6` to load `config6` like so: + +``` +endlessh6_flags=-s -f /etc/endlessh/config6 +endlessh_flags=-s +``` + +## Covering more than 128 connections + +The defaults in OpenBSD only allow for 128 open file descriptors per process, +so regardless of the `MaxClients` setting in `/etc/config` you'll end up with +something like 124 clients at the most. +You can increase these limits in `/etc/login.conf` for `endlessh` (and +`endlessh6`) like so: + +``` +endlessh:\ + :openfiles=1024:\ + :tc=daemon: +endlessh6:\ + :openfiles=1024:\ + :tc=daemon: +``` -- 2.39.0 From 1ecaafd5778c763c1fe633c4631d87b5ac8bfe6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 18 Apr 2021 14:55:32 +0200 Subject: [PATCH 3/4] Fix format string defect in log message (#63) --- endlessh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endlessh.c b/endlessh.c index adb8ad3..4b730f1 100644 --- a/endlessh.c +++ b/endlessh.c @@ -504,7 +504,7 @@ static void config_log(const struct config *c) { logmsg(log_info, "Port %d", c->port); - logmsg(log_info, "Delay %ld", c->delay); + logmsg(log_info, "Delay %d", c->delay); logmsg(log_info, "MaxLineLength %d", c->max_line_length); logmsg(log_info, "MaxClients %d", c->max_clients); logmsg(log_info, "BindFamily %s", -- 2.39.0 From dfe44eb2c5b6fc3c48a39ed826fe0e4459cdf6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 18 Apr 2021 14:56:58 +0200 Subject: [PATCH 4/4] Mark file local statistics struct static (#63) --- endlessh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endlessh.c b/endlessh.c index 4b730f1..e448d59 100644 --- a/endlessh.c +++ b/endlessh.c @@ -105,7 +105,7 @@ logsyslog(enum loglevel level, const char *format, ...) } } -struct { +static struct { long long connects; long long milliseconds; long long bytes_sent; -- 2.39.0