This file is indexed.

/usr/bin/pasaffe-import-figaroxml is in pasaffe 0.38-0ubuntu1.

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

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/python3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (C) 2011 Marc Deslauriers <marc.deslauriers@canonical.com>
# Copyright (C) 2011 Francesco Marella <fra.marella@gmx.com>
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
### END LICENSE

import sys
import os
import getpass
import shutil
from optparse import OptionParser

import gettext
from gettext import gettext as _
gettext.textdomain('pasaffe')

# Add project root directory (enable symlink and trunk execution)
PROJECT_ROOT_DIRECTORY = os.path.abspath(
    os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))))

python_path = []
if os.path.abspath(__file__).startswith('/opt'):
    syspath = sys.path[:]  # copy to avoid infinite loop in pending objects
    for path in syspath:
        opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/pasaffe')
        python_path.insert(0, opt_path)
        sys.path.insert(0, opt_path)
if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'pasaffe'))
    and PROJECT_ROOT_DIRECTORY not in sys.path):
    python_path.insert(0, PROJECT_ROOT_DIRECTORY)
    sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
if python_path:
    os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path)))  # for subprocess

from pasaffe_lib import figaroxml
from pasaffe_lib import readdb
from pasaffe_lib import set_up_logging, get_version
from pasaffe_lib.helpers import confirm, get_database_path

parser = OptionParser()
parser.add_option("-v", "--verbose", action="count", dest="verbose",
                  help="Show debug messages (-vv debugs pasaffe_lib also)")
parser.add_option("-f", "--file", dest="filename",
                  help="specify FPM2 XML file", metavar="FILE")
parser.add_option("-d", "--database", dest="database",
                  default=None, help="specify alternate Pasaffe database file")
parser.add_option("-o", "--overwrite", dest="overwrite", action="store_true",
                  default=False, help="overwrite existing Pasaffe password store")
parser.add_option("-y", "--yes", dest="yes", action="store_true",
                  default=False, help="don't ask for confirmation (may result in data loss!)")
parser.add_option("-m", "--masterpassword", dest="master",
                  default=None, help="specify Pasaffe database master password")
parser.add_option("-q", "--quiet", dest="quiet", action="store_true",
                  default=False, help="quiet messages")

(options, args) = parser.parse_args()

set_up_logging(options)

if options.filename == None:
    print("You must specify the name of the FPM2 XML file!\n")
    parser.print_help()
    sys.exit(1)
else:
    filename = options.filename

if not options.quiet:
    print("Attempting to import FPM2 passwords...")
    print("Database filename is %s" % filename)
    print()

if not os.path.exists(filename):
    print("Could not locate database file!")
    sys.exit(1)

if options.database == None:
    db_filename = get_database_path()
else:
    db_filename = options.database

fpmxml = figaroxml.FigaroXML(filename)

items = len(fpmxml.records)

if items == 0:
    print("Database was empty!")
    sys.exit(1)
else:
    if not options.quiet:
        print("Located %s passwords in the database!" % items)
        print()

if not options.quiet and len(fpmxml.skipped) > 0:
    print("WARNING: The following fields will be ignored by this script:")
    print(" ".join(fpmxml.skipped))
    print("Please keep a copy of your original FPM2 database, as the")
    print("content of those fields will not be imported into Pasaffe.")
    print()

if options.yes == True:
    if options.overwrite == True and os.path.exists(db_filename):
        shutil.copy(db_filename, db_filename + ".bak")
        os.unlink(db_filename)
else:
    if not os.path.exists(db_filename):
        print("WARNING: Could not locate a Pasaffe database.")
        response = confirm(prompt='Create a new database?', resp=False)
    elif options.overwrite == True:
        print("If you continue, your current Pasaffe database will be DELETED.")
        response = confirm(prompt='Overwrite database?', resp=False)
        if response == True:
            shutil.copy(db_filename, db_filename + ".bak")
            os.unlink(db_filename)
    else:
        print("If you continue, passwords will be imported into Pasaffe.")
        response = confirm(prompt='Import to database?', resp=False)

    if response == False:
        print("Aborting.")
        sys.exit(1)

# Get password for Pasaffe database
if os.path.exists(db_filename):
    if options.master != None:
        password = options.master
    else:
        print("You must now enter the Pasaffe database password.")
        password = getpass.getpass()

    passsafe = readdb.PassSafeFile(db_filename, password)
    for entry in fpmxml.records:
        passsafe.records[entry] = fpmxml.records[entry]
    passsafe.writefile(db_filename, backup=True)
else:
    if options.master != None:
        password = options.master
    else:
        print("You now must enter a master password for the new Pasaffe database")
        while(1):
            password = getpass.getpass("New password: ")
            password_conf = getpass.getpass("Confirm password: ")
            if password != password_conf:
                print("ERROR: passwords don't match, try again.\n\n")
            else:
                break
    passsafe = readdb.PassSafeFile()
    passsafe.new_db(password)
    passsafe.records = fpmxml.records
    passsafe.writefile(db_filename)

if not options.quiet:
    print("Success!")