#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'CREATE TABLE loginfo('
+ 'id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, '
+ 'log_id TEXT, '
+ 'public_key TEXT, ' # path to PEM-encoded file
+ 'distrusted INTEGER, ' # non-zero if not trusted
+ 'min_valid_timestamp INTEGER, '
+ 'max_valid_timestamp INTEGER, '
+ 'url TEXT)'
)
if required:
print >> sys.stderr, 'A record id was not provided'
sys.exit(1)
return None
stmt = 'SELECT * FROM loginfo WHERE id = ?'
cur.execute(stmt, [record_id])
sys.exit(1)
return record_id
return None
print >> sys.stderr, 'A log id was not provided'
sys.exit(1)
print >> sys.stderr, 'The log id is not formatted properly'
sys.exit(1)
return log_id
print >> sys.stderr, 'A public key file was not provided'
sys.exit(1)
sys.exit(1)
return pubkey
print >> sys.stderr, 'A timestamp was not provided'
sys.exit(1)
t = args.pop(0)
if t == '-':
return None
try:
val = int(t)
print >> sys.stderr, 'The timestamp "%s" is invalid' % t
sys.exit(1)
return val
usage()
stmt = 'INSERT INTO loginfo (public_key) VALUES(?)'
else:
stmt = 'UPDATE loginfo SET public_key = ? WHERE id = ?'
# can't specify more than one of record-id and log-id
usage()
if record_id:
stmt = 'UPDATE loginfo SET url = ? WHERE id = ?'
elif log_id:
stmt = 'INSERT INTO loginfo (log_id, url) VALUES(?, ?)'
else:
stmt = 'INSERT INTO loginfo (url) VALUES(?)'
usage()
if record_id:
stmt = 'DELETE FROM loginfo WHERE id = ?'
else:
stmt = 'DELETE FROM loginfo WHERE log_id = ?'
# could take a record id or a log id
if record_id:
else:
usage()
stmt = 'INSERT INTO loginfo (log_id, distrusted) VALUES(?, ?)'
cur.execute(stmt, [log_id, flag])
else:
stmt = 'UPDATE loginfo SET distrusted = ? WHERE id = ?'
cur.execute(stmt, [flag, record_id])
trust_distrust_log(cur, args + [0])
trust_distrust_log(cur, args + [1])
# could take a record id or a log id
if record_id:
else:
usage()
stmt = 'INSERT INTO loginfo ' + \
'(log_id, min_valid_timestamp, max_valid_timestamp) ' + \
'VALUES(?, ?, ?)'
else:
stmt = 'UPDATE loginfo SET min_valid_timestamp = ?, ' + \
'max_valid_timestamp = ? WHERE id = ?'
stmt = 'SELECT * FROM loginfo'
recs = []
return recs
usage()
not_conf = '(not configured)'
mint = \
maxt = \
print 'Log entry:'
print ' Public key file: ' + \
(rec.public_key if rec.public_key else not_conf)
print ''
help = """Usage: %s /path/to/log-config-db command args
Commands:
display config-db contents:
dump
configure public key:
configure-public-key [log-id|record-id] /path/log-pub-key.pem
configure URL:
configure-url [log-id|record-id] http://www.example.com/path/
valid-time-range log-id|record-id min-range max-range
mark log as trusted (default):
trust log-id|record-id
mark log as untrusted:
distrust log-id|record-id
remove log config from config-db:
forget log-id|record-id
log-id is a 64-character hex string representation of a log id
record-id references an existing entry and is in the form:
#<record-number>
(displayable with the dump command)
print >> sys.stderr, help
sys.exit(1)
usage()
'configure-url': configure_url,
'distrust': distrust_log,
'trust': trust_log,
'forget': forget_log,
'valid-time-range': time_range,
'dump': dump,
}
usage()
else:
sys.exit(1)
if __name__ == "__main__":