3.0 KiB
FreeBSD Support Improvements
- Native Build Artefacts
Updateoc2r-native-networking/build.shso producingliboc2rnet-bsd-{x86_64,arm64}.sois part of the normal build pipeline. At the moment the script never emits BSD binaries, so new resources would be missing from CI outputs.
Build and install (FreeBSD)
-
Install prerequisites
pkg install openjdk17 clang gmake export JAVA_HOME=/usr/local/openjdk17 # adjust if your JDK lives elsewhere -
Build the FreeBSD JNI bridge
cd oc2r-native-networking ./build-freebsd.sh cp build/liboc2rnet-bsd-*.so ../oc2r/src/main/resources/natives/bsd/ # Adjust to your oc2r sources location -
Compile and install the helper
cc -O2 -Wall -Wextra -pedantic oc2rnet-helper.c -o oc2rnet-helper install -o root -g wheel -m 0755 oc2rnet-helper /usr/local/libexec/oc2rnet-helper chmod u+s /usr/local/libexec/oc2rnet-helper
Launch helper and validation
-
Launch the helper
- Foreground check:
/usr/local/libexec/oc2rnet-helper - Background:
daemon -r -f /usr/local/libexec/oc2rnet-helper
- Foreground check:
-
Validate the socket and raw privileges
ls -l /var/run/oc2rnet-helper.sock sockstat -l | grep oc2rnet -
Test the jni against helper
cc -DCLITEST -O2 -Wall -Wextra -pedantic -Ijni-headers -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/freebsd" bsd_impl.c -o pingtest ./pingtest 9.9.9.9Expect a successful payload echo when the helper is reachable; a
NULLresult signals the helper was unavailable, matching the mod’s fallback behaviour. -
(optional) Kill daemon
kill "$(pgrep -fx 'daemon -r -f /usr/local/libexec/oc2rnet-helper')"
Recompile java mod with freebsd compat
-
If not already done copy the so file(s) compiled in step 2 of the build section
-
(optional) Change o2cr mod version in
gradle.properties -
Run
./gradlew buildin the oc2r sources files modified to support FreeBSD -
Get the file located in
./build/libs/oc2r-*-all.jarand put it in yourmodsdirectory
Important note
Run the helper with daemon(8) or an rc.d script so it stays available. The
JNI bridge will fall back to returning null if the helper is unreachable.
Optional helper configuration
Set these environment variables before launching the helper to adjust runtime behaviour:
OC2RNET_SOCKET_MODE(octal, default0666) — override the UNIX socket mode.OC2RNET_SOCKET_GROUP— chown the socket to this group afterbind(2).OC2RNET_DROP_USER(defaultnobody) — unprivileged account the helper switches to once initialisation is complete.OC2RNET_SOCK(default/var/run/oc2rnet-helper.sock) — alternate socket path for jails or non-standard hierarchies.OC2RNET_NO_CAPSICUM— set to any value to skipcap_enter()when Capsicum blocks raw sockets on older releases.