From: Coly Li Subject: fix ocfs2console crashing when DISPLAY is not correctly set References: bnc#448523 Author: Joel Becker When DISPLAY is not correctly set, this patch makes ocfs2console report error mesage and exit, other than a ugly crash. Signed-off-by: Joel Becker Signed-off-by: Coly Li --- diff --git a/ocfs2console/ocfs2console b/ocfs2console/ocfs2console index 77ab623..17dcfc5 100755 --- a/ocfs2console/ocfs2console +++ b/ocfs2console/ocfs2console @@ -3,14 +3,23 @@ from ocfs2interface.about import process_args nodeconf = process_args() +import warnings +warnings.filterwarnings("error") + try: import gtk -except RuntimeError: +except Exception, e: import sys - print >>sys.stderr, '''ERROR: ocfs2console needs an X11 display. + if str(e).lower().find('display') == -1: + print >>sys.stderr, '''ERROR: Unable to initialize the windowing +system: %s\n''' % e + else: + print >>sys.stderr, '''ERROR: ocfs2console needs an X11 display. Make sure a proper setup for your display environment exists.\n''' sys.exit(1) +warnings.resetwarnings() + if nodeconf: from ocfs2interface.nodeconfig import node_config node_config()