This is a quick brain dump from my brief coding session on PAUSE working on the permissions. This won’t make sense without reading the code yourself. Unless you’re interested in modifying PAUSE or reviewing my changes I would ignore this blog post. I’m writing this for my future self as much as anyone. The behaviour I modified in my pull request is in italics.
The code for setting the permissions when a new distribution is indexed is largely in
PAUSE::package. It’s triggered by
PAUSE::mldistwatch, but the code that actually sets the permissions is in
perm_check checks that the current user has permission to be uploading this distro and bails if not. If this is a new package (and they do have permission) then it also adds the user to the
perms table as they are effectively first come.
give_regdowner_perms adds people to the
perms table where necessary. This was supporting the module permissions in amongst other things. It is now also where we copy the permissions from the main module.
checkin method as well as adding the record to the packages table also adds to the
primeur table via the
checkin_into_primeur function. If the
x_authority flag is used then that user is added, otherwise the main module is looked up, or failing that the uploading user.
Note that the first come (primeur) users appear in both the
There are special checks for Perl distributions in the permissions code that will change the behaviour of the permissions. I am purposely not mentioning them as I never took the time to understand them.
A quick note on testing. As well as the tests which work of the dummy distributions in the corpus directory there is a test utility. To get a look at the permissions database in practice use the
build-fresh-cpan script. This will build a one off cpan environment that you can examine. Just pass it a package to index and then you can check the permissions database.
$ perl one-off-utils/build-fresh-cpan corpus/mld/009/authors/O/OO/OOOPPP/Jenkins-Hack-0.14.tar.gz Initialized empty Git repository in /tmp/h4L3GU6Awi/git/.git/ $ ls cpan db git Maildir pause.log run $ cd db $ ls authen.sqlite mod.sqlite $ sqlite3 mod.sqlite SQLite version 126.96.36.199 2014-10-29 13:59:56 Enter ".help" for usage hints. sqlite> select * from primeur; Jenkins::Hack::Utils|LOCAL Jenkins::Hack|LOCAL Jenkins::Hack2|LOCAL sqlite> select * from perms; 1|Jenkins::Hack::Utils|LOCAL 2|Jenkins::Hack|LOCAL 3|Jenkins::Hack2|LOCAL sqlite>