~ubuntu-branches/ubuntu/precise/python-keyring/precise-updates

« back to all changes in this revision

Viewing changes to keyring/util/loc_compat.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-11-19 12:50:49 UTC
  • mfrom: (8.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121119125049-mryxwft3qi7fz3pg
Tags: 0.9.2-0ubuntu0.12.04.2
* SECURITY UPDATE: CryptedFileKeyring format is insecure (LP: #1004845)
  - Rebuild python-keyring 0.9.2 from Ubuntu 12.10 as a security update
    for Ubuntu 12.04.
  - debian/patches/crypto_compat.patch: include PBKDF2() directly to be
    compatible with the older version of python-crypto in Ubuntu 12.04.
  - CVE-2012-4571
* SECURITY UPDATE: insecure default file permissions (LP: #1031465)
  - debian/patches/file_permissions.patch: set appropriate permissions on
    database directory.
  - CVE number pending
* debian/patches/fix_migration.patch: fix migration code so old
  databases get upgraded when a key is read. (LP: #1042754)
* debian/patches/fix_unlock.patch: fix unlocking an existing keyring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import shutil
 
3
import stat
 
4
import sys
 
5
 
 
6
def relocate_file(old_location, new_location):
 
7
    """
 
8
    keyring 0.8 changes the default location for storage of
 
9
    file-based keyring locations. This function is invoked to move
 
10
    files stored in the old location to the new location.
 
11
 
 
12
    TODO: remove this function for keyring 1.0.
 
13
    """
 
14
    if not os.path.exists(old_location):
 
15
        # nothing to do; no legacy file found
 
16
        return
 
17
 
 
18
    if os.path.exists(new_location):
 
19
        print >> sys.stderr, ("Password file found in legacy "
 
20
            "location\n  %(old_location)s\nand new location\n"
 
21
            "  %(new_location)s\nOld location will be ignored."
 
22
            % vars())
 
23
        return
 
24
 
 
25
    # ensure the storage path exists
 
26
    if not os.path.isdir(os.path.dirname(new_location)):
 
27
        os.makedirs(os.path.dirname(new_location))
 
28
    os.chmod(os.path.dirname(new_location),
 
29
        stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
 
30
    shutil.move(old_location, new_location)