ifcfg-rh: add helper to set unsupported error
The ifcfg-rh plugin is now deprecated and in bugfixes-only mode. When users try to set a property that is not supported by the plugin, we need to report an error. Add an helper function to set such error. Also, introduce a new error code so that the situation can be detected and dealt with programmatically.
This commit is contained in:
@@ -61,6 +61,24 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void _nm_unused
|
||||
set_error_unsupported(GError **error,
|
||||
NMConnection *connection,
|
||||
const char *name,
|
||||
gboolean is_setting)
|
||||
{
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN,
|
||||
"The ifcfg-rh plugin doesn't support %s '%s'. If you are modifying an existing "
|
||||
"connection profile saved in ifcfg-rh format, please migrate the connection to "
|
||||
"keyfile using 'nmcli connection migrate %s' or via the Update2() D-Bus API "
|
||||
"and try again.",
|
||||
is_setting ? "setting" : "property",
|
||||
name,
|
||||
nm_connection_get_uuid(connection));
|
||||
};
|
||||
|
||||
static void
|
||||
save_secret_flags(shvarFile *ifcfg, const char *key, NMSettingSecretFlags flags)
|
||||
{
|
||||
|
@@ -253,6 +253,9 @@ GQuark nm_secret_agent_error_quark(void);
|
||||
* @NM_SETTINGS_ERROR_VERSION_ID_MISMATCH: The profile's VersionId mismatched
|
||||
* and the update is rejected. See the "version-id" argument to Update2()
|
||||
* method. Since 1.44.
|
||||
* @NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN: the requested operation is not
|
||||
* supported by the settings plugin currently in use for the specified object.
|
||||
* Since: 1.44.
|
||||
*
|
||||
* Errors related to the settings/persistent configuration interface of
|
||||
* NetworkManager.
|
||||
@@ -262,15 +265,16 @@ GQuark nm_secret_agent_error_quark(void);
|
||||
* D-Bus errors in that namespace.
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTINGS_ERROR_FAILED = 0, /*< nick=Failed >*/
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
|
||||
NM_SETTINGS_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
|
||||
NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/
|
||||
NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/
|
||||
NM_SETTINGS_ERROR_INVALID_HOSTNAME, /*< nick=InvalidHostname >*/
|
||||
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, /*< nick=InvalidArguments >*/
|
||||
NM_SETTINGS_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/
|
||||
NM_SETTINGS_ERROR_FAILED = 0, /*< nick=Failed >*/
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED, /*< nick=PermissionDenied >*/
|
||||
NM_SETTINGS_ERROR_NOT_SUPPORTED, /*< nick=NotSupported >*/
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION, /*< nick=InvalidConnection >*/
|
||||
NM_SETTINGS_ERROR_READ_ONLY_CONNECTION, /*< nick=ReadOnlyConnection >*/
|
||||
NM_SETTINGS_ERROR_UUID_EXISTS, /*< nick=UuidExists >*/
|
||||
NM_SETTINGS_ERROR_INVALID_HOSTNAME, /*< nick=InvalidHostname >*/
|
||||
NM_SETTINGS_ERROR_INVALID_ARGUMENTS, /*< nick=InvalidArguments >*/
|
||||
NM_SETTINGS_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/
|
||||
NM_SETTINGS_ERROR_NOT_SUPPORTED_BY_PLUGIN, /*< nick=NotSupportedByPlugin >*/
|
||||
} NMSettingsError;
|
||||
|
||||
GQuark nm_settings_error_quark(void);
|
||||
|
Reference in New Issue
Block a user