Created attachment 174540 [details] rc.subr.diff Recently I was having issues with a port after upgrading from 10.3 to 11. (This bug also exists on head) When the chdir var is used, the limits command will be prepended to chdir instead of the prog. This can, and in my case caused the cd command to fail and the program will fail to start. i'm going to omit much of the debugging info and paste the useful points. Current rc.subr: + _doit='limits -C daemon cd /var/db/teamspeak && /usr/sbin/daemon -fp /var/db/teamspeak/teamspeak_server.pid -u teamspeak /usr/local/libexec/ts3server dbsqlpath=/usr/local/share/teamspeak/server/sql/ inifile=/usr/local/etc/teamspeak/ts3server.ini licensepath=/usr/local/etc/teamspeak/ logpath=/var/log/teamspeak' + _run_rc_doit 'limits -C daemon cd /var/db/teamspeak && /usr/sbin/daemon -fp /var/db/teamspeak/teamspeak_server.pid -u teamspeak /usr/local/libexec/ts3server dbsqlpath=/usr/local/share/teamspeak/server/sql/ inifile=/usr/local/etc/teamspeak/ts3server.ini licensepath=/usr/local/etc/teamspeak/ logpath=/var/log/teamspeak' + debug 'run_rc_command: doit: limits -C daemon cd /var/db/teamspeak && /usr/sbin/daemon -fp /var/db/teamspeak/teamspeak_server.pid -u teamspeak /usr/local/libexec/ts3server dbsqlpath=/usr/local/share/teamspeak/server/sql/ inifile=/usr/local/etc/teamspeak/ts3server.ini licensepath=/usr/local/etc/teamspeak/ logpath=/var/log/teamspeak' + eval 'limits -C daemon cd /var/db/teamspeak && /usr/sbin/daemon -fp /var/db/teamspeak/teamspeak_server.pid -u teamspeak /usr/local/libexec/ts3server dbsqlpath=/usr/local/share/teamspeak/server/sql/ inifile=/usr/local/etc/teamspeak/ts3server.ini licensepath=/usr/local/etc/teamspeak/ logpath=/var/log/teamspeak' + limits -C daemon cd /var/db/teamspeak + /usr/sbin/daemon -fp /var/db/teamspeak/teamspeak_server.pid -u teamspeak /usr/local/libexec/ts3server 'dbsqlpath=/usr/local/share/teamspeak/server/sql/' 'inifile=/usr/local/etc/teamspeak/ts3server.ini' 'licensepath=/usr/local/etc/teamspeak/' 'logpath=/var/log/teamspeak' Attached, I have created a small change to rc.subr that fixes this issue.
Created attachment 175378 [details] PATCH fix problem with chdir and limits in rc.subr Hi, I was just bitten by the same bug. The suggested fix here is not correct, though, since the limits clause is moved into the else clauee after "if chroot". I've attached another suggestion to fix this, that works with chroot as well. Palle
Hi, I'm taking the liberty to add adrian@ who committed the original work and dteske who reviewed it, just to draw your attention to this corner case, hope you don't mind. Palle
lgtm
So who can commit it. I'm only a porter, no commit bit in src. :)
If still pending by this weekend, I'll jump on it. Pretty busy right now though.
(In reply to Devin Teske from comment #6) Seems like this still isn't fixed? Since this bites me as well, can you please look into it?
Have manually applied the suggested fix, and can confirm that it works.
I've filed a patch for review. https://reviews.freebsd.org/D8232 Changed "_docd" from girgen's patch to "_cd" to prevent confusion (docd could be shorthand for "doc directory" instead of "do cd"). Changed the way NULL values are assigned (no quotes needed).
The same Teamspeak issue affected me as well. I applied the patch from https://reviews.freebsd.org/D8232 and now my Teamspeak service runs again. Thanks for the patch.
Since I patched my rc.subr Teamspeak works like a charm. Thanks.
https://reviews.freebsd.org/D8232 was accepted, has this been committed yet?
(In reply to Ultima from comment #12) We're waiting on Adrian
The fix is working flawlessly for me too.
Still waiting on Adrian
any news here?
A commit references this bug: Author: dteske Date: Sat Dec 3 19:03:40 UTC 2016 New revision: 309504 URL: https://svnweb.freebsd.org/changeset/base/309504 Log: Fix bug preventing limits(1) from being applied PR: misc/212493 Differential Revision: https://reviews.freebsd.org/D8232 Submitted by: girgen Reviewed by: adrian MFC after: 3 days X-MFC-to: stable/11 Changes: head/etc/rc.subr
(In reply to Matthias Fechner from comment #16) Adrian approved today. It's committed. Waiting 3 days for MFC to stable/11.
(In reply to Devin Teske from comment #18) Thanks a lot Devin! Hopefully it goes quickly into the stable branch. After this is fixed I can rollout freebsd 11 to all servers.
A commit references this bug: Author: dteske Date: Tue Dec 13 04:50:45 UTC 2016 New revision: 310010 URL: https://svnweb.freebsd.org/changeset/base/310010 Log: MFC r309504: Fix bug preventing limits(1) from being applied PR: misc/212493 Differential Revision: https://reviews.freebsd.org/D8232 Submitted by: girgen Reviewed by: adrian Changes: _U stable/11/ stable/11/etc/rc.subr
Will this be MFC'd to releng/11.0?
(In reply to Ultima from comment #21) When we merge into stable, it's from head (aka Current) and hence "MFC" is Merge from Current [into Stable]. When we merge into releng, it's from stable and hence "MFS" is the appropriate acronym here, for Merge from Stable [into Releng]. Merging into releng requires approval from secteam@ and/or releng@. I will be pointing them at this bug and see if I can get approval for MFS.
(In reply to Devin Teske from comment #22) Ah, Thanks for clearing this up. I have been getting messages from users asking when the port will be fixed and I refer them to this bug and that its not the port, waiting for MFC (actually is MFS). I hope there is an __FreeBSD_version bump if this gets MFS.
Yeah, would it be possible to get this into an errata? For some ports this is a big problem.
Put me down as another vote for merge, or at least errata noting. I just wasted well over an hour trying to figure out why a program with _chdir was failing to start.
Is there a time planning available this will be fixed in FreeBSD 11 (available via freebsd-update)? This is the last bug that prevents me to update all servers to FreeBSD 11. Thanks a lot for your answers.
batch change of PRs untouched in 2018 marked "in progress" back to open.
(In reply to commit-hook from comment #20) This was comitted in 2016.