How to debug program creating RAW socket?

1

For example I have this program:

int main()
{
  int sockfd = ::socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

  if ( sockfd == -1 )
    printf("Error\n");
  else
    printf("Success\n");

  return 0;

}

So, I need to have super user's rights or to use setcap:

$ ./Test 
Error
sudo setcap cap_net_raw+eip ./Test
$ ./Test 
Success

But, I need to debug my program with QtCretor and the program doesn't work even after setcap. I have tried to apply setcap to QtCreator, but it doesn't solve my problem.

Are there any solutions?

Rikitikitavi

Posted 2018-07-10T08:58:12.217

Reputation: 113

No answers