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

Fixes for OpenSSH 9.6 #25

Merged
merged 4 commits into from
Jan 2, 2024
Merged

Fixes for OpenSSH 9.6 #25

merged 4 commits into from
Jan 2, 2024

Conversation

martinpitt
Copy link
Collaborator

@martinpitt martinpitt commented Jan 2, 2024

See cockpit-project/bots#5733. When updating ferny locally to this version, it fixes at least TestSuperuserDashboard.test. I'll do a test run in a cockpit PR to validate all of this mess: cockpit-project/cockpit#19799

martinpitt added a commit to martinpitt/cockpit that referenced this pull request Jan 2, 2024
This unbreaks the Shell's SSH support with the latest round of OpenSSH
security updates.

FIXME: This currently tests allisonkarlitskaya/ferny#25
update the SHA after that PR has landed.
@martinpitt
Copy link
Collaborator Author

cockpit-project/cockpit#19799 works fine, so let's please get that in ASAP? Then we need to do stable release updates in Debian and Ubuntu for cockpit.

Copy link
Owner

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to see a bit neater handling of the expected exceptions in the unit test, but this can also go in as-is, if you're in a hurry. Thanks!

@@ -94,8 +94,9 @@ async def test_connection_refused(runtime_dir: pathlib.Path) -> None:
@pytest.mark.asyncio
async def test_dns_error(runtime_dir: pathlib.Path) -> None:
session = ferny.Session()
with pytest.raises(socket.gaierror):
with pytest.raises(Exception) as exc_info:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs look like you can pass a tuple of expected exception types here.

https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.raises

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did look at the docs, but I missed the Union(Tuple) thing. Seems to work!

@@ -37,3 +37,21 @@ jobs:

- name: Run unit tests
run: PYTHONPATH=src python3 -m pytest --color=yes

debian:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta-level: I wonder if we should take this situation as:

  • a failure to detect incoming changes (ie: we need better/regular testing in this area)
  • an indication that everything actually worked out fine, since we did catch the issue relatively quickly...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been nice to catch a bit earlier, though. This is more forward-looking.. It's easy and cheap to test on Debian, so let's?

@@ -2,6 +2,8 @@ name: CI
on:
push:
pull_request:
schedule:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. lol. yes. :)

OpenSSH 0.9.6 "now bans most shell metacharacters from user and
hostnames supplied via the command-line" [1], so it rejects the test's
invalid host name even before it gets tossed to the DNS resolver. Accept
the alternate exception as well.

[1] https://www.openssh.com/txt/release-9.6
`-` is not a valid host name, and gets rejected by OpenSSH 0.9.6. Use a
valid hostname in has_feature() to unbreak feature detection.
Fedora 39 and Rawhide have quite an old OpenSSH (9.3 at the moment).
Debian unstable has the latest 9.6. This reproduces the issues fixed
in the last two commits.

`test_cancel_askpass` hangs forever in Debian, skip this test for the
time being.
This ensures that ferny keeps working on Fedora/Debian with incoming OS
updates, and timely alerts us about regressions.
@@ -94,7 +94,7 @@ async def test_connection_refused(runtime_dir: pathlib.Path) -> None:
@pytest.mark.asyncio
async def test_dns_error(runtime_dir: pathlib.Path) -> None:
session = ferny.Session()
with pytest.raises(socket.gaierror):
with pytest.raises((socket.gaierror, ferny.ssh_errors.SshError)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow-ups:

  • is it worth capturing and categorizing the new message? I don't like that we blanket-capture SshError here.
  • should we try another hostname that is sure to get us a gaierror without hanging in case there's no network access?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, sent PR #26 for these

@martinpitt martinpitt merged commit f869d10 into main Jan 2, 2024
7 checks passed
@martinpitt martinpitt deleted the ssh-fixes branch January 2, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants