Created attachment 251384 [details] mysql80 Hi, attached is a mechanical patch (untested) which makes the rc.d script service jails ready. This is a new feature in -current. The setup I've chosen is to allow ipv4/ipv6 access. It does not allow to use sysv IPC in a jail. IF you want to add this possibility, the config would need to be changed to "net_basic sysvipc" instead. The config can be overridden in rc.conf. See also: https://docs.freebsd.org/en/books/handbook/jails/#service-jails https://docs.freebsd.org/en/articles/rc-scripting/#rcng-service-jails Bye, Alexander.
Created attachment 251385 [details] mysql81
Created attachment 251386 [details] mysql84
Note: this does not work with service jails, as the filename of the rc.d script is not the same as the value of the name variable inside. Both should match. Quoting https://docs.freebsd.org/en/articles/rc-scripting/ > Now it is the right time to choose a unique name for our script once and for all. We will use it in a number of places while developing the script. The content of the name variable needs to match the script name, some parts of FreeBSD (e.g., service jails and the cpuset feature of the rc framework) depend upon this. As such the filename shall also not contain characters which may be troublesome in scripting (e.g., do not use a hyphen "-" and others).
Somehow a part of the quote was lost: Now it is the right time to choose a unique name for our script once and for all. We will use it in a number of places while developing the script. The content of the name variable needs to match the script name, some parts of FreeBSD (e.g., service jails and the cpuset feature of the rc framework) depend upon this. As such the filename shall also not contain characters which may be troublesome in scripting (e.g., do not use a hyphen "-" and others).
Hi Alexander, sorry for the very late reply, this PR simply got lost on my side. As you noted yourself in comment 3, the patches don't actually work for the mysql ports, since the script is installed as "mysql-server" but name is "mysql". Renaming the script is not an option for me, "service mysql-server start" is muscle memory for admins since decades. Wouldn't it make more sense to fix this in rc.subr instead? It already knows the script path (rc_service), so the svcj code could use its basename instead of ${name} for exec.start/exec.stop. That would solve the problem for all ports with mismatching script names at once. Once that works I'm happy to add the svcj_options default to the mysql ports (8.1 is gone btw, today it's 8.0/8.4/9.7).
rc_service is a good catch! Committed in d0f0a3b89b932b776b76278fa6885f19e8b30cbb Will be MFCed in about a week.
(In reply to Alexander Leidinger from comment #6) Hi Alexander, I gave this a real test on a 15.1 VM (with 0bee17af48dd applied) and found a second problem: "service mysql-server stop" fails with "kill: Operation not permitted" and leaves the jail plus mysqld running. The default stop path kills from the host via run_rc_killcmd, and since the mysql script sets mysql_user, the kill is wrapped in "su -m mysql". An unprivileged user on the host can't signal processes inside a child jail. This hits every svcj service that sets ${name}user, scripts with their own stop_cmd are not affected since those are stopped via service -j inside the jail. The following works for me (tested: start/status/stop/restart in the svcj all fine, normal operation without svcj unchanged), in _run_rc_killcmd after the su wrapper: if checkyesno ${name}_svcj && [ "${_rc_svcj}" != jailing ]; then _cmd="/usr/sbin/jexec svcj-${name} ${_cmd}" fi I have the port patches for mysql80/84/97 ready and tested, but I'll hold them back until this is fixed in base, otherwise we'd ship a broken stop.
(In reply to Jochen Neumeister from comment #7) Fixed in -current (together with fixes for some more issues and unit tests for several operations). MFC to stable/15 in a month.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=443408a666860c2949ca9318b316f2f88b3176f0 commit 443408a666860c2949ca9318b316f2f88b3176f0 Author: Alexander Leidinger <netchild@FreeBSD.org> AuthorDate: 2026-09-05 20:23:57 +0000 Commit: Jochen Neumeister <joneum@FreeBSD.org> CommitDate: 2026-09-05 20:24:37 +0000 databases/mysql*-server: make the rc script service jail aware Set a default of net_basic for the service jail options, so mysqld can use IPv4/IPv6 when it is started in a service jail. The default can be overridden via rc.conf. PR: 279672 Sponsored by: Netzkommune GmbH databases/mysql80-server/Makefile | 2 +- databases/mysql80-server/files/mysql-server.in | 1 + databases/mysql84-server/Makefile | 2 +- databases/mysql84-server/files/mysql-server.in | 1 + databases/mysql97-server/Makefile | 2 +- databases/mysql97-server/files/mysql-server.in | 1 + 6 files changed, 6 insertions(+), 3 deletions(-)