From 71ec383a3cf5f913055172eb966f3b95ea7fa8d3 Mon Sep 17 00:00:00 2001 From: Bernardo Innocenti Date: Sun, 23 Sep 2007 08:29:45 +0200 Subject: [PATCH] Fix ACLs --- geekigeeki.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index 9fd1adf..0c1423a 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -219,9 +219,6 @@ def do_raw(pagename): Page(pagename).send_raw() def do_savepage(pagename): - if privileged_url is None: - raise 'editing disallowed for ' + pagename - global form pg = Page(pagename) if 'preview' in form: @@ -230,7 +227,7 @@ def do_savepage(pagename): pg.save_text(form['savetext'].value) pg.send_page() elif 'cancel' in form: - pg.msg = 'Editing cancelled' + pg.msg = 'Editing canceled' pg.msg_type = 'notice' pg.send_page() else: @@ -592,7 +589,6 @@ class Page: else: return link_tag(word, word, 'nonexistent') - def get_raw_body(self): try: return open(self._text_filename(), 'rt').read() @@ -651,7 +647,7 @@ class Page: if self.can_read(): PageFormatter(self.get_raw_body()).print_html() else: - print "

This page is not visible to you

" + send_guru("Read access denied by ACLs", "notice") send_footer(page_name, self._last_modified()) def _last_modified(self): @@ -663,6 +659,9 @@ class Page: def send_editor(self, preview=None): send_title(None, 'Edit ' + self.split_title(), msg=self.msg, msg_type=self.msg_type) + if not self.can_write(): + send_guru("Write access denied by ACLs", "error") + return print ('

Editing ' + self.page_name + ' for ' + cgi.escape(remote_user()) @@ -687,6 +686,9 @@ class Page: send_footer(self.page_name) def send_raw(self): + if not self.can_read(): + send_title(None, msg='Read access denied by ACLs', msg_type='notice') + return emit_header("text/plain") print self.get_raw_body() @@ -703,6 +705,11 @@ class Page: os.rename(tmp_filename, text) def save_text(self, newtext): + if not self.can_write(): + self.msg = 'Write access denied by ACLs' + self.msg_type = 'error' + return + self._write_file(newtext) rc = 0 if post_edit_hook: @@ -721,7 +728,7 @@ class Page: if msg: self.msg += 'Output follows:\n' + msg else: - self.msg = 'Thankyou for your contribution. Your attention to detail is appreciated.' + self.msg = 'Thank you for your contribution. Your attention to detail is appreciated.' self.msg_type = 'success' def send_verbatim(filename, mime_type='application/octet-stream'): -- 2.25.1