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

"/etc/resolv.conf" assumed default path is wrong for termux #724

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rawrrawrfox
Copy link

termux: the default path for resolv.conf file is not "/etc/resolv.conf", but the code presumes that to be the case

termux is a terminal app for android capable of running many linux utilites

the file resolv.conf is not found at the default location which therefore breaks other projects which use this one as a dependency

i ran accross this problem when trying to run the termux version of onionshare (https://github.com/oleanderxoxo/onidroid) which uses this library as a dependency somewhere downstream

i'm not sure what would be the most elegant solution to the resolv.conf location problem, but i've tested this code, and it works as a quickfix nonetheless

it checks if the $PREFIX environment variable is set and if it points to the termux app's "...data/files/usr" system path, then specifies explicitly the location of the resolv.conf file when creating the resolver object, which needs to be $PREFIX + "/etc/resolv.conf"

not all systems' resolv.conf file is at the same location "/etc/resolv.conf"

this is the case with the termux environment on android - the file is not found at the default location and therefore breaks other projects which use this one as a dependency

i ran accross this problem when trying to run the termux version of onionshare (https://github.com/oleanderxoxo/onidroid) which uses this library as a dependency somewhere downstream

i'm not sure what would be the most elegant solution to the resolv.conf location problem, but i've tested this code, and it works as a quickfix nonetheless
@temoto
Copy link
Member

temoto commented Sep 13, 2021

@rawrrawrfox thank you. Configurable location of resolv.conf is a great feature.

I think we should try to support one of:

  • EVENTLET_RESOLV_CONF=/path/to/resolv.conf or just RESOLV_CONF at first, becase second option plain $PREFIX/etc/resolv.conf may break unexpectedly in a lot of build environments.
  • $PREFIX/etc/resolv.conf seems most reasonable after specific path option for resolv.conf file.

Unless required, I'm strongly against hardcode integration with one particular platform+application (Android/termux). It should work for other applications that set PREFIX like termux but to another value. IMHO, it would be awkward to limit this useful feature to Android.

@eventlet/developers @jstasiak @tipabu @clayg @edwardgeorge @nat-goodspeed @vikt0rs please say

@clayg
Copy link
Contributor

clayg commented Sep 13, 2021

@rawrrawrfox I agree with @temoto strong preference for EVENTLET_RESOLV_CONF=/path/to/resolv.conf - I found no such facility in dns.resolver.Resolver

No need for anything platform specific:

diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py
index 76545c7..eadac2b 100644
--- a/eventlet/support/greendns.py
+++ b/eventlet/support/greendns.py
@@ -408,7 +408,8 @@ class ResolverProxy(object):
         return aliases
 
 
-resolver = ResolverProxy(hosts_resolver=HostsResolver())
+resolver = ResolverProxy(hosts_resolver=HostsResolver(), filename=os.environ.get(
+    'EVENTLET_RESOLV_CONF', '/etc/resolv.conf'))
 
 
 def resolve(name, family=socket.AF_INET, raises=True, _proxy=None,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants