~ubuntu-branches/ubuntu/maverick/aptdaemon/maverick-proposed

« back to all changes in this revision

Viewing changes to aptdaemon/core.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-09-08 09:38:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100908093831-xg57uhzyzxuny56a
Tags: 0.31+bzr476-0ubuntu2
* debian/patches/07_i18n_fixes.patch: 
  - use dgettext to not clobber the clients gettext.textdomain
    on import (LP: #631675)
* debian/patches/05_sources_list_password.patch: 
  - when adding a sources.list entry with a password protect
    the file via mode 0640 and root.admin ownership

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from optparse import OptionParser
45
45
import os
46
46
import Queue
 
47
import re
47
48
import signal
48
49
import sys
49
50
import tempfile
1319
1320
            sourcesfile = None
1320
1321
        action = policykit1.PK_ACTION_CHANGE_REPOSITORY
1321
1322
        yield policykit1.check_authorization_by_name(sender, action)
1322
 
        old_umask = os.umask(0022)
 
1323
        # if there is a password in the uri, protect the file from
 
1324
        # non-admin users
 
1325
        password_in_uri = re.match("(http|https|ftp)://\S+?:\S+?@\S+", uri)
 
1326
        if password_in_uri:
 
1327
            old_umask = os.umask(0027)
 
1328
        else:
 
1329
            old_umask = os.umask(0022)
1323
1330
        try:
1324
1331
            sources = SourcesList()
1325
1332
            entry = sources.add(type, uri, dist, comps, comment,
1328
1335
                raise errors.RepositoryInvalidError()
1329
1336
        #FIXME: Should be removed after requiring Python 2.6
1330
1337
        except Exception, error:
 
1338
            logging.exception("adding repository")
1331
1339
            raise error
1332
1340
        else:
1333
1341
            sources.save()
 
1342
            # set to sourcesfile root.admin only
 
1343
            if password_in_uri and sourcesfile:
 
1344
                import grp
 
1345
                try:
 
1346
                    os.chown(sourcesfile, 0, grp.getgrnam("admin")[2])
 
1347
                except Exception, e:
 
1348
                    logging.warn("os.chmod() failed '%s'" % e)
1334
1349
        finally:
1335
1350
            os.umask(old_umask)
1336
1351