Running lxc-ls as non-root should provide a nicer error message

Bug #1267242 reported by Jorge Castro
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
Low
Stéphane Graber

Bug Description

You need root to run lxc-ls now, but this happens:

jorge@jilldactyl:~$ lxc-ls
lxc: Permission denied - opendir on lxcpath
Traceback (most recent call last):
  File "/usr/bin/lxc-ls", line 200, in <module>
    for container_name in lxc.list_containers(config_path=lxcpath):
  File "/usr/lib/python3/dist-packages/lxc/__init__.py", line 390, in list_containers
    config_path=config_path)
ValueError: failure to list containers

I asked Serge:

<hallyn> jcastro: you have to run lxc-ls as root now
 jcastro: however, it shouldn't give you a backtrace like that, just a nice error msg
<hallyn> so that's bug-worthy

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: lxc 1.0.0~beta1-0ubuntu3
ProcVersionSignature: Ubuntu 3.12.0-7.15-generic 3.12.4
Uname: Linux 3.12.0-7-generic x86_64
ApportVersion: 2.12.7-0ubuntu6
Architecture: amd64
CurrentDesktop: Unity
Date: Wed Jan 8 15:56:45 2014
EcryptfsInUse: Yes
InstallationDate: Installed on 2013-12-11 (28 days ago)
InstallationMedia: Ubuntu 13.10 "Saucy Salamander" - Release amd64 (20131016.1)
SourcePackage: lxc
UpgradeStatus: Upgraded to trusty on 2014-01-07 (1 days ago)
defaults.conf:
 lxc.network.type = veth
 lxc.network.link = lxcbr0
 lxc.network.flags = up
lxcsyslog:

Revision history for this message
Stéphane Graber (stgraber) wrote :

Most of the occurrences of that bug will disappear with the next LXC milestone as lxc-ls will default to looking for user-owned containers rather than system ones.

However even with that change, it'll be technically possible to call list_containers on an unreadable directory and get that traceback. Sadly as this comes from liblxc, there isn't many ways to make the error prettier as the actual string is simply output on stderr...
What I could (and will eventually) do is have lxc-ls catch any exception raised by list_container and print a vague error saying "Unable to list containers" which is unfortunately as clear as I can make it...

Changed in lxc (Ubuntu):
status: New → Triaged
importance: Undecided → Low
assignee: nobody → Stéphane Graber (stgraber)
Revision history for this message
Stéphane Graber (stgraber) wrote :

lxc-ls now shows user containers when run as non-root.

Changed in lxc (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.