This file is indexed.

/usr/share/cherokee/admin/PageError.py is in cherokee-admin 1.2.101-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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# -*- coding: utf-8 -*-
#
# Cherokee-admin
#
# Authors:
#      Alvaro Lopez Ortega <alvaro@alobbs.com>
#
# Copyright (C) 2010 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

import os
import CTK

from urllib import quote
from configured import *

ERROR_LAUNCH_URL_ADMIN = N_('The server suggests to check <a href="%s">this page</a>. Most probably the problem can be solved in there.')

class PageErrorLaunch (CTK.Page):
    def __init__ (self, error_str, **kwargs):
        srcdir = os.path.dirname (os.path.realpath (__file__))
        theme_file = os.path.join (srcdir, 'exception.html')

        # Set up the template
        template = CTK.Template (filename = theme_file)
        template['body_props'] = ' id="body-error"'

        # Parent's constructor
        CTK.Page.__init__ (self, template, **kwargs)

        # Error parse
        self._error     = None
        self._error_raw = error_str

        for line in error_str.split("\n"):
            if not line:
                continue

            if line.startswith("{'type': "):
                src = "self._error = " + line
                exec(src)
                break

        # Build the page content
        template['title'] = _('Server Launch Error')

        if self._error:
            self._build_error_py()
        else:
            self._build_error_raw()

    def _build_error_py (self):
        self += CTK.RawHTML ('<h1>%s</h1>' %(self._error['title']))
        self += CTK.Box ({'class': 'description'}, CTK.RawHTML(self._error.get('description','')))

        admin_url = self._error.get('admin_url')
        if admin_url:
            self += CTK.Box ({'class': 'admin-url'}, CTK.RawHTML(_(ERROR_LAUNCH_URL_ADMIN)%(admin_url)))

        debug = self._error.get('debug')
        if debug:
            self += CTK.Box ({'class': 'debug'}, CTK.RawHTML(debug))

        backtrace = self._error.get('backtrace')
        if backtrace:
            self += CTK.Box ({'class': 'backtrace'}, CTK.RawHTML(backtrace))

        self += CTK.Box ({'class': 'time'}, CTK.RawHTML(self._error.get('time','')))

    def _build_error_raw (self):
        self += CTK.RawHTML ('<h1>%s</h1>' %(_('Server Launch Error')))
        self += CTK.Box ({'class': 'description'}, CTK.RawHTML(_('Something unexpected just happened.')))
        self += CTK.Box ({'class': 'backtrace'},   CTK.RawHTML(self._error_raw))



NOT_WRITABLE_F_TITLE = N_('The configuration file <code>%s</code> cannot be modified.')
NOT_WRITABLE_F_1     = N_('You have to change its permissions in order to allow cherokee-admin to work with it. You can try to fix it by changing the file permissions:')
NOT_WRITABLE_F_2     = N_('or by launching cherokee-admin as root.')

NOT_WRITABLE_D_TITLE = N_('The specified configuration file <code>%s</code> is a directory.')
NOT_WRITABLE_D_1     = N_('You must change the name in order to allow cherokee-admin to work with it. You can try to fix it by renaming the directory so the file can be created: ')
NOT_WRITABLE_D_2     = N_('or by launching cherokee-admin specifying a different configuration file.')

class ConfigNotWritable (CTK.Page):
    def __init__ (self, file, **kwargs):
        srcdir = os.path.dirname (os.path.realpath (__file__))
        theme_file = os.path.join (srcdir, 'exception.html')

        # Set up the template
        template = CTK.Template (filename = theme_file)
        template['body_props'] = ' id="body-error"'
        template['title']      = _('Configuration file is not writable')

        # Parent's constructor
        CTK.Page.__init__ (self, template, **kwargs)

        # Body
        if os.path.isfile (file):
            self += CTK.RawHTML ('<h1>%s</h1>' %(_('Configuration file is not writable')))
            self += CTK.RawHTML ('<p><strong>%s</strong></p>' %(NOT_WRITABLE_F_TITLE %(file)))
            self += CTK.RawHTML ('<p>%s</p>' %(NOT_WRITABLE_F_1))
            self += CTK.RawHTML ('<div class="shell">chmod u+w %s</div>' %(file))
            self += CTK.RawHTML ('<p>%s</p>' %(NOT_WRITABLE_F_2))
        else:
            self += CTK.RawHTML ('<h1>%s</h1>' %(_('Incorrect configuration file specified')))
            self += CTK.RawHTML ('<p><strong>%s</strong></p>' %(NOT_WRITABLE_D_TITLE %(file)))
            self += CTK.RawHTML ('<p>%s</p>' %(NOT_WRITABLE_D_1))
            self += CTK.RawHTML ('<div class="shell">mv %s %s.dir</div>' %(file, file))
            self += CTK.RawHTML ('<p>%s</p>' %(NOT_WRITABLE_D_2))


