This file is indexed.

/usr/share/pyshared/xdiagnose/welcome.py is in xdiagnose 2.5.2ubuntu0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/env python

import os
import gtk
import shutil

import gettext
from gettext import gettext as _
gettext.textdomain('xdiagnose')

from application import Application
from utils.debug import dbg
from utils.execute import execute


class XDiagnoseApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.xorg_conf_path = "/etc/X11/xorg.conf"
        self.xorg_conf_d_path = "/etc/X11/xorg.conf.d"
        self.xorg_conf_backup_path = "%s-backup" %(self.xorg_conf_path)
        self.xorg_conf_d_backup_path = "%s-backup" %(self.xorg_conf_d_path)

        self.pages['welcome'] = self.create_welcome_page()
        self.pages['actions'] = self.create_actions_page()
        self.pages['reconfigure'] = self.create_reconfigure_page()
        self.pages['troubleshoot'] = self.create_troubleshoot_page()

        # Refresh
        self.update_frame()
        self.window.show_all()
        self.on_page(None, 'welcome')

    def create_welcome_page(self):
        page = self.create_page(
            '<big>The system is running in low-graphics mode</big>\n\n' +
            'Your graphics and input devices could not be detected correctly.  You will need to configure these yourself.')
        nav_bar = self.create_nav_bar(next_page="actions")
        page.pack_end(nav_bar, expand=False)
        return page

    def create_actions_page(self):
        page = self.create_page("What would you like to try?")

        hbox = gtk.HBox()

        button1 = self.create_button("Run in low-graphics mode",
                                      "Use low-graphics for just one session")
        button1.connect("clicked", self.on_low_res_mode)
        button2 = self.create_button("Reconfigure",
                                      "Try to automatically fix the problem")
        button2.connect("clicked", self.on_page, "reconfigure")
        button3 = self.create_button("Troubleshoot",
                                      "Review errors, configs, and logs")
        button3.connect("clicked", self.on_page, "troubleshoot")
        button4 = self.create_button("Console",
                                      "Exit to the console login")
        button4.connect("clicked", self.on_exit_to_console)

        table = gtk.Table(rows=4, columns=3, homogeneous=False)
        table.set_border_width(0)
        table.attach(gtk.Label(''), 0, 1, 0, 1, xoptions=gtk.EXPAND)
        table.attach(button1, 1, 2, 0, 1)
        table.attach(button2, 1, 2, 1, 2)
        table.attach(button3, 1, 2, 2, 3)
        table.attach(button4, 1, 2, 3, 4)
        table.attach(gtk.Label(''), 2, 3, 0, 1, xoptions=gtk.EXPAND)
        page.pack_start(table, expand=False)

        nav_bar = self.create_nav_bar(prev_page="welcome")
        page.pack_end(nav_bar, expand=False)
        return page

    def create_reconfigure_page(self):
        page = self.create_page("How would you like to reconfigure your display?")

        hbox = gtk.HBox()

        button1 = self.create_button("Reset to defaults",
                                      "Use default (generic) configuration")
        button1.connect("clicked", self.on_reset_to_default_xorg_conf)
        button2 = self.create_button("Generate xorg.conf",
                                      "Creates a new configuration for this hardware")
        button2.connect("clicked", self.on_generate_xorg_conf)
        button3 = self.create_button("Restore backup",
                                      "Use your backed-up configuration")
        button3.connect("clicked", self.on_restore_backup)

        table = gtk.Table(rows=3, columns=3, homogeneous=False)
        table.set_border_width(0)
        table.attach(gtk.Label(''), 0, 1, 0, 1, xoptions=gtk.EXPAND)
        table.attach(button1, 1, 2, 0, 1)
        table.attach(button2, 1, 2, 1, 2)
        table.attach(button3, 1, 2, 2, 3)
        table.attach(gtk.Label(''), 2, 3, 0, 1, xoptions=gtk.EXPAND)
        page.pack_start(table, expand=False)

        nav_bar = self.create_nav_bar(prev_page="actions")
        page.pack_end(nav_bar, expand=False)
        return page

    def create_troubleshoot_page(self):
        page = self.create_page("What information would you like to review?")

        hbox = gtk.HBox()

        button1 = self.create_button("X server log",
                                      "Review the failed session Xorg.0.log")
        button1.connect("clicked", self.on_view_file, "/var/log/Xorg.0.log")
        button2 = self.create_button("lightdm's X startup log",
                                      "Review the display manager log")
        button2.connect("clicked", self.on_view_file, "/var/log/lightdm/x-0.log")
        button3 = self.create_button("Edit X Config",
                                      "Edit xorg.conf configuration file")
        button3.connect("clicked", self.on_edit_file, "/etc/X11/xorg.conf")

        table = gtk.Table(rows=4, columns=3, homogeneous=False)
        table.set_border_width(0)
        table.attach(gtk.Label(''), 0, 1, 0, 1, xoptions=gtk.EXPAND)
        table.attach(button1, 1, 2, 0, 1)
        table.attach(button2, 1, 2, 1, 2)
        table.attach(button3, 1, 2, 2, 3)
        table.attach(button4, 1, 2, 3, 4)
        table.attach(gtk.Label(''), 2, 3, 0, 1, xoptions=gtk.EXPAND)
        page.pack_start(table, expand=False)

        nav_bar = self.create_nav_bar(prev_page="actions")
        page.pack_end(nav_bar, expand=False)
        return page

    def has_backup(self):
        if (os.path.exists(self.xorg_conf_backup_path) or
            os.path.exists(self.xorg_conf_d_backup_path)):
            return True
        return False

    def backup_xorg_conf(self):
        '''Backs up xorg.conf and xorg.conf.d, overwriting any pre-existing backups'''
        if os.path.exists(self.xorg_conf_path):
            if os.path.exists(self.xorg_conf_backup_path):
                shutil.rm(self.xorg_conf_backup_path)
            shutil.copy(self.xorg_conf_path, self.xorg_conf_backup_path)
        if os.path.exists(self.xorg_conf_d_path):
            if os.path.exists(self.xorg_conf_d_backup_path):
                shutil.rmtree(self.xorg_conf_d_backup_path)
            shutil.copytree(self.xorg_conf_d_path, self.xorg_conf_d_backup_path)

    def update_frame(self):
        self.window.ensure_style()
        style = self.window.get_style()
        color = style.bg[gtk.STATE_SELECTED]
        self.frame.modify_bg(gtk.STATE_NORMAL, color)

        self.page_title.modify_fg(gtk.STATE_NORMAL, color)

    def on_page(self, widget, page_name):
        new_page = self.pages[page_name]
        if self.current_page is not None:
            self.frame.remove(self.current_page)
        if page_name == "welcome":
            self.page_title.set_markup("<big>Failsafe-X</big>")
        else:
            self.page_title.set_markup("<big>Failsafe-X: %s</big>" %(page_name.capitalize()))
        self.frame.add(new_page)
        self.current_page = new_page
        self.frame.show_all()

    def on_low_res_mode(self, widget):
        pass

    def on_exit_to_console(self, widget):
        pass

    def on_reset_to_default_xorg_conf(self, widget):
        if not self.backup_xorg_conf():
            dbg("Error: Could not backup the config")
            return
        shutils.rm(self.xorg_conf)
        shutils.rmtree(self.xorg_conf_d)

    def on_generate_xorg_conf(self, widget):
        if not self.backup_xorg_conf():
            dbg("Error: Could not backup the config")
            return
        pass

    def on_restore_backup(self, widget):
        pass

    def on_view_file(self, widget, filename):
        execute("zenity --text-info --filename=%s --width=640 --height=480" %(filename))

    def on_edit_file(self, widget, filename):
        if not os.path.exists(self.xorg_conf_path):
            # TODO: Stub in an xorg.conf
            pass
        execute("zenity --text-info --editable --filename=%s --width=640 --height=480" %(self.xorg_conf_path))


if __name__ == "__main__":
    import sys

    dbg("main:  Starting program")
    app = XDiagnoseApplication()
    gtk.main()

    dbg("main:  Ending program")
    sys.exit(0)