Hi everyone, I am trying to do a simple pcap from a web page and am not having success.
Using visudo, I have added the following 2 lines at the end
www-data ALL=(testuser) NOPASSWD: /usr/sbin/*tcpdump* testuser ALL= NOPASSWD: /usr/sbin/tcpdump*
My php page contains
echo "Current user is: " . get_current_user()."<br>"; echo exec('sudo -u testuser timeout 5 tcpdump -w /var/www/html/temp/testing.pcap');
When I run this from the web page, the Current user comes back as www-data but it does not capture. It complains about not having permissions
When I run the same php page from command line, the capture is good and I do not have to enter any root password.
This is on an ubuntu server 18 system using php 7.x