util: add access check for hooks to fix running as non-root
util: add access check for hooks to fix running as non-root

Since feb83c1e710b9ea8044a89346f4868d03b31b0f1 libvirtd will abort on
startup if run as non-root

  2020-07-01 16:30:30.738+0000: 1647444: error : virDirOpenInternal:2869 : cannot open directory '/etc/libvirt/hooks/daemon.d': Permission denied

The root cause flaw is that non-root libvirtd is using /etc/libvirt for
its hooks. Traditionally that has been harmless though since we checked
whether we could access the hook file and degraded gracefully. We need
the same access check for iterating over the hook directory.

Long term we should make it possible to have an unprivileged hook dir
under $HOME.

Reviewed-by: Daniel Henrique Barboza <627b089ad62deae9aaf06ccfa2c9056df28927e0@gmail.com>
Signed-off-by: Daniel P. Berrangé <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>

libvirt/libvirt,jardasgit/libvirt,nertpinx/libvirt,olafhering/libvirt,crobinso/libvirt,libvirt/libvirt,zippy2/libvirt,zippy2/libvirt,nertpinx/libvirt,nertpinx/libvirt,olafhering/libvirt,crobinso/libvirt,zippy2/libvirt,jfehlig/libvirt,jfehlig/libvirt,olafhering/libvirt,jardasgit/libvirt,nertpinx/libvirt,olafhering/libvirt,libvirt/libvirt,jfehlig/libvirt,jfehlig/libvirt,jardasgit/libvirt,zippy2/libvirt,crobinso/libvirt,nertpinx/libvirt,jardasgit/libvirt,crobinso/libvirt,jardasgit/libvirt,libvirt/libvirt