1

I want to launch wireshark using the following command:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY wireshark 
No protocol specified

** (wireshark:9323): WARNING **: Could not open X display
No protocol specified
error: XDG_RUNTIME_DIR not set in the environment.

(wireshark:9323): Gtk-WARNING **: cannot open display: :0
A.B.
  • 90,397

1 Answers1

1

Create a new policy rule in /usr/share/polkit-1/actions/

sudo nano /usr/share/polkit-1/actions/wireshark.policy

and add the lines below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">

<policyconfig>

  <action id="org.freedesktop.policykit.pkexec.run-wireshark">
    <description>Run FlashTool</description>
    <message>Authentication is required to run Wireshark</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/wireshark</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
  </action>

</policyconfig>

Then create a new script wireshark-pkexec

sudo nano /usr/bin/wireshark-pkexec

and add the lines below:

#!/bin/sh
pkexec "wireshark" "$@"

and add the executable flag

sudo chmod +x /usr/bin/wireshark-pkexec   

And finally create a new desktop file

nano /usr/share/applications/wireshark-pkexec.desktop

and add the lines below:

[Desktop Entry]
Name=Wireshark as root
GenericName=Network Analyzer
Comment=Network traffic analyzer
Exec=wireshark-pkexec %f
Icon=wireshark
Terminal=false
Type=Application
Categories=GNOME;Network;
StartupNotify=true
MimeType=application/vnd.tcpdump.pcap;application/x-pcapng;application/x-snoop;application/x-iptrace;application/x-lanalyzer;application/x-nettl;application/x-radcom;application/x-etherpeek;application/x-visualnetworks;application/x-netinstobserver;application/x-5view;

Restart Unity/GNOME Shell and start Wireshark as root

A.B.
  • 90,397