title: How to read file capabilities using Python?
body: <p>On Linux systems root privileges can be granted more selectively than adding the setuid bit using file capabilities. See <a href="http://man7.org/linux/man-pages/man7/capabilities.7.html" rel="nofollow noreferrer"><code>capabilities(7)</code></a> for details. These are attributes of files and can be read using the <code>getcap</code> program. How can these attributes be retrieved in Python?</p>
  
  <p>Even though running the <code>getcap</code> program using e.g. <code>subprocess</code> for answering such a question is possible it is not desirable when retrieving very many capabilities.</p>
  
  <p>It should be possible to devise a solution using <code>ctypes</code>. Are there alternatives to this approach or even libraries facilitating this task?</p>