This file is indexed.

/usr/bin/willowng-config is in willowng-config-gnome 0.4-0ubuntu2.

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

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
#!/usr/bin/python
# -*- coding: utf-8 -*-
#   WillowNG - Content Filtering Web Proxy
#   Copyright (C) 2006  Travis Watkins
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Library General Public
#   License as published by the Free Software Foundation; either
#   version 2 of the License, or (at your option) any later version.
#
#   This library is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   Library General Public License for more details.
#
#   You should have received a copy of the GNU Library General Public
#   License along with this library; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import gtk, gtk.glade, gobject
import dbus
import urllib2
import commands
import gettext
import os
from WillowNG import util
gettext.bindtextdomain('alacarte')
gettext.textdomain('alacarte')
gtk.glade.bindtextdomain('alacarte')
gtk.glade.textdomain('alacarte')
_ = gettext.gettext

class MainWindow:
    def __init__(self):
        try:
            from WillowNG import config
            datadir = config.pkgdatadir
            self.confdir = config.confdir
        except:
            datadir = '.'
            self.confdir = '.'
        self.config = util.readConfig(self.confdir, datadir)
        self.tree = gtk.glade.XML(os.path.join(datadir, 'willowng.glade'))
        self.tree.get_widget('content_filter_button').set_filename(os.path.abspath(self.config['content_blocked_page']))
        self.tree.get_widget('domain_filter_button').set_filename(os.path.abspath(self.config['domain_blocked_page']))
        mainwin = self.tree.get_widget('mainwindow')
        if os.path.exists('/usr/share/pixmaps/willowng.png'):
            mainwin.set_icon_from_file('/usr/share/pixmaps/willowng.png')
        signals = {}
        for attr in dir(self):
            signals[attr] = getattr(self, attr)
        self.tree.signal_autoconnect(signals)
        try:
            bus = dbus.SystemBus()
            remote_object = bus.get_object('com.ubuntu.WillowNG', '/com/ubuntu/WillowNG')
            self.iface = dbus.Interface(remote_object, 'com.ubuntu.WillowNG')
            self._setupDomainLists()
        except:
            mainwin.set_sensitive(False)
            dialog = gtk.MessageDialog(parent=mainwin, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_YES_NO)
            dialog.set_title('')
            dialog.set_markup(_('Content filter not running! Start content filter?'))
            response = dialog.run()
            if response == gtk.RESPONSE_YES:
                commands.getoutput('/etc/dbus-1/event.d/99willowng start')
                os.execvp('willowng-config', ())
            else:
                mainwin.destroy()

    def _setupDomainLists(self):
        good_list = self.tree.get_widget('good_domain_list')
        self.good_store = gtk.TreeStore(str)
        column = gtk.TreeViewColumn(_('Domain'))
        cell = gtk.CellRendererText()
        column.pack_start(cell)
        column.set_attributes(cell, text=0)
        good_list.append_column(column)
        good_list.set_model(self.good_store)

        bad_list = self.tree.get_widget('bad_domain_list')
        self.bad_store = gtk.TreeStore(str)
        column = gtk.TreeViewColumn(_('Domain'))
        cell = gtk.CellRendererText()
        column.pack_start(cell)
        column.set_attributes(cell, text=0)
        bad_list.append_column(column)
        bad_list.set_model(self.bad_store)
        self._loadDomainLists()

    def _loadDomainLists(self):
        self.good_store.clear()
        self.bad_store.clear()
        domains = self.iface.getDomains()
        if domains == None:
            return
        for domain in domains:
            if domain[1] == 'bad':
                self.bad_store.append(None, (domain[0],))
            elif domain[1] == 'good':
                self.good_store.append(None, (domain[0],))

    def addDomain(self, pool):
        mainwindow = self.tree.get_widget('mainwindow')
        if pool == 'bad':
            title = _('Add Bad Domain')
        else:
            title = _('Add Good Domain')
        dialog = gtk.Dialog(title, mainwindow, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_ADD, gtk.RESPONSE_ACCEPT))
        hbox = gtk.HBox()
        hbox.set_spacing(6)
        hbox.set_border_width(4)
        label = gtk.Label(_('Domain: '))
        entry = gtk.Entry()
        hbox.add(label)
        hbox.add(entry)
        dialog.vbox.add(hbox)
        hbox.show()
        entry.show()
        label.show()
        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            domain = entry.get_text()
            if pool == 'bad':
                self.iface.domainBad(domain)
            else:
                self.iface.domainGood(domain)
        dialog.destroy()

    def on_content_filter_button_selection_changed(self, button):
        filename = button.get_filename()
        if filename != None and filename != self.config['content_blocked_page']:
            self.config['content_blocked_page'] = filename
            util.writeConfig(self.confdir, self.config)

    def on_domain_filter_button_selection_changed(self, button):
        filename = button.get_filename()
        if filename != None and filename != self.config['domain_blocked_page']:
            self.config['domain_blocked_page'] = filename
            util.writeConfig(self.confdir, self.config)

    def on_add_good_button_clicked(self, button):
        self.addDomain('good')
        self._loadDomainLists()

    def on_remove_good_button_clicked(self, button):
        good_list = self.tree.get_widget('good_domain_list')
        domains, iter = good_list.get_selection().get_selected()
        self.iface.removeDomain(domains[iter][0])
        self.tree.get_widget('remove_good_button').set_sensitive(False)
        self._loadDomainLists()

    def on_good_domain_list_cursor_changed(self, good_list):
        self.tree.get_widget('remove_good_button').set_sensitive(True)

    def on_add_bad_button_clicked(self, button):
        self.addDomain('bad')
        self._loadDomainLists()

    def on_remove_bad_button_clicked(self, button):
        bad_list = self.tree.get_widget('bad_domain_list')
        domains, iter = bad_list.get_selection().get_selected()
        self.iface.removeDomain(domains[iter][0])
        self.tree.get_widget('remove_bad_button').set_sensitive(False)
        self._loadDomainLists()

    def on_bad_domain_list_cursor_changed(self, good_list):
        self.tree.get_widget('remove_bad_button').set_sensitive(True)

    def on_good_url_button_clicked(self, button):
        url = self.tree.get_widget('good_url_entry').get_text()
        self.iface.trainGood(url)

    def on_bad_url_button_clicked(self, button):
        url = self.tree.get_widget('bad_url_entry').get_text()
        self.iface.trainBad(url)

    def on_mainwindow_destroy(self, widget):
        gtk.main_quit()

    def on_close_button_clicked(self, button):
        self.on_mainwindow_destroy(button)

if os.getuid() != 0:
    dialog = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE)
    dialog.set_title('')
    dialog.set_markup(_('This program must be run as superuser.'))
    response = dialog.run()
    gobject.timeout_add(0, gtk.main_quit)

foo = MainWindow()
gtk.main()