Initial Commit
- initial default booting image
This commit is contained in:
89
package/ser2net/0001-Fix-authorization-path-handling.patch
Normal file
89
package/ser2net/0001-Fix-authorization-path-handling.patch
Normal file
@@ -0,0 +1,89 @@
|
||||
From fa6c2a8840cbc8d7622e46ce12ba15ecc0fb51b7 Mon Sep 17 00:00:00 2001
|
||||
From: Corey Minyard <corey@minyard.net>
|
||||
Date: Thu, 23 Jul 2026 10:51:25 -0500
|
||||
Subject: [PATCH] Fix authorization path handling
|
||||
|
||||
The username is received from the remote end and thus untrusted. Make
|
||||
sure it doesn't have any characters that can cause it to escape the
|
||||
directory it is supposed to be in when constructing a path.
|
||||
|
||||
Reported-by: TristanInSec
|
||||
Signed-off-by: Corey Minyard <corey@minyard.net>
|
||||
|
||||
Upstream: https://github.com/cminyard/ser2net/commit/fa6c2a8840cbc8d7622e46ce12ba15ecc0fb51b7
|
||||
|
||||
Signed-off-by: Mattia Narducci <mattianarducci1@gmail.com>
|
||||
---
|
||||
auth.c | 42 ++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 38 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/auth.c b/auth.c
|
||||
index 95c80b4..53c3186 100644
|
||||
--- a/auth.c
|
||||
+++ b/auth.c
|
||||
@@ -185,6 +185,40 @@ handle_auth_begin(struct gensio *net, const char *authdir, const char *pamauth,
|
||||
return GE_NOTSUP;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Construct a secure authorization path.
|
||||
+ *
|
||||
+ * filename must be at least MAX_PATH.
|
||||
+ *
|
||||
+ * "username" is untrusted, the rest of the data is trusted.
|
||||
+ */
|
||||
+static bool
|
||||
+construct_auth_path(char *filename, const char *authdir, const char *username,
|
||||
+ const char *format, ...)
|
||||
+{
|
||||
+ size_t baselen;
|
||||
+ va_list ap;
|
||||
+
|
||||
+ /*
|
||||
+ * '/', '.', and '\' are all parts of things that can modify the base
|
||||
+ * path. Don't allow them in usernames.
|
||||
+ */
|
||||
+ if (strchr(username, '.') || strchr(username, '/')
|
||||
+ || strchr(username, '\\'))
|
||||
+ return false;
|
||||
+
|
||||
+ /* Get a good base path ending in / */
|
||||
+ baselen = snprintf(filename, PATH_MAX, "%s/%s/",
|
||||
+ authdir, username);
|
||||
+
|
||||
+ /* Now append the rest of the path. */
|
||||
+ va_start(ap, format);
|
||||
+ vsnprintf(filename + baselen, PATH_MAX - baselen, format, ap);
|
||||
+ va_end(ap);
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
handle_precert(struct gensio *net, const char *authdir)
|
||||
{
|
||||
@@ -228,8 +262,8 @@ handle_precert(struct gensio *net, const char *authdir)
|
||||
}
|
||||
}
|
||||
|
||||
- snprintf(filename, sizeof(filename), "%s/%s/allowed_certs/",
|
||||
- authdir, s);
|
||||
+ if (!construct_auth_path(filename, authdir, s, "allowed_certs/"))
|
||||
+ return GE_AUTHREJECT;
|
||||
err = gensio_control(net, 0, false, GENSIO_CONTROL_CERT_AUTH,
|
||||
filename, &len);
|
||||
if (err && err != GE_CERTNOTFOUND) {
|
||||
@@ -258,8 +292,8 @@ handle_password(struct gensio *net, const char *authdir, const char *password)
|
||||
return GE_AUTHREJECT;
|
||||
}
|
||||
|
||||
- snprintf(filename, sizeof(filename), "%s/%s/password",
|
||||
- authdir, username);
|
||||
+ if (!construct_auth_path(filename, authdir, username, "password"))
|
||||
+ return GE_AUTHREJECT;
|
||||
pwfile = fopen(filename, "r");
|
||||
if (!pwfile) {
|
||||
syslog(LOG_ERR, "Can't open password file %s: %s", filename,
|
||||
--
|
||||
2.55.0
|
||||
|
||||
11
package/ser2net/Config.in
Normal file
11
package/ser2net/Config.in
Normal file
@@ -0,0 +1,11 @@
|
||||
config BR2_PACKAGE_SER2NET
|
||||
bool "ser2net"
|
||||
depends on BR2_USE_MMU # fork()
|
||||
depends on BR2_TOOLCHAIN_HAS_ATOMIC # gensio
|
||||
select BR2_PACKAGE_GENSIO
|
||||
select BR2_PACKAGE_LIBYAML
|
||||
help
|
||||
Ser2net provides a way for a user to connect from a network
|
||||
connection to a serial port.
|
||||
|
||||
http://ser2net.sourceforge.net
|
||||
43
package/ser2net/S50ser2net
Normal file
43
package/ser2net/S50ser2net
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Startup script for ser2net
|
||||
#
|
||||
|
||||
start() {
|
||||
printf "Starting ser2net: "
|
||||
if [ ! -f /etc/ser2net.conf ] && [ ! -f /etc/ser2net/ser2net.yaml ] ; then
|
||||
echo "no configuration file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start-stop-daemon -S -q --exec /usr/sbin/ser2net -- -P /var/run/ser2net.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Shutting down ser2net: "
|
||||
start-stop-daemon -K -q -p /var/run/ser2net.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ser2net {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
6
package/ser2net/ser2net.hash
Normal file
6
package/ser2net/ser2net.hash
Normal file
@@ -0,0 +1,6 @@
|
||||
# From https://sourceforge.net/projects/ser2net/files/ser2net/
|
||||
md5 73b4ccc7e9d89034f1a1a20a780b9da9 ser2net-4.3.8.tar.gz
|
||||
sha1 d1597d88d154489cb08bac69bb1772712d30cbcd ser2net-4.3.8.tar.gz
|
||||
# Locally computed:
|
||||
sha256 e5620975523059a38709bb53c0567600adbbcb8011066a2d2fe1b4db9efe0ba3 ser2net-4.3.8.tar.gz
|
||||
sha256 501f3108e6c03e5a0a5585ebaaa369171aead5319cd0a7a4dc1f66211c1f09f1 COPYING
|
||||
29
package/ser2net/ser2net.mk
Normal file
29
package/ser2net/ser2net.mk
Normal file
@@ -0,0 +1,29 @@
|
||||
################################################################################
|
||||
#
|
||||
# ser2net
|
||||
#
|
||||
################################################################################
|
||||
|
||||
SER2NET_VERSION = 4.3.8
|
||||
SER2NET_SITE = https://downloads.sourceforge.net/project/ser2net/ser2net
|
||||
SER2NET_LICENSE = GPL-2.0+
|
||||
SER2NET_LICENSE_FILES = COPYING
|
||||
SER2NET_DEPENDENCIES = gensio libyaml
|
||||
|
||||
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
|
||||
SER2NET_CONF_OPTS += --with-pthreads
|
||||
else
|
||||
SER2NET_CONF_OPTS += --without-pthreads
|
||||
endif
|
||||
|
||||
# fix gensio detection with openssl enabled
|
||||
ifeq ($(BR2_PACKAGE_OPENSSL),y)
|
||||
SER2NET_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs openssl`"
|
||||
endif
|
||||
|
||||
define SER2NET_INSTALL_INIT_SYSV
|
||||
$(INSTALL) -D -m 755 package/ser2net/S50ser2net \
|
||||
$(TARGET_DIR)/etc/init.d/S50ser2net
|
||||
endef
|
||||
|
||||
$(eval $(autotools-package))
|
||||
Reference in New Issue
Block a user