Add per-package upload permission checks.

This commit is contained in:
Luca Falavigna 2009-02-19 23:59:12 +01:00
parent b04a9071c0
commit d830c5a4c1
3 changed files with 34 additions and 2 deletions

8
debian/changelog vendored
View File

@ -6,7 +6,13 @@ ubuntu-dev-tools (0.65) UNRELEASED; urgency=low
[ Jonathan Davies ] [ Jonathan Davies ]
* requestsync: Only check existing reports if the --lp flag is used. * requestsync: Only check existing reports if the --lp flag is used.
-- Jonathan Davies <jpds@ubuntu.com> Mon, 16 Feb 2009 15:06:16 +0000 [ Luca Falavigna ]
* Add per-package upload permission checks:
- ubuntutools/lp/functions.py: implement isPerPackageUploader.
- requestsync: check if submitter has per-package upload permission
using isPerPackageUploader function and adjust report accordingly.
-- Luca Falavigna <dktrkranz@ubuntu.com> Thu, 19 Feb 2009 23:55:04 +0100
ubuntu-dev-tools (0.64) jaunty; urgency=low ubuntu-dev-tools (0.64) jaunty; urgency=low

View File

@ -78,6 +78,11 @@ def checkNeedsSponsorship(component):
teamMember = lp_functions.isLPTeamMember(team) teamMember = lp_functions.isLPTeamMember(team)
if not teamMember: if not teamMember:
# Check if they have a per-package upload permission.
if lp_functions.isPerPackageUploader(args[0]):
return "perpackageupload"
print "You are not a member (direct or indirect) of the '%s' " \ print "You are not a member (direct or indirect) of the '%s' " \
"team on Launchpad." % team "team on Launchpad." % team
print "Your sync request shall require an approval by a member of " \ print "Your sync request shall require an approval by a member of " \
@ -526,7 +531,7 @@ if __name__ == '__main__':
# Generate bug report. # Generate bug report.
subscribe = 'ubuntu-archive' subscribe = 'ubuntu-archive'
status = 'confirmed' status = 'confirmed'
if sponsorship: if sponsorship == True:
status = 'new' status = 'new'
if component in ['main', 'restricted']: if component in ['main', 'restricted']:
subscribe = 'ubuntu-main-sponsors' subscribe = 'ubuntu-main-sponsors'
@ -550,6 +555,9 @@ if __name__ == '__main__':
report += 'Explanation of the Ubuntu delta and why it can be dropped:\n' + \ report += 'Explanation of the Ubuntu delta and why it can be dropped:\n' + \
'>>> ENTER_EXPLANATION_HERE <<<\n\n' '>>> ENTER_EXPLANATION_HERE <<<\n\n'
if sponsorship == 'perpackageupload':
report += 'Note that I have per-package upload permissions for %s.\n\n' % srcpkg
uidx = base_ver.find('build') uidx = base_ver.find('build')
if uidx > 0: if uidx > 0:
base_ver = base_ver[:uidx] base_ver = base_ver[:uidx]

View File

@ -22,6 +22,9 @@ import cookie
import urlopener as lp_urlopener import urlopener as lp_urlopener
import urllib2 import urllib2
import sys import sys
import libsupport as lp_libsupport
import launchpadlib
from re import findall
def isLPTeamMember(team): def isLPTeamMember(team):
""" Checks if the user is a member of a certain team on Launchpad. """ Checks if the user is a member of a certain team on Launchpad.
@ -53,3 +56,18 @@ def isLPTeamMember(team):
return False return False
return True return True
def isPerPackageUploader(package):
# Checks if the user has upload privileges for a certain package.
launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools")
me = findall('~(\S+)', '%s' % launchpad.me)[0]
main_archive = launchpad.distributions["ubuntu"].main_archive
try:
perms = main_archive.getUploadersForPackage(source_package_name=package)
except launchpadlib.errors.HTTPError:
return False
for perm in perms:
if perm.person.name == me:
return True