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

Correct undefined name error in LazyFqdn.__str__ #179

Closed
wants to merge 1 commit into from
Closed

Correct undefined name error in LazyFqdn.__str__ #179

wants to merge 1 commit into from

Conversation

@logic
Copy link

@logic logic commented Jun 25, 2013

If AddressFamily is set to anything but "any" in your ssh config, this (presumably little-used; it's a fluke of history that we have that enabled in our environment) code path runs, and the undefined "host" variable gets referenced. I'm guessing, at some point in the past, host used to be set to socket.gethostname(); here's a quick patch. :)

If AddressFamily is set to anything but "any" in your ssh config, this (presumably little-used; it's a fluke of history that we have that enabled in our environment) code path runs, and the undefined "host" variable gets referenced. I'm guessing, at some point in the past, host used to be set to socket.gethostname(); here's a quick patch. :)
@karenc
Copy link

@karenc karenc commented Aug 7, 2013

@stefanha @logic Here's the original patch:

fairview@0ed3734

The commits were from #110 and #128. The "host" line was probably removed because of a conflict resolution:

host = socket.gethostname().split('.')[0]

@Kami
Copy link

@Kami Kami commented Aug 21, 2013

(re-posting this from #201)

@stefanha Replacing it with self.config['hostname'] will work (in a way that exception is not thrown), but it's logically incorrect. LazyFqdn is used to replace %l variable which refers to a local host name, but self.config['hostname'] refers to a remote / target host name (%h).

@stefanha
Copy link

@stefanha stefanha commented Aug 21, 2013

@Kami agreed and thanks for fixing it!

@Kami
Copy link

@Kami Kami commented Aug 21, 2013

@stefanha No problem & thanks :)

@bitprophet
Copy link
Member

@bitprophet bitprophet commented Sep 27, 2013

Hi all, sorry for letting this sit around. I checked and it looks like the line utilizing socket.gethostname didn't go away, it was simply not handed to LazyFqdn which encapsulates the line which is breaking. I'm testing a fix now that simply passes in that host value to the constructor :)

As soon as I can convince a regression test to fail correctly I'll merge my fix.

@bitprophet
Copy link
Member

@bitprophet bitprophet commented Sep 27, 2013

Welp, got the test failing, but it exposes another issue - socket.getaddrinfo() is likely to fail with socket.gaierror on workstations and any other node where the result of socket.gethostname() isn't valid in local DNS. This may or may not merit a fatal exception in regular usage (guessing not) but it definitely tanks the test for me :)

However in these situations socket.getfqdn() usually still functions, and that's what is used for AddressFamily 'any' or for unknown values. So I think I'll update the codebase to capture socket.gaierror and fallback to the same spot.

bitprophet added a commit that referenced this issue Sep 27, 2013
@logic logic deleted the patch-1 branch Oct 1, 2013
@lndbrg lndbrg mentioned this pull request Aug 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants