1 |
Hi, |
2 |
|
3 |
First, sorry if this is not the correct list. |
4 |
|
5 |
Second, the background story... |
6 |
|
7 |
I was tracking a problem that I have always ignored when updating python |
8 |
on my Gentoo laptop. The problem is that emerge-ing python always fail |
9 |
when FEATURES="test" is on. Usually, I would just turn FEATURES="test" |
10 |
off when updating python, but today I set up to search for the source of |
11 |
the failure. |
12 |
|
13 |
After downloading the latest svn version from python and a few hours of |
14 |
debugging python's test suite; I isolated the problem to this: |
15 |
|
16 |
lieryan@lieryan ~/Desktop/pythontrunk/trunk $ ./python |
17 |
Python 2.7a0 (trunk:75376M, Oct 12 2009, 22:17:57) |
18 |
[GCC 4.3.2] on linux2 |
19 |
Type "help", "copyright", "credits" or "license" for more information. |
20 |
>>> import socket |
21 |
>>> socket.gethostname() |
22 |
'lieryan' |
23 |
>>> socket.gethostbyname(socket.gethostname()) |
24 |
Traceback (most recent call last): |
25 |
File "<stdin>", line 1, in <module> |
26 |
socket.gaierror: [Errno -2] Name or service not known |
27 |
>>> socket.gethostbyname('localhost') |
28 |
'127.0.0.1' |
29 |
|
30 |
From that, I see that socket.gethostname() returned 'lieryan' which is |
31 |
my user name; instead of 'localhost' which is the correct local |
32 |
machine's name. |
33 |
|
34 |
Tracking the interpreter's source code, it seems that |
35 |
socket.gethostname() simply returns what the libc's gethostname() |
36 |
returns; which "man gethostname" says "The GNU C Library ... implements |
37 |
gethostname() as a library function that calls uname(2)..." |
38 |
|
39 |
So running "uname -a": |
40 |
lieryan@lieryan ~/Desktop/pythontrunk/trunk $ uname -a |
41 |
Linux lieryan 2.6.28-gentoo-r5-LR-15 #14 SMP Tue Oct 6 18:12:23 EST 2009 |
42 |
x86_64 AMD Turion(tm) 64 X2 AuthenticAMD GNU/Linux |
43 |
|
44 |
So clearly this is an environmental issue. |
45 |
|
46 |
============================= |
47 |
|
48 |
|
49 |
It appears that gethostname() returns 'lieryan'; which is my user name |
50 |
instead of 'localhost' which, I believe, should be the correct hostname |
51 |
for the machine I'm currently in. |
52 |
|
53 |
Now I know where the source of the problem is; but I don't know how to |
54 |
fix it. |
55 |
|
56 |
Anyone got any idea what I should do to change the return value of |
57 |
gethostname()? |
58 |
|
59 |
Googling gethostname() only returned various versions of "gethostname()" |
60 |
man page. The man pages also mentioned about another libc's function |
61 |
sethostname() but this system call is not available in python and even |
62 |
if I write a C script to call sethostname() with the correct value; I |
63 |
doubt this will really fix the real root cause of the problem. |
64 |
|
65 |
Anyone got any lead? |
66 |
|
67 |
|
68 |
Extra information: |
69 |
|
70 |
lieryan@lieryan ~/Desktop/pythontrunk/trunk $ /lib/libc.so.6 |
71 |
GNU C Library stable release version 2.9, by Roland McGrath et al. |
72 |
Copyright (C) 2008 Free Software Foundation, Inc. |
73 |
This is free software; see the source for copying conditions. |
74 |
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A |
75 |
PARTICULAR PURPOSE. |
76 |
Compiled by GNU CC version 4.3.2. |
77 |
Compiled on a Linux >>2.6.28-gentoo-r5-LR-12<< system on 2009-07-05. |
78 |
Available extensions: |
79 |
C stubs add-on version 2.1.2 |
80 |
crypt add-on version 2.1 by Michael Glad and others |
81 |
Gentoo snapshot 20081201 |
82 |
Gentoo patchset 5 |
83 |
GNU Libidn by Simon Josefsson |
84 |
Native POSIX Threads Library by Ulrich Drepper et al |
85 |
Support for some architectures added on, not maintained in glibc core. |
86 |
BIND-8.2.3-T5B |
87 |
For bug reporting instructions, please see: |
88 |
<http://www.gnu.org/software/libc/bugs.html>. |