summaryrefslogtreecommitdiff
path: root/src/nm-config-data.c
Commit message (Collapse)AuthorAgeFilesLines
* config: remove nm_config_data_get_value_cached()Thomas Haller2017-10-311-21/+0
| | | | | | | It has almost no callers, and it is a bit of a strange API. Let's not cache the last accessed value inside NMConfigData. Instead, free it right after use. It was not reused anyway, it only hangs around as convenience for the caller.
* config: add nm_config_data_get_value_int64() utilThomas Haller2017-10-311-1/+23
|
* core,clients: use our own string hashing function nm_str_hash()Thomas Haller2017-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | Replace the usage of g_str_hash() with our own nm_str_hash(). GLib's g_str_hash() uses djb2 hashing function, just like we do at the moment. The only difference is, that we use a diffrent seed value. Note, that we initialize the hash seed with random data (by calling getrandom() or reading /dev/urandom). That is a change compared to before. This change of the hashing function and accessing the random pool might be undesired for libnm/libnm-core. Hence, the change is not done there as it possibly changes behavior for public API. Maybe we should do that later though. At this point, there isn't much of a change. This patch becomes interesting, if we decide to use a different hashing algorithm.
* config: add an API to disable connectivity check via internal config file.James Henstridge2017-08-171-1/+22
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=785117
* device: handle default for unset ignore-carrier option depending on deviceThomas Haller2017-06-221-2/+9
| | | | | | | | | Currently, device types like Bond hack around ignore-carrier setting, as they always want to ignore-carrier. Prepare so that also for such master types, we rely and honor the ignore-carrier setting better. In the next commit, bond, bridge and team devices they will get ignore-carrier turned on by default.
* logging: log device and connection along with the messageLubomir Rintel2017-03-241-1/+1
|
* all/trivial: unify construct-only property commentsThomas Haller2017-03-081-1/+5
| | | | | | | Unify marking GObject properties that are G_PARAM_CONSTRUCT_ONLY with a comment /* construct-only */
* core: use define for atomic-section-prefix setting for NMConfigThomas Haller2017-02-171-1/+1
| | | | | | | | | main() should pass the same atomic-section-prefix setting to it's NMConfig instances. Currently both are NULL, but make it a define to make this explicit. Also, make static array @default_values const and sanitize value when setting PROP_ATOMIC_SECTION_PREFIXES property.
* build: fix -Wignored-qualifiers warningsThomas Haller2017-02-061-1/+1
| | | | | | ./src/nm-config-data.h:163:1: error: 'const' type qualifier on return type has no effect [-Werror,-Wignored-qualifiers] const guint nm_config_data_get_connectivity_interval (const NMConfigData *config_data); ^~~~~~
* all: use nm_utils_strv_find_first() from shared/nm-utilsThomas Haller2017-02-041-1/+1
|
* config: drop nm_config_get_dhcp_client() and access config directlyThomas Haller2016-11-251-1/+1
| | | | | | | | | | | | Also, ifnet plugin would read the configuration value, which is just wrong because: - the configuration might not be set and ifnet would fail to fallback to the compile time default. - the configuration only is in effect if the plugin is also available. Otherwise, we fallback to the next plugin. Only the dhcp-manager knows which DHCP plugin is in use.
* config: drop nm_config_get_auth_polkit() and access value directlyThomas Haller2016-11-251-6/+6
|
* config/trivial: unify name of compile time config defaultsThomas Haller2016-11-251-6/+6
|
* config: optionally let nm_config_get_plugins() return compile time defaultThomas Haller2016-11-251-0/+21
| | | | | | | | | | | Instead of having the caller do the fallback to the compile time default plugins, let it be handled by nm_config_get_plugins(). The knowledge of fallback to a compile time default (and how to do that properly) should be inside NMConfig/NMConfigData alone. Also, as this function is only called once, let NMConfig not cache the string list but create it once as needed.
* build: don't add subdirectories to include search path but require qualified ↵Thomas Haller2016-11-211-1/+1
| | | | | | | | | | | | | | | include Keep the include paths clean and separate. We use directories to group source files together. That makes sense (I guess), but then we should use this grouping also when including files. Thus require to #include files with their path relative to "src/". Also, we build various artifacts from the "src/" tree. Instead of having individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be unified. Previously, the CFLAGS for each artifact differ and are inconsistent in which paths they add to the search path. Fix the inconsistency by just don't add the paths at all.
* config: print default value of main.dhcp with --print-configThomas Haller2016-11-031-0/+1
|
* config: fix printing default values for missing sectionsThomas Haller2016-10-111-15/+41
| | | | | | | | Previously, the default values were only printed if the corresponding section was already present. Fix that. Also, we call nm_config_data_log() also to dump the configuration into the logfile. In that case (!stream), exclude the default values.
* config: print default value for logging.auditThomas Haller2016-10-111-0/+1
|
* config: add default values to 'NM --print-config' outputBeniamino Galvani2016-10-041-1/+21
| | | | | | | | | | | | | | | | | | | | | There isn't an easy way to determine the effective value of some configuration options as their default value can be set at build time; the user has to search in logs or look at the manual page when available. This adds those default values that can be changed at build time to the output of 'NetworkManager --print-config': [main] # plugins=ifcfg-rh,ifupdown,ifnet,ibft # rc-manager=symlink # auth-polkit=true dns=dnsmasq ... [logging] # backend=journal ...
* core: refactor private data in "src"Thomas Haller2016-10-041-117/+112
| | | | | | | | | | | | | | | | - use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere. - reorder statements, to have GObject related functions (init, dispose, constructed) at the bottom of each file and in a consistent order w.r.t. each other. - unify whitespaces in signal and properties declarations. - use NM_GOBJECT_PROPERTIES_DEFINE() and _notify() - drop unused signal slots in class structures - drop unused header files for device factories
* all: modify line separator comments to be 80 chars wideThomas Haller2016-10-031-9/+9
| | | | sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
* config: make "ignore-carrier" a per-device configuration optionThomas Haller2016-06-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetworkManager.conf already contains several per-device settings, that is, settings that have a device-spec as argument. main.ignore-carrier main.no-auto-default main.assume-ipv6ll-only keyfile.unmanged-devices Optimally, these settings should be moved to the new [device*] section. For now, only move main.ignore-carrier there. For the others it may not make sense to do so: - main.no-auto-default: is already merged with internal state from /var/lib/NetworkManager/no-auto-default.state. While NMConfig's write API would be fine to also persist and merge the no-auto-default setting, we'd still have to read the old file too. Thus, deprecating this setting gets quite cumbersome to still handle the old state file. Also, it seems a less useful setting to configure in the global configuration aside setting main.no-auto-default=*. - main.assume-ipv6ll-only: one day, I hope that we no longer assume connections at all, and this setting becomes entirely obsolete. - keyfile.unmanged-devices: this sets NM_UNMANAGED_USER_SETTINGS, which cannot be overruled via D-Bus. For a future device.managed setting we want it it to be overwritable via D-Bus by an explicit user action. Thus, a device.managed property should have a different semantic, this should be more like a device.unmanaged-force setting, which could be done.
* config: add support for per-device configuration to NetworkManager.confThomas Haller2016-06-301-47/+147
| | | | | | | | | | | | | | | | | | | | | | Add a new [device*] section to NetworkManager.conf. This works similar like the default connection settings in [connection*]. This will allow us to express per-device configuration in NetworkManager.conf in our familar style. Later, via NMConfig's write API it will be possible to make settings accessible via D-Bus and persist them in NetworkManager-intern.conf. This way, the user can both edit configuration snippets and modify them via D-Bus, and also support installing default configuration from the package. In a way, a [device*] setting is similar to networkd's link files. The match options is all encoded in the match-device specs. One difference is, that the resulting setting can be merged together by multiple section by partially overwriting them. This makes it more flexible and allows for example to drop a configuration snippet that only sets one property, while the rest can be merged from different snippets.
* config: refactor change-flags to be a cause/reason which triggered the changeThomas Haller2016-06-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | For the most part, this patch just renames some change-flags, but doesn't change much about them. The new name should better express what they are. A config-change signal can be emitted for different reasons: when we receive a signal (SIGHUP, SIGUSR1, SIGUSR2) or for internal reasons like resetting of no-auto-default or setting internal values. Depending on the reason, we want to perform different actions. For example: - we reload the configuration from disk on SIGHUP, but not for SIGUSR1. - For SIGUSR1 and SIGHUP, we want to update-dns, but not for SIGUSR2. Another part of the change-flags encodes which part of the configuration actually changed. Often, these parts can only change when re-reading from disk (e.g. a SIGUSR1 will not change any configuration inside NMConfig). Later, we will have more causes, and accordingly more fine-grained effects of what should be done on reload.
* libnm,core: fix syntax of 'transfer' annotationBeniamino Galvani2016-02-241-1/+1
|
* all: cleanup includes and let "nm-default.h" include "config.h"Thomas Haller2016-02-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - All internal source files (except "examples", which are not internal) should include "config.h" first. As also all internal source files should include "nm-default.h", let "config.h" be included by "nm-default.h" and include "nm-default.h" as first in every source file. We already wanted to include "nm-default.h" before other headers because it might contains some fixes (like "nm-glib.h" compatibility) that is required first. - After including "nm-default.h", we optinally allow for including the corresponding header file for the source file at hand. The idea is to ensure that each header file is self contained. - Don't include "config.h" or "nm-default.h" in any header file (except "nm-sd-adapt.h"). Public headers anyway must not include these headers, and internal headers are never included after "nm-default.h", as of the first previous point. - Include all internal headers with quotes instead of angle brackets. In practice it doesn't matter, because in our public headers we must include other headers with angle brackets. As we use our public headers also to compile our interal source files, effectively the result must be the same. Still do it for consistency. - Except for <config.h> itself. Include it with angle brackets as suggested by https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
* all/trivial: rename STRLEN() macro to NM_STRLEN()Thomas Haller2016-02-141-5/+5
| | | | | | | We should not have defines/macros in header files without a nm/NM prefix. STRLEN() was one of the few offenders. https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00048.html
* build: cleanup default includesThomas Haller2016-02-121-2/+1
| | | | | | | | | | | | | | | | | | | - "gsystem-local-alloc.h" and <gio/gio.h> are already included via "nm-default.h". No need to include them separately. - include "nm-macros-internal.h" via "nm-default.h" and drop all explict includes. - in the modified files, ensure that we always include "config.h" and "nm-default.h" first. As second, include the header file for the current source file (if applicable). Then follow external includes and finally internal nm includes. - include nm headers inside source code files with quotes - internal header files don't need to include default headers. They can savely assume that "nm-default.h" is already included and with it glib, nm-glib.h, nm-macros-internal.h, etc.
* main: add argument --print-config to NetworkManagerThomas Haller2015-11-221-7/+20
|
* config: drop global-dns.enable option in favor of .config.enableThomas Haller2015-10-051-1/+1
| | | | | | | | No longer support disabling the global-dns configuration via the "enable" option. Instead, the user can put the entire dns-configuration in one separate snippet, and disable it altogether with ".config.enable".
* config/trivial: rename nm_config_get_device_match_spec() to ↵Thomas Haller2015-10-051-7/+7
| | | | | | | nm_config_get_match_spec() We want to use the term match-spec more generally and not only for "device-specs".
* config: add missing include to "config.h" headerThomas Haller2015-10-051-0/+2
|
* nm-config: drop a glib 2.40-ismLubomir Rintel2015-10-011-1/+1
| | | | Fixes: ae9e82354a9c1b2247b7d071ed62acd9e83ae27b
* manager: export DNS global configuration D-Bus propertyBeniamino Galvani2015-10-011-0/+182
|
* dns: add support for global configuration in DNS managerBeniamino Galvani2015-10-011-0/+31
| | | | | | | Modify the DNS manager to use the static global DNS configuration when available. In addition, change DNS plugins interface to accept a new argument for global configuration and add support for this new parameter to the dnsmasq plugin.
* core: add support for reading global DNS configuration from keyfileBeniamino Galvani2015-10-011-0/+298
| | | | | | Add to the NMConfigData object information about global DNS configuration, which is loaded from user or internal keyfile upon object construction.
* all: make use of new header file "nm-default.h"Thomas Haller2015-08-051-2/+1
|
* config: add nm_config_data_get_value_cached() functionThomas Haller2015-07-141-0/+21
| | | | | | | nm_config_data_get_value() returns an allocated string. This is inconvenient for the caller. Add a utility function nm_config_data_get_value_cached() that caches the returned value. Of course, use with care as the returned string will be invalidated by each call to nm_config_data_get_value_cached().
* config: add write support to atomic-sectionsThomas Haller2015-07-021-4/+53
| | | | | | | | | | | | | | | | | | | We already support setting configuration values, either: (1) set any internal section, i.e. groups starting with [.intern*]. Those values don't ever interfere with that the user can configure. (2) set individual properties that overwrite user configuration. When doing that, we record the value from user configuration and on load, we reject our internal overwrite if the user configuration changed in the meantime. This is done by storing the values with ".set." and ".was." prefixes. Now add support for "atomic sections". In this case, certain groups can be marked as "atomic". When writing to such sections, we overwrite the entire user-provided setting. We also record the values from user configuration, and reject our internal value if we notice modifications. This basically extends (2) from individual properties to the entire section.
* config: add write support for NMConfigThomas Haller2015-07-021-12/+169
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* config/trivial: add code commentThomas Haller2015-07-021-0/+7
|
* config: add NMConfigGetValueFlags argument to nm_config_data_get_value()Thomas Haller2015-07-021-8/+4
| | | | | | | | | | | | In some cases we want the returned value to be stripped. In some cases, we want to read the raw value instead of the string parsed by GKeyFile. Add an flags argument to nm_config_data_get_value(). It is up to the caller to determine the exact meaning (and whether to strip). By adding the flags argument, the caller can get the desired behavior easier without having to workaround it afterwards. But more importantly, it becomes apparent that there are different ways to retrieve the value and the caller should decide on the details.
* config: strip white space from configuration valuesThomas Haller2015-07-021-3/+3
| | | | | https://bugzilla.gnome.org/show_bug.cgi?id=750659 https://bugzilla.redhat.com/show_bug.cgi?id=1229861
* config: add config utility accessorsThomas Haller2015-07-021-0/+51
|
* config: fix usage of g_key_file_get_value() vs. g_key_file_get_string()Thomas Haller2015-07-021-19/+22
| | | | | | | | | | | | | | g_key_file_get_value() returns the raw value as stored in the file. When accessing a string value, in most cases it is correct to use g_key_file_get_string() instead. When working with internals, such as comparing two keyfiles for equality, g_key_file_get_value() is correct. When parsing booleans, we parse it based on the raw value. Fix the usages. This is a change in behavior if the config file contained unusual strings.
* config: log configuration at startup and on reloadThomas Haller2015-07-021-0/+89
|
* config: add defines for keyfile groups to "nm-config.h"Thomas Haller2015-07-021-10/+10
| | | | | | | | | | | | | | Some plugins had their local defines for the name of the sections and keys in NMConfig. Move those defines to "nm-config.h". Usually plugins make use of code in core, but not the other way round. Defining the names inside "nm-config.h" is no violation of that because the config section names are anyway not local to the plugin, but global in the shared name-space with other settings. For example, another plugins shouldn't reuse the section "ifnet". For that reason, it is correct and consistent to move these defines to "nm-config.h". We don't use those names in core, we merely signal their existance.
* config: add nm_config_data_get_value_boolean()Thomas Haller2015-07-021-0/+14
|
* config: get rid of @error argument to nm_config_data_get_value()Thomas Haller2015-07-021-2/+4
| | | | | We don't use this argument. A failure to retrieve a key is (for every practical purpose) the same as no such key.
* libnm: consider ordering for _nm_keyfile_equals()Thomas Haller2015-07-021-1/+1
| | | | | | GKeyFile considers the order of the files, so add a possibility to check whether to keyfiles are equal -- also with respect to the order of the elements.