1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
lib/portage/process.py | 9 ++++++++- |
4 |
1 file changed, 8 insertions(+), 1 deletion(-) |
5 |
|
6 |
diff --git a/lib/portage/process.py b/lib/portage/process.py |
7 |
index 79052b608..ceb454030 100644 |
8 |
--- a/lib/portage/process.py |
9 |
+++ b/lib/portage/process.py |
10 |
@@ -715,7 +715,14 @@ def _exec(binary, mycommand, opt_name, fd_pipes, |
11 |
if unshare_net: |
12 |
# use 'localhost' to avoid hostname resolution problems |
13 |
try: |
14 |
- socket.sethostname('localhost') |
15 |
+ # pypy3 does not implement socket.sethostname() |
16 |
+ new_hostname = b'localhost' |
17 |
+ if hasattr(socket, 'sethostname'): |
18 |
+ socket.sethostname(new_hostname) |
19 |
+ else: |
20 |
+ if libc.sethostname(new_hostname, len(new_hostname)) != 0: |
21 |
+ errno_value = ctypes.get_errno() |
22 |
+ raise OSError(errno_value, os.strerror(errno_value)) |
23 |
except Exception as e: |
24 |
writemsg("Unable to set hostname: %s (for FEATURES=\"network-sandbox\")\n" % ( |
25 |
e,), |
26 |
-- |
27 |
2.26.2 |