-
-
Notifications
You must be signed in to change notification settings - Fork 127
fix(qubes-setup-dnat-to-ns): handle null dns dbus response #593
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #593 +/- ##
=======================================
Coverage 71.10% 71.10%
=======================================
Files 3 3
Lines 481 481
=======================================
Hits 342 342
Misses 139 139 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
According to the documentation DNS is an array, not "array or nothing". Even if I unset all addresses, I still get an array. What is the case when the service does respond with something else? Note the service not responding at all is already handled via an exception. |
While as you note the dbus interface itself always returns an arrary, |
|
The ambiguity makes me think maybe the Updated accordingly. |
607b3d7 to
78c36d2
Compare
55f78e5 to
633271c
Compare
network/qubes-setup-dnat-to-ns
Outdated
| return nameservers | ||
|
|
||
| def get_dns_resolved(): | ||
| dns = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line isn't needed - there is no code path that leave dns unset and gets to the place where it's used. And there would be - better get an exception that is easy to find, than silently break DNS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And there would be - better get an exception that is easy to find, than silently break DNS.
Hum, the fallback function get_resolv_conf does seem to use the strategy of "fail silently and return empty on error (which does seem sane as there is no global exception handler or hook to catch such errors right now?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may want fixing too, at some point (if not propagate exception, then at least log a message)... But that's independent of this PR.
python typings indicate that resolve1.Get may return None. Handle this possibility as failure, falling back to resolv.conf
633271c to
3dbe9c3
Compare
resolve1.Getdbus call is not guaranteed to return a list. This handles the case of aNoneresult as equal to[].An alternative would be to fall back to
get_dns_resolv_conf(as already done for handling known errors)