check that the entry is a directory before using it as such

Assuming everything under /var/lib/lxc/ is a directory and
then accessing it as such will fail at least on Debian wheezy,
since it contains /var/lib/lxc/template.config which is a file.