def rpc_config_set(handler, options): """ Set options in the server's configuration. Any changes to the server's configuration are not written to disk. :param dict options: A dictionary of option names and values """ for option_name, option_value in options.items(): if not option_name in CONFIG_WRITEABLE: raise errors.KingPhisherPermissionError('permission denied to write config option: ' + option_name) handler.config.set(option_name, option_value) return
def rpc_config_get(handler, option_name): """ Retrieve a value from the server's configuration. :param str option_name: The name of the configuration option. :return: The option's value. """ if isinstance(option_name, (list, tuple)): option_names = option_name option_values = {} for option_name in option_names: if not option_name in CONFIG_READABLE: raise errors.KingPhisherPermissionError('permission denied to read config option: ' + option_name) if handler.config.has_option(option_name): option_values[option_name] = handler.config.get(option_name) return option_values if not option_name in CONFIG_READABLE: raise errors.KingPhisherPermissionError('permission denied to read config option: ' + option_name) if handler.config.has_option(option_name): return handler.config.get(option_name) return
def rpc_config_set(handler, options): """ Set options in the server's configuration. Any changes to the server's configuration are not written to disk. :param dict options: A dictionary of option names and values """ if rpc_logger.isEnabledFor(logging.DEBUG): _log_rpc_call(handler, 'rpc_config_set', dict((key, _REDACTED) for key in options.keys())) for key, value in options.items(): if key not in CONFIG_WRITEABLE: raise errors.KingPhisherPermissionError('permission denied to write config option: ' + key) handler.config.set(key, value) return
def rpc_database_get_row_by_id(handler, session, table_name, row_id): """ Retrieve a row from a given table with the specified value in the id column. :param str table_name: The name of the database table to retrieve a row from. :param row_id: The id value. :return: The specified row data. :rtype: dict """ metatable = handler.server.tables_api.get(table_name) if not metatable: raise errors.KingPhisherAPIError("failed to get table object for: {0}".format(table_name)) row = db_manager.get_row_by_id(session, metatable.model, row_id) if row: row.assert_session_has_permissions('r', handler.rpc_session) row = dict(zip(metatable.column_names, (getattr(row, c) for c in metatable.column_names))) elif metatable.model.is_private: raise errors.KingPhisherPermissionError() return row
def wrapped(plugin, handler, *args, **kwargs): if not plugin.handler_has_write_access(handler): raise errors.KingPhisherPermissionError( 'the user does not possess the necessary access level to change this data' ) return function(plugin, handler, *args, **kwargs)