def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter)
context.signal_map = { signal.SIGTERM: 'terminate', signal.SIGHUP: 'terminate' } if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print 'Password failed' sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = make_encrypter(new_password) print 'Re-encrypting your keys...' astore = ActivityStore(os.path.join(args['data_dir'], DBNAME), encrypter, store_text=(not args['no_text'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print 'Exiting...' sys.exit(0)
if __name__ == '__main__': args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) ss = Selfstats(os.path.join(args['data_dir'], DBNAME), args) if args['limit']: try: int(args['limit'][0]) except ValueError: print 'First argument to --limit must be an integer' sys.exit(1) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password() if args['password'] == "": models.ENCRYPTER = None else: models.ENCRYPTER = Blowfish.new(hashlib.md5(args['password']).digest()) if not check_password.check(args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) ss.do()
context = daemon.DaemonContext(working_directory=args['data_dir'], pidfile=lock, stderr=sys.stderr) context.signal_map = { signal.SIGTERM: 'terminate', signal.SIGHUP: 'terminate' } if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print 'Password failed' sys.exit(1) with context: astore = ActivityStore(os.path.join(args['data_dir'], DBNAME), encrypter, store_text=(not args['no_text'])) try: astore.run() except SystemExit: astore.close()
if __name__ == '__main__': args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) ss = Selfstats(os.path.join(args['data_dir'], DBNAME), args) if args['limit']: try: int(args['limit'][0]) except ValueError: print 'First argument to --limit must be an integer' sys.exit(1) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password() if args['password'] == "": models.ENCRYPTER = None else: models.ENCRYPTER = Blowfish.new( hashlib.md5(args['password']).digest()) if not check_password.check( args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) ss.do()