On 2023-04-25, rea...@catastrophe.net <rea...@catastrophe.net> wrote: > On Tue, Apr 25, 2023 at 08:32:35PM +0200, Antoine Jacoutot wrote: >>On Tue, Apr 25, 2023 at 01:16:22PM -0500, rea...@catastrophe.net wrote: >>> On Tue, Apr 25, 2023 at 08:09:46PM +0200, Antoine Jacoutot wrote: >>> >On Tue, Apr 25, 2023 at 12:41:41PM -0500, rea...@catastrophe.net wrote: >>> >> On Tue, Apr 25, 2023 at 12:03:51PM -0500, rea...@catastrophe.net wrote: >>> >> >On Tue, Apr 25, 2023 at 10:45:21AM -0500, rea...@catastrophe.net wrote: >>> >> >> [..] >>> >> >> [ some bad paste ] >>> >> > >>> >> >Just a clarification: the rc script in /etc/rc.d/autossh actually looks >>> >> >like >>> >> > >>> >> >#!/bin/ksh >>> >> ># start autossh tunnel >>> >> ># requires remoteuser user with $HOME/.ssh/config and keys >>> >> > >>> >> >daemon="/usr/local/bin/autossh" >>> >> >daemon_flags_1="-M 0 -f -N tun-remoteA" >>> >> >daemon_flags_2="-M 0 -f -N tun-remoteB" >>> >> >daemon_user="remoteuser" >>> >> > >>> >> >. /etc/rc.d/rc.subr >>> >> > >>> >> >rc_reload=NO >>> >> > >>> >> >pexp="autossh:.*" >>> >> > >>> >> ># Child will not return a config parsing error to the parent. >>> >> >rc_start() { >>> >> > # use rcexec here since daemon_flags may contain arguments with >>> >> > spaces >>> >> > ${rcexec} "${daemon} ${daemon_flags_1}" && \ >>> >> > ${rcexec} "${daemon} ${daemon_flags_2}" >>> >> >} >>> >> > >>> >> >rc_cmd $1 >>> >> >>> >> >>> >> So tracking this down a bit more, if I modify the rc script to just >>> >> list remoteuser's ~/.ssh/config file issues arise >>> > >>> >That's not what the script does from what I can see. >>> > >>> >> rc_start() { >>> >> # use rcexec here since daemon_flags may contain arguments with >>> >> spaces >>> >> ls -l ${daemon_user}/.ssh/config >>> >> #${rcexec} "${daemon} ${daemon_flags_1}" && \ >>> >> #${rcexec} "${daemon} ${daemon_flags_2}" >>> >> } >>> >> >>> >> # rcctl -d start autossh >>> >> doing _rc_parse_conf >>> >> autossh_flags empty, using default >< >>> >> doing rc_check >>> >> autossh >>> >> doing rc_start >>> >> doing _rc_wait_for_start >>> >> doing rc_check >>> >> ls: remoteuser/.ssh/config: No such file or directory >>> >> doing _rc_rm_runfile >>> >> (failed) >>> > >>> >Well it's doing exactly what you are telling it to do. >>> >Not sure I understand what you mean. >>> >>> You missed the second part where I said: >>> >>> But if I add prepend "/home" to ${daemon_user}, it works as expected. >>> >> >>I didn't miss anything. >> >>"ls -l ${daemon_user}/.ssh/config" >>Which translate to "ls remoteuser/.ssh/config". >>That file does not exist (it's not an absolute path so if you run it from >>anywhere other than /home, then it won't be found). >> >>When you append /home you are doing: >>"ls -l /home/${daemon_user}/.ssh/config" which translate to an absolute path: >>/home/remoteuser/.ssh/config. > > Yes, that's exactly correct and I was showing that, somewhere along the way > from 7.2 to 7.3, something changed to break the original rc script I > posted and that which is quoted at the top of this mail.
So let's ignore this ls -l red herring, which cannot have worked in 7.2 either (I think you might have meant to type ~${daemon_user} or something, but anyway..) The rc.d subsystem is really intended for internal use by system daemons, ports, etc. As such, changes are sometimes made to how it works, and everything is updated in ports/base as necessary, but if you're writing your own you will need to keep track of those changes yourself. I think what you're missing are these two commits: ---------------------------- revision 1.153 date: 2022/05/21 10:50:09; author: ajacoutot; state: Exp; lines: +13 -6; commitid: iyDYBSL549hXuvMg; Replace the $rcexec variable by an rc_exec function. It is much cleaner to the eyes and makes more sense from a functionnal point of view. This will allow to extend rc_exec with other functionnalities (like upcoming rc_startdir). Bonus point: daemon_logger will now work with manually crafted rc_start functions. This will require a mechanical change from ${rcexec} to rc_exec in rc.d scripts. ports will be fixed right after this commit but we will keep compatibility to give a chance to people to fix their custom scripts. positive tests from a few ok robert@ ---------------------------- ---------------------------- revision 1.160 date: 2022/10/19 21:04:45; author: ajacoutot; state: Exp; lines: +1 -3; commitid: A78P0jfG7qlNxhdx; Drop support for $rcexec; people should now use the rc_exec function. prodded by jsg@ ---------------------------- though FWIW I think this should be split into two scripts, the subsystem isn't geared up to handle one script dealing with two separate daemons. (or alternatively what I normally do when I use autossh here is to add @reboot cron jobs)...