Repository: certbot/certbot

Issue:
ValueError: ambiguos inode with multiple PIDs references
I got some trouble with the standalone authentication plugin.

Apparantly, the authenticator tries to check whether certain ports which it needs to listen on are already taken or if it can open them. On my machine, this check causes the client to crash, no matter whether my web server is running or not.

```
  2015-10-22 06:34:12,046:DEBUG:letsencrypt.cli:Exiting abnormally:
  Traceback (most recent call last):
File "/usr/bin/letsencrypt", line 9, in <module>
  load_entry_point('letsencrypt==0.1', 'console_scripts', 'letsencrypt')()
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 926, in main
  return args.func(args, config, plugins)
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 335, in auth
  domains, authenticator, installer, plugins):
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 240, in obtain_and_enroll_certificate
  certr, chain, key, _ = self.obtain_certificate(domains)
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 216, in obtain_certificate
  return self._obtain_certificate(domains, csr) + (key, csr)
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 174, in _obtain_certificate
  authzr = self.auth_handler.get_authorizations(domains)
File "/usr/lib/python2.7/dist-packages/letsencrypt/auth_handler.py", line 80, in get_authorizations
  cont_resp, dv_resp = self._solve_challenges()
File "/usr/lib/python2.7/dist-packages/letsencrypt/auth_handler.py", line 115, in _solve_challenges
  dv_resp = self.dv_auth.perform(self.dv_c)
File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/standalone/authenticator.py", line 386, in perform
  if self.already_listening(self.config.dvsni_port):
File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/standalone/authenticator.py", line 304, in already_listening
  listeners = [conn.pid for conn in psutil.net_connections()
File "/usr/lib/python2.7/dist-packages/psutil/__init__.py", line 1790, in net_connections
  return _psplatform.net_connections(kind)
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 572, in net_connections
  return _connections.retrieve(kind)
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 556, in retrieve
  for fd, family, type_, laddr, raddr, status, bound_pid in ls:
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 490, in process_inet
  raise ValueError("ambiguos inode with multiple "
  ValueError: ambiguos inode with multiple PIDs references
```

I think that this issue might be related to my slightly unusual N/W configuration which involves several interfaces and some strange routing arrangements; However, I still don't get what is happening here.

ValueError: ambiguos inode with multiple PIDs references
I got some trouble with the standalone authentication plugin.

Apparantly, the authenticator tries to check whether certain ports which it needs to listen on are already taken or if it can open them. On my machine, this check causes the client to crash, no matter whether my web server is running or not.

```
  2015-10-22 06:34:12,046:DEBUG:letsencrypt.cli:Exiting abnormally:
  Traceback (most recent call last):
File "/usr/bin/letsencrypt", line 9, in <module>
  load_entry_point('letsencrypt==0.1', 'console_scripts', 'letsencrypt')()
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 926, in main
  return args.func(args, config, plugins)
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 335, in auth
  domains, authenticator, installer, plugins):
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 240, in obtain_and_enroll_certificate
  certr, chain, key, _ = self.obtain_certificate(domains)
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 216, in obtain_certificate
  return self._obtain_certificate(domains, csr) + (key, csr)
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 174, in _obtain_certificate
  authzr = self.auth_handler.get_authorizations(domains)
File "/usr/lib/python2.7/dist-packages/letsencrypt/auth_handler.py", line 80, in get_authorizations
  cont_resp, dv_resp = self._solve_challenges()
File "/usr/lib/python2.7/dist-packages/letsencrypt/auth_handler.py", line 115, in _solve_challenges
  dv_resp = self.dv_auth.perform(self.dv_c)
File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/standalone/authenticator.py", line 386, in perform
  if self.already_listening(self.config.dvsni_port):
File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/standalone/authenticator.py", line 304, in already_listening
  listeners = [conn.pid for conn in psutil.net_connections()
File "/usr/lib/python2.7/dist-packages/psutil/__init__.py", line 1790, in net_connections
  return _psplatform.net_connections(kind)
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 572, in net_connections
  return _connections.retrieve(kind)
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 556, in retrieve
  for fd, family, type_, laddr, raddr, status, bound_pid in ls:
File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 490, in process_inet
  raise ValueError("ambiguos inode with multiple "
  ValueError: ambiguos inode with multiple PIDs references
```

