This file is indexed.

/usr/lib/python2.7/dist-packages/otrapps/adium.py is in keysync 0.2.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-

from __future__ import print_function
import os
import platform
import plistlib
import sys

if __name__ == '__main__':
    sys.path.insert(0, "../") # so the main() test suite can find otrapps module
import otrapps.util
from otrapps.otr_private_key import OtrPrivateKeys
from otrapps.otr_fingerprints import OtrFingerprints

class AdiumProperties():

    path = os.path.expanduser('~/Library/Application Support/Adium 2.0/Users/Default')
    accountsfile = 'Accounts.plist'
    keyfile = 'otr.private_key'
    fingerprintfile = 'otr.fingerprints'
    files = (accountsfile, keyfile, fingerprintfile)

    @staticmethod
    def _get_accounts_from_plist(settingsdir):
        '''get dict of accounts from Accounts.plist'''
        # convert index numbers used for the name into the actual account name
        accountsfile = os.path.join(settingsdir, 'Accounts.plist')
        print('accountsfile: ', end=' ')
        print(accountsfile)
        if not os.path.exists(accountsfile):
            oldaccountsfile = accountsfile
            accountsfile = os.path.join(AdiumProperties.path, AdiumProperties.accountsfile)
            if platform.system() == 'Darwin' and os.path.exists(accountsfile):
                print('Adium WARNING: "' + oldaccountsfile + '" does not exist! Using:')
                print('\t"' + accountsfile + '"')
            else:
                print('Adium ERROR: No usable Accounts.plist file found, cannot create Adium files!')
                return []
        # make sure the plist is in XML format, not binary,
        # this should be converted to use python-biplist.
        if platform.system() == 'Darwin':
            os.system("plutil -convert xml1 '" + accountsfile + "'")
        return plistlib.readPlist(accountsfile)['Accounts']

    @staticmethod
    def parse(settingsdir=None):
        if settingsdir == None:
            settingsdir = AdiumProperties.path

        kf = os.path.join(settingsdir, AdiumProperties.keyfile)
        if os.path.exists(kf):
            keydict = OtrPrivateKeys.parse(kf)
        else:
            keydict = dict()

        accounts = AdiumProperties._get_accounts_from_plist(settingsdir)
        newkeydict = dict()
        for adiumIndex, key in keydict.items():
            for account in accounts:
                if account['ObjectID'] == key['name']:
                    name = account['UID']
                    key['name'] = name
                    newkeydict[name] = key
        keydict = newkeydict

        fpf = os.path.join(settingsdir, AdiumProperties.fingerprintfile)
        if os.path.exists(fpf):
            otrapps.util.merge_keydicts(keydict, OtrFingerprints.parse(fpf))

        return keydict

    @staticmethod
    def write(keydict, savedir='./'):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        # need when converting account names back to Adium's account index number
        accountsplist = AdiumProperties._get_accounts_from_plist(savedir)

        kf = os.path.join(savedir, AdiumProperties.keyfile)
        adiumkeydict = dict()
        for name, key in keydict.items():
            name = key['name']
            for account in accountsplist:
                if account['UID'] == name:
                    key['name'] = account['ObjectID']
                    adiumkeydict[name] = key
        OtrPrivateKeys.write(keydict, kf)

        accounts = []
        for account in accountsplist:
            accounts.append(account['ObjectID'])
        fpf = os.path.join(savedir, AdiumProperties.fingerprintfile)
        OtrFingerprints.write(keydict, fpf, accounts)


if __name__ == '__main__':

    import pprint

    print('Adium stores its files in ' + AdiumProperties.path)

    if len(sys.argv) == 2:
        settingsdir = sys.argv[1]
    else:
        settingsdir = '../tests/adium'
    keydict = AdiumProperties.parse(settingsdir)
    pprint.pprint(keydict)

    AdiumProperties.write(keydict, '/tmp')