def NotWritable (file):
    return ConfigNotWritable (file).Render()



RESOURCE_MISSING_TITLE = N_('Could not find a Cherokee resource: <code>%s</code>')
RESOURCE_MISSING       = N_('You may need to reinstall the Web Server in order to sort out this issue.')

class ResourceMissingError (CTK.Page):
    def __init__ (self, path, **kwargs):
        srcdir = os.path.dirname (os.path.realpath (__file__))
        theme_file = os.path.join (srcdir, 'exception.html')

        # Set up the template
        template = CTK.Template (filename = theme_file)
        template['body_props'] = ' id="body-error"'
        template['title']      = _('Cherokee resource is missing')

        # Parent's constructor
        CTK.Page.__init__ (self, template, **kwargs)

        # Body
        self += CTK.RawHTML ('<h1>%s</h1>'%(template['title']))
        self += CTK.RawHTML ('<p><strong>%s</strong>'%(_(RESOURCE_MISSING_TITLE)%(path)))
        self += CTK.RawHTML ('<p>%s</p>' %(RESOURCE_MISSING))

def ResourceMissing (path):
    return ResourceMissingError(path).Render()



ANCIENT_CONFIG_TITLE = N_('Cherokee-admin has detected a very old configuration file.')
ANCIENT_CONFIG       = N_('Most probably cherokee-admin is trying to read an old configuration file. Please, remove it so cherokee-admin can create a new one with the right format.')

class AncientConfigError (CTK.Page):
    def __init__ (self, path, **kwargs):
        srcdir = os.path.dirname (os.path.realpath (__file__))
        theme_file = os.path.join (srcdir, 'exception.html')

        # Set up the template
        template = CTK.Template (filename = theme_file)
        template['body_props'] = ' id="body-error"'
        template['title']      = _('Detected an Ancient Configuration File')

        # Parent's constructor
        CTK.Page.__init__ (self, template, **kwargs)

        # Body
        self += CTK.RawHTML ('<h1>%s</h1>'%(_('Ancient Configuration File')))
        self += CTK.RawHTML ('<p><strong>%s</strong>'%(_(ANCIENT_CONFIG_TITLE)))
        self += CTK.RawHTML ('<p>%s</p>' %(ANCIENT_CONFIG))
        self += CTK.RawHTML ("<p><pre>rm -f '%s'</pre></p>" %(path))

def AncientConfig (file):
    return AncientConfigError(file).Render()



OWS_DIR_P1 = N_("A problem with the installation directories has been found.  The %s directory is missing and it could not be created by Cherokee-Admin.")
OWS_DIR_P2 = N_("Please, create it and try again:")

OWS_PERM_P1 = N_("A problem with the installation directories has been found.  The %(dir)s directory has the wrong permissions. It must be writable by the UID %(uid)s.")
OWS_PERM_P2 = N_("Please, fix it and try again:")

class OWSDirectoryError (CTK.Page):
    def __init__ (self, **kwargs):
        srcdir = os.path.dirname (os.path.realpath (__file__))
        theme_file = os.path.join (srcdir, 'exception.html')

        # Set up the template
        template = CTK.Template (filename = theme_file)
        template['body_props'] = ' id="body-error"'
        template['title']      = _('An Incomplete Installation was detected')

        # Parent's constructor
        CTK.Page.__init__ (self, template, **kwargs)

        # Write the right message
        errors = False

        for d in (CHEROKEE_OWS_DIR, CHEROKEE_OWS_ROOT):
            if not os.path.isdir (d):
                self += CTK.RawHTML ('<h1>%s</h1>'%(_('Missing Directory')))
                self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_DIR_P1)%(d)))
                self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_DIR_P2)))
                self += CTK.RawHTML ("<p><pre>mkdir -p -m 0755 '%s'</pre>" %(d))
                self += CTK.RawHTML ("<pre>chown -R %d '%s'</pre></p>" %(os.getuid(), d))
                errors = True
                break

            if not os.access (d, os.W_OK):
                self += CTK.RawHTML ('<h1>%s</h1>'%(_('Installation Problem')))
                self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_PERM_P1)%({'dir':d, 'uid':os.getuid()})))
                self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_PERM_P2)))
                self += CTK.RawHTML ("<pre>chown -R %d '%s'</pre></p>" %(os.getuid(), d))
                self += CTK.RawHTML ("<pre>chmod -R 0775 '%s'</pre></p>" %(d))
                errors = True
                break

        if errors:
            button = CTK.Button (_("Try Again"))
            button.bind ('click', CTK.JS.ReloadURL())
            self += button
        else:
            self += CTK.RawHTML (js = CTK.JS.ReloadURL())

def OWSDirectory():
    return OWSDirectoryError().Render()