This abstracts away from the GDBM interface slightly, and makes it a bit
more convenient for other implementations.
using the stored keys.
"""
using the stored keys.
"""
- def __init__(me, file, mode = 'r'):
+ def __init__(me, file, writep = False):
"""
Initialize a PW object from the GDBM database in FILE.
"""
Initialize a PW object from the GDBM database in FILE.
- MODE can be `r' for read-only access to the underlying database, or `w'
- for read-write access. Requests the database password from the Pixie,
+ If WRITEP is true, then allow write-access to the database; otherwise
+ allow read access only. Requests the database password from the Pixie,
which may cause interaction.
"""
## Open the database.
which may cause interaction.
"""
## Open the database.
- me.db = _G.open(file, mode)
+ me.db = _G.open(file, writep and 'w' or 'r')
## Find out what crypto to use.
c = _C.gcciphers[me.db['cipher']]
## Find out what crypto to use.
c = _C.gcciphers[me.db['cipher']]
def cmd_changepp(av):
if len(av) != 0:
return 1
def cmd_changepp(av):
if len(av) != 0:
return 1
+ pw = PW(file, writep = True)
pw.changepp()
def cmd_find(av):
pw.changepp()
def cmd_find(av):
pp = stdin.readline()
else:
pp = av[1]
pp = stdin.readline()
else:
pp = av[1]
+ pw = PW(file, writep = True)
pw[av[0]] = chomp(pp)
def cmd_copy(av):
pw[av[0]] = chomp(pp)
def cmd_copy(av):
def cmd_del(av):
if len(av) != 1:
return 1
def cmd_del(av):
if len(av) != 1:
return 1
+ pw = PW(file, writep = True)
tag = av[0]
try:
del pw[tag]
tag = av[0]
try:
del pw[tag]