title: pthread_setname_np() when capabilities are set
body: <p>I compiled the example program from man <a href="http://man7.org/linux/man-pages/man3/pthread_setname_np.3.html" rel="nofollow noreferrer">pthread_setname_np</a> with </p>
  
  <pre><code>g++ -pthread  example.cpp
  </code></pre>
  
  <p>And I set the cap_net_raw capability of my program a.out. </p>
  
  <pre><code>sudo setcap 'cap_net_raw=+eip' a.out
  </code></pre>
  
  <p>Surprisingly the program fails when executing:</p>
  
  <pre><code>$./a.out
  Created a thread. Default name is: a.out
  pthread_setname_np: Permission denied
  </code></pre>
  
  <p>when I remove the capabilities it works..</p>
  
  <pre><code>$sudo setcap 'cap_net_raw=-eip' a.out
  $./a.out
  Created a thread. Default name is: a.out
  The thread name after setting it is THREADFOO.
  Done
  </code></pre>
  
  <p>So for me it looks like I have less privileges when I add a capability. Can anybody explain this?</p>
  
  <p>Thanky you for your response ;-)</p>
  
  <p>Some additional info:</p>
  
  <ul>
  <li>Capabilities are supported on my target I checked it with the ping command and CAP_NET_RAW</li>
  <li>Kernel 4.4.32-rt43</li>
  <li>RFS: ext4</li>
  <li>I reduced the post to the example program I agree it makes no sense to add the CAP_NET_RAW to this program.</li>
  <li>It would work if I add the CAP_DAC_OVERRIDE but I want to avoid that.</li>
  </ul>