Re: mailgw woes

Ralf Schlatterbeck <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
On Tue, Apr 13, 2021 at 10:34:58PM +0000, Tom Ekberg wrote:
> 
> The problem I'm having is that when a user, that has no corresponding
> tracker user, sends an email, the issue gets created by user
> Anonymous. I tracked the problem down to mailgw.py in the
> get_author_id function in this code fragment:
> 
>         create = 1
>         anonid = self.db.user.lookup('anonymous')
>         if not (self.db.security.hasPermission('Register', anonid, 'user')
>                 and self.db.security.hasPermission('Email Access', anonid)):
>             create = 0
> 
> The "Register' part of the 'if' statement returns 0, while the 'Email
> Access' part returns 1. This causes create to be set to 0, failing to
> create a tracker user using the sender's email. I have these lines in
> my schema.py for this tracker:
> 
> db.security.addPermissionToRole('Anonymous', 'Email Access')
> db.security.addPermissionToRole('Anonymous', 'Register', 'user')
> 
> Which should cause both the 'Register' and "Email Address' parts of
> the if in get_author_id to return 1, leaving create being set to 1.

Looks good, I can't spot any obvious errors.
You can debug this as follows:

In the tracker directory create a script:

import sys
import os
from roundup import instance
dir = os.getcwd ()
tracker = instance.open (dir)
db = tracker.open ('anonymous')
anonid = db.user.lookup ('anonymous')
print (db.security.hasPermission('Register', anonid, 'user'))
print (db.security.hasPermission('Email Access', anonid))

You can directly cut&paste this into a python interpreter started in the
tracker directory and experiment with the permissions, also with
db.security.addPermissionToRole to check if the permissions are there
when added.

At least in my trackers I don't have a Register permission defined, so
the addPermissionToRole above fails in my trackers with a
ValueError: No permission "Register" defined
but I *think* this would work in the classic template.

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.