#!/usr/bin/perl -w # # setuid-root - Enable/disable setuid for tshark and dumpcap. # # $Id$ # # Copyright 2007, Luis Ontanon and Gerald Combs # # Wireshark - Network traffic analyzer # By Gerald Combs # Copyright 1998 Gerald Combs # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. sub usage() { die <= 0) { $revert_owner = shift; } if (length($revert_owner) < 1 && length($ENV{SUDO_USER}) > 0) { $revert_owner = $ENV{SUDO_USER}; } if ($command eq "enable") { system("chown root $bin_prefix/$tshark_bin"); system("chown root $bin_prefix/$dumpcap_bin"); system("chmod ug+s $bin_prefix/$tshark_bin"); system("chmod ug+s $bin_prefix/$dumpcap_bin"); exit 0; } if ($command eq "disable"){ system("chmod ug-s $bin_prefix/$tshark_bin"); system("chmod ug-s $bin_prefix/$dumpcap_bin"); die "Can't revert owner" if length($revert_owner) < 1; system("chown $revert_owner $bin_prefix/$tshark_bin"); system("chown $revert_owner $bin_prefix/$dumpcap_bin"); exit(0); } usage();