Wireshark-users: Re: [Wireshark-users] (wireshark:26800): Gtk-WARNING **: cannot open display:
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 12 Dec 2007 10:49:57 -0800
Greg Toombs wrote:

sudo echo $display:
:0.0

"$display" (I assume this is some shell that sets the variable "display" to the same value as the all-caps DISPLAY environment variable; there is no environment variable named all-lower-case "display" that X libraries look at) is expanded by the shell and then passed as the second argument to "sudo", so that doesn't indicate whether sudo passes it on or not.

 Your sudo may also have an option to preserve environment variables such as DISPLAY when running. I don't have a Linux machine handy at the moment to try it out, but on MacOS X sudo does preserve environment variables and has an option not to.
I think it would be more proper to set the default environmental
variables for the root user, instead of temporarily transferring those
from the non-root to root user during sudo.

It would not be proper to prevent the user from configuring sudo to at least pass on particular environment variables, because when you do "sudo XXX", you're running command XXX from your session, and you'd want at least some environment variables passed on from that session. DISPLAY is one obvious example, but other examples might exist (one does for a build script used where I work).