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


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)


But if I add prepend "/home" to ${daemon_user}, it works as expected.

rc_start() {
        # use rcexec here since daemon_flags may contain arguments with spaces
        ls -l /home/${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
-r--------  1 remoteuser  users  459 Mar 16  2022 /home/remoteuser/.ssh/config
doing _rc_write_runfile
(ok)


So I'm back to asking if something changed with the way rc.d handles 
$daemon_user and if there is any way to resolve the issue (short of
hard-coding everything behind rcexec in the startup?

Thanks.

Reply via email to