config: add write support for NMConfig
Internal configuration is written as keyfile to NMSTATEDIR"/NetworkManager-intern.conf" Basically, the content of this file is merged with user configuration from "NetworkManager.conf" files. After loading the configuration, NMConfig exposes a merged view of user-provided settings and internal overwrites. All sections/groups named [.intern*] are reserved for internal configuration values. They can be written by API, but are ignored when the user sets them via "NetworkManager.conf". For these internal sections, no conflicts can arise. We can also overwrite individual properties from user configuration. In this case, we store the value we want to set, but also remember the value that the user configuration had, at the time of setting. If on a later reload the user configuration changed, we ignore our internal value -- as we assume that the user modified the value afterwards. We can also hide/delete value from user configuration. This works on a per-setting basis.
This commit is contained in:
@@ -38,7 +38,8 @@ G_BEGIN_DECLS
|
||||
|
||||
#define NM_CONFIG_DATA_CONFIG_MAIN_FILE "config-main-file"
|
||||
#define NM_CONFIG_DATA_CONFIG_DESCRIPTION "config-description"
|
||||
#define NM_CONFIG_DATA_KEYFILE "keyfile"
|
||||
#define NM_CONFIG_DATA_KEYFILE_USER "keyfile-user"
|
||||
#define NM_CONFIG_DATA_KEYFILE_INTERN "keyfile-intern"
|
||||
#define NM_CONFIG_DATA_CONNECTIVITY_URI "connectivity-uri"
|
||||
#define NM_CONFIG_DATA_CONNECTIVITY_INTERVAL "connectivity-interval"
|
||||
#define NM_CONFIG_DATA_CONNECTIVITY_RESPONSE "connectivity-response"
|
||||
@@ -71,10 +72,12 @@ typedef enum { /*< flags >*/
|
||||
|
||||
NM_CONFIG_CHANGE_CONFIG_FILES = (1L << 3),
|
||||
NM_CONFIG_CHANGE_VALUES = (1L << 4),
|
||||
NM_CONFIG_CHANGE_CONNECTIVITY = (1L << 5),
|
||||
NM_CONFIG_CHANGE_NO_AUTO_DEFAULT = (1L << 6),
|
||||
NM_CONFIG_CHANGE_DNS_MODE = (1L << 7),
|
||||
NM_CONFIG_CHANGE_RC_MANAGER = (1L << 8),
|
||||
NM_CONFIG_CHANGE_VALUES_USER = (1L << 5),
|
||||
NM_CONFIG_CHANGE_VALUES_INTERN = (1L << 6),
|
||||
NM_CONFIG_CHANGE_CONNECTIVITY = (1L << 7),
|
||||
NM_CONFIG_CHANGE_NO_AUTO_DEFAULT = (1L << 8),
|
||||
NM_CONFIG_CHANGE_DNS_MODE = (1L << 9),
|
||||
NM_CONFIG_CHANGE_RC_MANAGER = (1L << 10),
|
||||
|
||||
_NM_CONFIG_CHANGE_LAST,
|
||||
NM_CONFIG_CHANGE_ALL = ((_NM_CONFIG_CHANGE_LAST - 1) << 1) - 1,
|
||||
@@ -93,7 +96,9 @@ GType nm_config_data_get_type (void);
|
||||
NMConfigData *nm_config_data_new (const char *config_main_file,
|
||||
const char *config_description,
|
||||
const char *const*no_auto_default,
|
||||
GKeyFile *keyfile);
|
||||
GKeyFile *keyfile_user,
|
||||
GKeyFile *keyfile_intern);
|
||||
NMConfigData *nm_config_data_new_update_keyfile_intern (const NMConfigData *base, GKeyFile *keyfile_intern);
|
||||
NMConfigData *nm_config_data_new_update_no_auto_default (const NMConfigData *base, const char *const*no_auto_default);
|
||||
|
||||
NMConfigChangeFlags nm_config_data_diff (NMConfigData *old_data, NMConfigData *new_data);
|
||||
@@ -128,6 +133,13 @@ char *nm_config_data_get_connection_default (const NMConfigData *self,
|
||||
char **nm_config_data_get_groups (const NMConfigData *self);
|
||||
char **nm_config_data_get_keys (const NMConfigData *self, const char *group);
|
||||
|
||||
GKeyFile *nm_config_data_clone_keyfile_intern (const NMConfigData *self);
|
||||
|
||||
/* private accessors */
|
||||
GKeyFile *_nm_config_data_get_keyfile (const NMConfigData *self);
|
||||
GKeyFile *_nm_config_data_get_keyfile_user (const NMConfigData *self);
|
||||
GKeyFile *_nm_config_data_get_keyfile_intern (const NMConfigData *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_CONFIG_DATA_H */
|
||||
|
Reference in New Issue
Block a user