Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:
edgeos

Nmap Development: Re: zenmap as root error

Re: zenmap as root error

From: Guilherme Polo <ggpolo_at_gmail.com>
Date: Tue, 1 Apr 2008 22:52:02 -0300

2008/4/1, Joćo Medeiros <ignotus21_at_gmail.com>:
> You can just check if the DISPLAY environment variable is set. Like this:
>
> ----------------------------------------8<----------------------------------------
> import os
> import sys
>
> if 'DISPLAY' not in os.environ.keys():

just if 'DISPLAY' not in os.environ is fine

>
> print "Unable to start graphical application. Please, set DISPLAY \
> environment variable."
> sys.exit(0)
>
> import gtk
> ----------------------------------------8<----------------------------------------
>
> Put this before "import gtk" in zenmap main file to avoid some warnings too.
>
> Att, Joćo Medeiros.
>

But, for PyGtk 2.8 and earlier I would suggest doing this in a
different manner (and much simpler and less error-prone):

try:
    import gtk
except ImportError, e:
    print e

For PyGtk 2.10 and newer, ImportError is actually a warning so the
code changes a bit:

import warnings
warnings.filterwarnings('error', module='gtk')
try:
    import gtk
except Warning, w:
    print w
warnings.resetwarnings()

>
> On Tue, Apr 1, 2008 at 4:21 PM, Fyodor <fyodor_at_insecure.org> wrote:
> > On Sun, Mar 23, 2008 at 11:47:56PM -0300, eldraco wrote:
> > > Hi Aaron,
> > >
> > > Hope this helps you. Perhaps you already think about this, but...
> > > Try to set the DISPLAY variable before.
> > >
> > > If I don't set it before, I have the same output:
> > >
> > > #zenmap
> > > Segmentation fault
> > >
> > > But after I set It, it works like a charm:
> >
> > Hm, thanks for the report. Zenmap should give a proper error in that
> > case, not segfault. When I unset my display, I get a much more useful
> > exception:
> >
> > RuntimeError: could not open display
> >
> > If anyone else gets the segmentation fault result described above and
> > can find a fix, I'd be happy to integrate it.
> >
> > Cheers,
> > -F
> >
> > _______________________________________________
> > Sent through the nmap-dev mailing list
> > http://cgi.insecure.org/mailman/listinfo/nmap-dev
> > Archived at http://SecLists.Org
> >
>
> _______________________________________________
> Sent through the nmap-dev mailing list
> http://cgi.insecure.org/mailman/listinfo/nmap-dev
> Archived at http://SecLists.Org
>

-- 
-- Guilherme H. Polo Goncalves
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Received on Apr 01 2008
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]