Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topgrade fails to initiate remote connection to FreeBSD host/tcsh/sh shell #996

Open
3 of 6 tasks
Kreeblah opened this issue Dec 7, 2024 · 3 comments
Open
3 of 6 tasks
Assignees
Labels
C-bug Something isn't working

Comments

@Kreeblah
Copy link
Contributor

Kreeblah commented Dec 7, 2024

Erroneous Behavior

I added a FreeBSD host to the remote_topgrades option on my Mac, and it fails to connect with the following error:

Connecting to myhost.domain.com...
Illegal option -l
Connection to myhost.domain.com closed.
Remote (bigwhoop.home.kreeblah.com) failed: 
   0: Command failed: `/usr/bin/ssh -t myhost.domain.com env 'TOPGRADE_PREFIX=myhost.domain.com' '$SHELL' -lc topgrade`
   1: `/usr/bin/ssh` failed: exit status: 2

Location:
   src/steps/remote/ssh.rs:53

Expected Behavior

I'd expect the remote connection to work, like it does when I connect to Linux hosts.

Steps to reproduce

Add a FreeBSD 14.2-RELEASE host to remote_topgrades. Attempt to run topgrade.

Possible Cause (Optional)

FreeBSD doesn't use bash or dash as the default shell. Instead, the shell at /bin/sh is a different Bourne-like shell. So, it works a little differently. In this case, if the first argument begins with -, then it runs the shell as though it's a login shell (in other words, -l isn't necessary if you're using -c).

Problem persists without calling from topgrade

  • Yes
  • No
    Running /bin/sh -lc topgrade locally on the FreeBSD host still exhibits the issue.

Did you run topgrade through Remote Execution

  • Yes
  • No

If yes, does the issue still occur when you run topgrade directly in your
remote host

  • Yes
  • No
    Running /bin/sh -lc topgrade locally on the FreeBSD host still exhibits the issue.

Additional Details

  • Operation System/Version
    FreeBSD 14.2-RELEASE - Remote system
    macOS 15.1.1 - Local system

  • Installation
    Installed from Homebrew for local copy and installed from FreeBSD packages for remote copy.

  • Topgrade version (topgrade -V)
    Local - topgrade 16.0.2
    Remote - topgrade 16.0.1

Verbose Output (topgrade -v)

Connecting to myhost.domain.com...
DEBUG Executing command `/usr/bin/ssh -t myhost.domain.com env 'TOPGRADE_PREFIX=myhost.domain.com' '$SHELL' -lc topgrade`
Illegal option -l
Connection to myhost.domain.com closed.
DEBUG Command failed: Err(
   0: Command failed: `/usr/bin/ssh -t myhost.domain.com env 'TOPGRADE_PREFIX=myhost.domain.com' '$SHELL' -lc topgrade`
   1: `/usr/bin/ssh` failed: exit status: 2

Location:
src/steps/remote/ssh.rs:53)
DEBUG Step "Remote (myhost.domain.com)" failed:
0: Command failed: /usr/bin/ssh -t myhost.domain.com env 'TOPGRADE_PREFIX=myhost.domain.com' '$SHELL' -lc topgrade
1: /usr/bin/ssh failed: exit status: 2

Location:
src/steps/remote/ssh.rs:53
Remote (myhost.domain.com) failed:
0: Command failed: /usr/bin/ssh -t myhost.domain.com env 'TOPGRADE_PREFIX=myhost.domain.com' '$SHELL' -lc topgrade
1: /usr/bin/ssh failed: exit status: 2

Location:
src/steps/remote/ssh.rs:53

@Kreeblah Kreeblah added the C-bug Something isn't working label Dec 7, 2024
@SteveLauC
Copy link
Member

if the first argument begins with -, then it runs the shell as though it's a login shell (in other words, -l isn't necessary if you're using -c).

Thanks for explaining it, the man page I found also verifies this:

If the first argument (argument 0) to the shell is '-' then it is a login shell. A login shell can be also specified by invoking the shell with the -l flag as the only argument.

@SteveLauC SteveLauC changed the title topgrade fails to initiate remote connection to FreeBSD host topgrade fails to initiate remote connection to FreeBSD host/tcsh shell Dec 10, 2024
@SteveLauC SteveLauC self-assigned this Dec 10, 2024
@Kreeblah
Copy link
Contributor Author

So, that man page is relevant, but I should probably mention that only FreeBSD 13 and below uses tcsh as the default shell, whereas FreeBSD 14 and up use sh instead. The man page for sh has the full details on this.

In this case, the main difference is that although both act the same way if the first argument begins with -, shexplicitly doesn't support a -l parameter (which is what's causing the error there).

@SteveLauC
Copy link
Member

Thanks for the explanation, then I have another case to deal with 😄

@SteveLauC SteveLauC changed the title topgrade fails to initiate remote connection to FreeBSD host/tcsh shell topgrade fails to initiate remote connection to FreeBSD host/tcsh/sh shell Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants