Re: FreeBSD port of the Omada SDN Controller

From: Marcin Cieslak <saper_at_saper.info>
Date: Tue, 26 Aug 2025 21:42:55 UTC
On Tue, 26 Aug 2025, Mark Felder wrote:

> If someone could figure out a way to dynamically patch the class in the jar file -- either manually with a script the porter needs to run or as part of the port itself -- I'll pay out a $200 bounty. It would remove a lot of tedious pain when doing updates. I don't think it's possible though.

What about something like the below. Requires xxd and jar.

JARFILE=../Omada_SDN_Controller_v5.15.24.19_linux_x64/lib/omada-common-5.15.24.19.jar
ISLINUXOS_CLASS="com/tplink/smb/omada/common/util/S.class"

check() {
 	unzip -p "${JARFILE}" "${ISLINUXOS_CLASS}" | xxd -p -c 0 |
 	grep -q 02000969734c696e75784f53 || { echo >&2 "\"${ISLINUXOS_CLASS}\" does not check for Linux"; exit 1; }

patch() {
 	new_class_dir=`mktemp -d`
 	trap 'rm -rf -- "${new_class_dir}"' EXIT
 	dest_dir=`dirname "${ISLINUXOS_CLASS}"`
 	mkdir -p "${new_class_dir}/${dest_dir}"
 	unzip -p "${JARFILE}" "${ISLINUXOS_CLASS}" | xxd -p -c 0 | {
 		sed -e s,0100056c696e7578,01000766726565627364,
 	} | xxd -r -p > "${new_class_dir}/${ISLINUXOS_CLASS}"
 	jar uf "${JARFILE}" -C "${new_class_dir}" "${ISLINUXOS_CLASS}"
}
check && patch

Can't test if this really works at the moment, should update the omada-common-5.15.24.19.jar file in place. If "check" fails, we need to figure out whether the Linux-checking function has been moved, renamed or discarded.

Marcin