I think that this issue might be related to my slightly unusual N/W configuration which involves several interfaces and some strange routing arrangements; However, I still don't get what is happening here.



Discussion:
First of all, please use `./letsencrypt-auto`. I can see that you installed git `master` using `python setup.py install` (or something similar), a mode which is explicitly forbidden by our docs: http://letsencrypt.readthedocs.org/en/latest/using.html#installation-and-usage. Moreover, you seem to be using old `master`.

Please rerun with `./letsencrypt-auto` and report back if you're still having the same issue. Thanks!

I'm using the latest version from the letsencrypt-debian repository and I understand that it is outdated (which is probably the reason why letsencrypt-auto is missing on my machine).

Actually, I didn't run python setup.py install (at least not directly). I just built the package as usual (debuild) and then I installed it.

(bbl when I'm done rebuilding from the other (this) repository)

I was unable to reproduce this issue with the lastest version from the letsencrypt repository.

Closing this issue as outdated.

Please, reopen this issue.
I'm experiencing same issue on Gentoo, and package is installed from latest HEAD on that hour.

```
2015-12-0418:32:17,785:DEBUG:letsencrypt.error_handler:Encountered exception:
Traceback (most recent call last):
File"/usr/lib/python2.7/site-packages/letsencrypt/auth_handler.py",line 115
, in _solve_challenges
dv_resp = self.dv_auth.perform(self.dv_c)
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/standalone.py",li
ne 206, in perform
if any(util.already_listening(port) for port inself._necessary_ports):
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/standalone.py",li
ne 206, in <genexpr>
if any(util.already_listening(port) for port inself._necessary_ports):
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/util.py",line 28,
in already_listening
net_connections = psutil.net_connections()
File "/usr/lib/python2.7/site-packages/psutil/__init__.py",line 1793, in net
_connections
return _psplatform.net_connections(kind)
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 569, in net_connections
return _connections.retrieve(kind)
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 553, in retrieve
for fd, family, type_, laddr, raddr, status, bound_pid in ls:
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 490, in process_inet
raise ValueError("ambiguos inode with multiple "
ValueError: ambiguos inode with multiple PIDs references
```

Can't it be related to extended "max pid" on the system?

i can confirm the problem on Gentoo

@tillschaefer can you try to upgrade dev-python/psutils to "unstable" version and check if it will fix issue?

upgrading to dev-python/psutil-3.3.0 (from version 2.1.3) fixes the error here. Is this a Gentoo packaging problem, then?

downstream bug report (Gentoo): https://bugs.gentoo.org/show_bug.cgi?id=569012

I'm seeing the same error on debian/jessie.   Commenting out the assertion results fixes the issue.

debian/jessie still the same error

Debian/Jessie I have this error as well

@sbc100 @genyx @Ounnix as I (and @tillschaefer) mentioned above, upgrade to psutil-3 (and, probably, 4 too) fixes the problem. So, it looks like that bug is in that fact, that README should state that version requirements.

// and debian packager (you can check who is that in package info) should somehow resolve that issue: either by patching, shipping bundled psutil or upgrading psutil package as well.

+1. that solves! thank you

same issue in debian/jessie backport

Same problem debian jessie (python-psutil package problem)...

Line where it goes wrong.

```
 net_connections = psutil.net_connections()
```

**EDIT:** I will create a bug report in debian.

@ all the debian ppl: Please report the bug in the debian bugtracker then. It is a packaging issue which cannot be resolved upstream (here).

Bug created:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825830

If it's simple to do so, I'd rather we kept compatibility with old versions of python-psutil; 3.4.2 is not in jessie and would need backporting.  I can do so if necessary, but....

But what? 

Debian will not upgrade packages to new versions in stable releases. They Backport security/bug fixes. The policy against version changes is due to api/version stability, which is essential for running servers.

First of all, please use `./letsencrypt-auto`. I can see that you installed git `master` using `python setup.py install` (or something similar), a mode which is explicitly forbidden by our docs: http://letsencrypt.readthedocs.org/en/latest/using.html#installation-and-usage. Moreover, you seem to be using old `master`.

Please rerun with `./letsencrypt-auto` and report back if you're still having the same issue. Thanks!

I'm using the latest version from the letsencrypt-debian repository and I understand that it is outdated (which is probably the reason why letsencrypt-auto is missing on my machine).

Actually, I didn't run python setup.py install (at least not directly). I just built the package as usual (debuild) and then I installed it.

(bbl when I'm done rebuilding from the other (this) repository)

I was unable to reproduce this issue with the lastest version from the letsencrypt repository.

Closing this issue as outdated.

Please, reopen this issue.
I'm experiencing same issue on Gentoo, and package is installed from latest HEAD on that hour.

```
2015-12-0418:32:17,785:DEBUG:letsencrypt.error_handler:Encountered exception:
Traceback (most recent call last):
File"/usr/lib/python2.7/site-packages/letsencrypt/auth_handler.py",line 115
, in _solve_challenges
dv_resp = self.dv_auth.perform(self.dv_c)
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/standalone.py",li
ne 206, in perform
if any(util.already_listening(port) for port inself._necessary_ports):
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/standalone.py",li
ne 206, in <genexpr>
if any(util.already_listening(port) for port inself._necessary_ports):
File"/usr/lib/python2.7/site-packages/letsencrypt/plugins/util.py",line 28,
in already_listening
net_connections = psutil.net_connections()
File "/usr/lib/python2.7/site-packages/psutil/__init__.py",line 1793, in net
_connections
return _psplatform.net_connections(kind)
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 569, in net_connections
return _connections.retrieve(kind)
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 553, in retrieve
for fd, family, type_, laddr, raddr, status, bound_pid in ls:
File "/usr/lib/python2.7/site-packages/psutil/_pslinux.py",line 490, in process_inet
raise ValueError("ambiguos inode with multiple "
ValueError: ambiguos inode with multiple PIDs references
```

Can't it be related to extended "max pid" on the system?

i can confirm the problem on Gentoo

@tillschaefer can you try to upgrade dev-python/psutils to "unstable" version and check if it will fix issue?

upgrading to dev-python/psutil-3.3.0 (from version 2.1.3) fixes the error here. Is this a Gentoo packaging problem, then?

downstream bug report (Gentoo): https://bugs.gentoo.org/show_bug.cgi?id=569012

I'm seeing the same error on debian/jessie.   Commenting out the assertion results fixes the issue.

debian/jessie still the same error

Debian/Jessie I have this error as well

@sbc100 @genyx @Ounnix as I (and @tillschaefer) mentioned above, upgrade to psutil-3 (and, probably, 4 too) fixes the problem. So, it looks like that bug is in that fact, that README should state that version requirements.

// and debian packager (you can check who is that in package info) should somehow resolve that issue: either by patching, shipping bundled psutil or upgrading psutil package as well.

+1. that solves! thank you

same issue in debian/jessie backport

Same problem debian jessie (python-psutil package problem)...

Line where it goes wrong.

```
 net_connections = psutil.net_connections()
```

**EDIT:** I will create a bug report in debian.

@ all the debian ppl: Please report the bug in the debian bugtracker then. It is a packaging issue which cannot be resolved upstream (here).

Bug created:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825830

If it's simple to do so, I'd rather we kept compatibility with old versions of python-psutil; 3.4.2 is not in jessie and would need backporting.  I can do so if necessary, but....

But what? 

Debian will not upgrade packages to new versions in stable releases. They Backport security/bug fixes. The policy against version changes is due to api/version stability, which is essential for running servers.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -40,7 +40,7 @@ def read_file(filename, encoding='utf8'):
     'configobj',
     'cryptography>=0.7',  # load_pem_x509_certificate
     'parsedatetime>=1.3',  # Calendar.parseDT
-    'psutil>=2.1.0',  # net_connections introduced in 2.1.0
+    'psutil>=2.2.1',  # 2.1.0 for net_connections and 2.2.1 resolves #1080
     'PyOpenSSL',
     'pyrfc3339',
     'python2-pythondialog>=3.2.2rc1',  # Debian squeeze support, cf. #280


Test patch: