diff options
Diffstat (limited to 'src/settings')
117 files changed, 5421 insertions, 7449 deletions
diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index 8d9252a5..ee1c6202 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -23,34 +23,85 @@ #include <string.h> #include <pwd.h> -#include <glib.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - +#include "nm-default.h" #include "nm-dbus-interface.h" -#include "nm-logging.h" #include "nm-agent-manager.h" #include "nm-secret-agent.h" #include "nm-auth-utils.h" -#include "nm-dbus-glib-types.h" -#include "nm-auth-utils.h" #include "nm-setting-vpn.h" -#include "nm-setting-connection.h" #include "nm-enum-types.h" #include "nm-auth-manager.h" -#include "nm-dbus-manager.h" +#include "nm-bus-manager.h" #include "nm-session-monitor.h" #include "nm-simple-connection.h" #include "NetworkManagerUtils.h" +#include "nm-core-internal.h" + +#include "nmdbus-agent-manager.h" + +NM_DEFINE_SINGLETON_INSTANCE (NMAgentManager); + +#define _NMLOG_PREFIX_NAME "agent-manager" +#define _NMLOG_DOMAIN LOGD_AGENTS +#define _NMLOG(level, agent, ...) \ + G_STMT_START { \ + if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ + char __prefix1[32]; \ + char __prefix2[128]; \ + NMSecretAgent *__agent = (agent); \ + \ + if (!(self)) \ + g_snprintf (__prefix1, sizeof (__prefix1), "%s%s", ""_NMLOG_PREFIX_NAME"", "[]"); \ + else if ((self) != singleton_instance) \ + g_snprintf (__prefix1, sizeof (__prefix1), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ + else \ + g_strlcpy (__prefix1, _NMLOG_PREFIX_NAME, sizeof (__prefix1)); \ + if (__agent) { \ + g_snprintf (__prefix2, sizeof (__prefix2), \ + ": req[%p, %s]", \ + __agent, \ + nm_secret_agent_get_description (__agent)); \ + } else \ + __prefix2[0] = '\0'; \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ + "%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + __prefix1, __prefix2 _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + } G_STMT_END + +#define LOG_REQ_FMT "[%p/%s%s%s%s%s%s]" +#define LOG_REQ_ARG(req) \ + (req), \ + NM_PRINT_FMT_QUOTE_STRING ((req)->detail), \ + NM_PRINT_FMT_QUOTED (((req)->request_type == REQUEST_TYPE_CON_GET) && (req)->con.get.setting_name, \ + "/\"", (req)->con.get.setting_name, "\"", \ + ((req)->request_type == REQUEST_TYPE_CON_GET ? "/(none)" : _request_type_to_string ((req)->request_type, FALSE))) + +typedef enum { + REQUEST_TYPE_INVALID, + REQUEST_TYPE_CON_GET, + REQUEST_TYPE_CON_SAVE, + REQUEST_TYPE_CON_DEL, +} RequestType; + +static const char * +_request_type_to_string (RequestType request_type, gboolean verbose) +{ + switch (request_type) { + case REQUEST_TYPE_CON_GET: return verbose ? "getting" : "get"; + case REQUEST_TYPE_CON_SAVE: return verbose ? "saving" : "sav"; + case REQUEST_TYPE_CON_DEL: return verbose ? "deleting" : "del"; + default: return "??"; + } +} -G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT) #define NM_AGENT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ NM_TYPE_AGENT_MANAGER, \ NMAgentManagerPrivate)) typedef struct { - NMDBusManager *dbus_mgr; NMAuthManager *auth_mgr; /* Auth chains for checking agent permissions */ @@ -72,7 +123,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -typedef struct _Request Request; +typedef struct _NMAgentManagerCallId Request; static void request_add_agent (Request *req, NMSecretAgent *agent); @@ -80,19 +131,11 @@ static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **p static void request_next_agent (Request *req); -static void impl_agent_manager_register (NMAgentManager *self, - const char *identifier, - DBusGMethodInvocation *context); - -static void impl_agent_manager_register_with_capabilities (NMAgentManager *self, - const char *identifier, - NMSecretAgentCapabilities capabilities, - DBusGMethodInvocation *context); +static void _con_get_request_start (Request *req); +static void _con_save_request_start (Request *req); +static void _con_del_request_start (Request *req); -static void impl_agent_manager_unregister (NMAgentManager *self, - DBusGMethodInvocation *context); - -#include "nm-agent-manager-glue.h" +static gboolean _con_get_try_complete_early (Request *req); /*************************************************************/ @@ -112,12 +155,11 @@ remove_agent (NMAgentManager *self, const char *owner) if (!agent) return FALSE; - nm_log_dbg (LOGD_AGENTS, "(%s) agent unregistered or disappeared", - nm_secret_agent_get_description (agent)); + _LOGD (agent, "agent unregistered or disappeared"); /* Remove this agent from any in-progress secrets requests */ g_hash_table_iter_init (&iter, priv->requests); - while (g_hash_table_iter_next (&iter, NULL, &data)) + while (g_hash_table_iter_next (&iter, &data, NULL)) request_remove_agent ((Request *) data, agent, &pending_reqs); /* We cannot call request_next_agent() from from within hash iterating loop, @@ -132,6 +174,17 @@ remove_agent (NMAgentManager *self, const char *owner) return TRUE; } +/* Call this *after* calling request_next_agent() */ +static void +maybe_remove_agent_on_error (NMSecretAgent *agent, + GError *error) +{ + if ( g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED) + || g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER)) + remove_agent (nm_agent_manager_get (), nm_secret_agent_get_dbus_owner (agent)); +} + /*************************************************************/ static gboolean @@ -192,7 +245,7 @@ validate_identifier (const char *identifier, GError **error) static void agent_register_permissions_done (NMAuthChain *chain, GError *error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, gpointer user_data) { NMAgentManager *self = NM_AGENT_MANAGER (user_data); @@ -213,8 +266,7 @@ agent_register_permissions_done (NMAuthChain *chain, NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, "Failed to request agent permissions: (%d) %s", error->code, error->message); - dbus_g_method_return_error (context, local); - g_error_free (local); + g_dbus_method_invocation_take_error (context, local); } else { agent = nm_auth_chain_steal_data (chain, "agent"); g_assert (agent); @@ -229,16 +281,15 @@ agent_register_permissions_done (NMAuthChain *chain, sender = nm_secret_agent_get_dbus_owner (agent); g_hash_table_insert (priv->agents, g_strdup (sender), agent); - nm_log_dbg (LOGD_AGENTS, "(%s) agent registered", - nm_secret_agent_get_description (agent)); - dbus_g_method_return (context); + _LOGD (agent, "agent registered"); + g_dbus_method_invocation_return_value (context, NULL); /* Signal an agent was registered */ g_signal_emit (self, signals[AGENT_REGISTERED], 0, agent); /* Add this agent to any in-progress secrets requests */ g_hash_table_iter_init (&iter, priv->requests); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &req)) + while (g_hash_table_iter_next (&iter, (gpointer) &req, NULL)) request_add_agent (req, agent); } @@ -264,15 +315,23 @@ find_agent_by_identifier_and_uid (NMAgentManager *self, } static void +agent_disconnected_cb (NMSecretAgent *agent, gpointer user_data) +{ + /* The agent quit, so remove it and let interested clients know */ + remove_agent (NM_AGENT_MANAGER (user_data), + nm_secret_agent_get_dbus_owner (agent)); +} + +static void impl_agent_manager_register_with_capabilities (NMAgentManager *self, + GDBusMethodInvocation *context, const char *identifier, - NMSecretAgentCapabilities capabilities, - DBusGMethodInvocation *context) + guint32 capabilities) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); NMAuthSubject *subject; gulong sender_uid = G_MAXULONG; - GError *error = NULL, *local = NULL; + GError *error = NULL; NMSecretAgent *agent; NMAuthChain *chain; @@ -285,17 +344,6 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, } sender_uid = nm_auth_subject_get_unix_process_uid (subject); - if ( 0 != sender_uid - && !nm_session_monitor_uid_has_session (nm_session_monitor_get (), - sender_uid, - NULL, - &local)) { - error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, - NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, - local && local->message ? local->message : "Session not found"); - goto done; - } - /* Validate the identifier */ if (!validate_identifier (identifier, &error)) goto done; @@ -316,9 +364,10 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, "Failed to initialize the agent"); goto done; } + g_signal_connect (agent, NM_SECRET_AGENT_DISCONNECTED, + G_CALLBACK (agent_disconnected_cb), self); - nm_log_dbg (LOGD_AGENTS, "(%s) requesting permissions", - nm_secret_agent_get_description (agent)); + _LOGD (agent, "requesting permissions"); /* Kick off permissions requests for this agent */ chain = nm_auth_chain_new_subject (subject, context, agent_register_permissions_done, self); @@ -337,33 +386,30 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self, done: if (error) - dbus_g_method_return_error (context, error); - g_clear_error (&error); - g_clear_error (&local); + g_dbus_method_invocation_take_error (context, error); g_clear_object (&subject); } static void impl_agent_manager_register (NMAgentManager *self, - const char *identifier, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + const char *identifier) { - impl_agent_manager_register_with_capabilities (self, identifier, 0, context); + impl_agent_manager_register_with_capabilities (self, context, identifier, 0); } static void impl_agent_manager_unregister (NMAgentManager *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { - NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); GError *error = NULL; char *sender = NULL; - if (!nm_dbus_manager_get_caller_info (priv->dbus_mgr, - context, - &sender, - NULL, - NULL)) { + if (!nm_bus_manager_get_caller_info (nm_bus_manager_get (), + context, + &sender, + NULL, + NULL)) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, "Unable to determine request sender."); @@ -378,137 +424,188 @@ impl_agent_manager_unregister (NMAgentManager *self, goto done; } - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (context, NULL); done: if (error) - dbus_g_method_return_error (context, error); - g_clear_error (&error); + g_dbus_method_invocation_take_error (context, error); g_free (sender); } /*************************************************************/ -typedef void (*RequestCompleteFunc) (Request *req, - GHashTable *secrets, - const char *agent_dbus_owner, - const char *agent_username, - GError *error, - gpointer user_data); -typedef gboolean (*RequestAddAgentFunc) (Request *req, NMSecretAgent *agent); -typedef void (*RequestNextFunc) (Request *req); -typedef void (*RequestCancelFunc) (Request *req); - -/* Basic secrets request structure */ -struct _Request { - guint32 reqid; +struct _NMAgentManagerCallId { + NMAgentManager *self; + + RequestType request_type; + char *detail; - char *verb; NMAuthSubject *subject; /* Current agent being asked for secrets */ NMSecretAgent *current; - gconstpointer current_call_id; + NMSecretAgentCallId current_call_id; /* Stores the sorted list of NMSecretAgents which will be asked for secrets */ GSList *pending; - /* Stores the list of NMSecretAgent hashes that we've already - * asked for secrets, so that we don't ask the same agent twice - * if it quits and re-registers during this secrets request. - */ - GSList *asked; + guint idle_id; - NMAuthChain *chain; + union { + struct { + char *path; + NMConnection *connection; - guint32 idle_id; + NMAuthChain *chain; - RequestAddAgentFunc add_agent_callback; - RequestCancelFunc cancel_callback; - RequestNextFunc next_callback; - RequestCompleteFunc complete_callback; - gpointer complete_callback_data; - gboolean completed; + /* Whether the agent currently being asked for secrets + * has the system.modify privilege. + */ + gboolean current_has_modify; - GDestroyNotify free_func; -}; + union { + struct { + NMSecretAgentGetSecretsFlags flags; + char *setting_name; + char **hints; -static guint32 next_req_id = 1; + GVariant *existing_secrets; + + NMAgentSecretsResultFunc callback; + gpointer callback_data; + } get; + }; + } con; + }; +}; static Request * -request_new (gsize struct_size, +request_new (NMAgentManager *self, + RequestType request_type, const char *detail, - const char *verb, - NMAuthSubject *subject, - RequestCompleteFunc complete_callback, - gpointer complete_callback_data, - RequestAddAgentFunc add_agent_callback, - RequestNextFunc next_callback, - RequestCancelFunc cancel_callback, - GDestroyNotify free_func) + NMAuthSubject *subject) { Request *req; - req = g_malloc0 (struct_size); - req->reqid = next_req_id++; + req = g_slice_new0 (Request); + req->self = g_object_ref (self); + req->request_type = request_type; req->detail = g_strdup (detail); - req->verb = g_strdup (verb); req->subject = g_object_ref (subject); - req->complete_callback = complete_callback; - req->complete_callback_data = complete_callback_data; - req->add_agent_callback = add_agent_callback, - req->next_callback = next_callback; - req->cancel_callback = cancel_callback; - req->free_func = free_func; return req; } static void request_free (Request *req) { - if (req->free_func) - req->free_func ((gpointer) req); + switch (req->request_type) { + case REQUEST_TYPE_CON_GET: + case REQUEST_TYPE_CON_SAVE: + case REQUEST_TYPE_CON_DEL: + g_object_unref (req->con.connection); + g_free (req->con.path); + if (req->con.chain) + nm_auth_chain_unref (req->con.chain); + if (req->request_type == REQUEST_TYPE_CON_GET) { + g_free (req->con.get.setting_name); + g_strfreev (req->con.get.hints); + if (req->con.get.existing_secrets) + g_variant_unref (req->con.get.existing_secrets); + } + break; + default: + g_assert_not_reached (); + } if (req->idle_id) g_source_remove (req->idle_id); - if (!req->completed && req->cancel_callback) - req->cancel_callback (req); - - if (req->chain) - nm_auth_chain_unref (req->chain); + if (req->current && req->current_call_id) { + /* cancel-secrets invokes the done-callback synchronously -- in which case + * the handler just return. + * Hence, we can proceed to free @req... */ + nm_secret_agent_cancel_secrets (req->current, req->current_call_id); + } g_object_unref (req->subject); g_free (req->detail); - g_free (req->verb); g_slist_free_full (req->pending, g_object_unref); - g_slist_free (req->asked); + + g_object_unref (req->self); + + if (req->current) + g_object_unref (req->current); + memset (req, 0, sizeof (Request)); - g_free (req); + g_slice_free (Request, req); } static void -req_complete_success (Request *req, - GHashTable *secrets, +req_complete_release (Request *req, + GVariant *secrets, const char *agent_dbus_owner, - const char *agent_uname) + const char *agent_username, + GError *error) +{ + NMAgentManager *self = req->self; + + switch (req->request_type) { + case REQUEST_TYPE_CON_GET: + req->con.get.callback (self, + req, + agent_dbus_owner, + agent_username, + req->con.current_has_modify, + req->con.get.setting_name, + req->con.get.flags, + error ? NULL : secrets, + error, + req->con.get.callback_data); + + break; + case REQUEST_TYPE_CON_SAVE: + case REQUEST_TYPE_CON_DEL: + break; + default: + g_return_if_reached (); + } + + request_free (req); +} + +static void +req_complete_cancel (Request *req, gboolean is_disposing) +{ + gs_free_error GError *error = NULL; + + nm_assert (req && req->self); + nm_assert (!g_hash_table_contains (NM_AGENT_MANAGER_GET_PRIVATE (req->self)->requests, req)); + + nm_utils_error_set_cancelled (&error, is_disposing, "NMAgentManager"); + req_complete_release (req, NULL, NULL, NULL, error); +} + +static void +req_complete (Request *req, + GVariant *secrets, + const char *agent_dbus_owner, + const char *agent_username, + GError *error) { - req->completed = TRUE; - req->complete_callback (req, - secrets, - agent_dbus_owner, - agent_uname, - NULL, - req->complete_callback_data); + NMAgentManager *self = req->self; + NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); + + if (!g_hash_table_remove (priv->requests, req)) + g_return_if_reached (); + req_complete_release (req, secrets, agent_dbus_owner, agent_username, error); } static void req_complete_error (Request *req, GError *error) { - req->completed = TRUE; - req->complete_callback (req, NULL, NULL, NULL, error, req->complete_callback_data); + req_complete (req, NULL, NULL, NULL, error); } static gint @@ -535,12 +632,8 @@ agent_compare_func (gconstpointer aa, gconstpointer bb, gpointer user_data) } /* Prefer agents in active sessions */ - a_active = nm_session_monitor_uid_active (nm_session_monitor_get (), - nm_secret_agent_get_owner_uid (a), - NULL); - b_active = nm_session_monitor_uid_active (nm_session_monitor_get (), - nm_secret_agent_get_owner_uid (b), - NULL); + a_active = nm_session_monitor_session_exists (nm_session_monitor_get (), nm_secret_agent_get_owner_uid (a), TRUE); + b_active = nm_session_monitor_session_exists (nm_session_monitor_get (), nm_secret_agent_get_owner_uid (b), TRUE); if (a_active && !b_active) return -1; else if (a_active == b_active) @@ -554,14 +647,26 @@ agent_compare_func (gconstpointer aa, gconstpointer bb, gpointer user_data) static void request_add_agent (Request *req, NMSecretAgent *agent) { + NMAgentManager *self; + g_return_if_fail (req != NULL); g_return_if_fail (agent != NULL); - if (g_slist_find (req->asked, GUINT_TO_POINTER (nm_secret_agent_get_hash (agent)))) - return; + self = req->self; - if (req->add_agent_callback && !req->add_agent_callback (req, agent)) - return; + if (req->request_type == REQUEST_TYPE_CON_GET) { + NMAuthSubject *subject = nm_secret_agent_get_subject (agent); + + /* Ensure the caller's username exists in the connection's permissions, + * or that the permissions is empty (ie, visible by everyone). + */ + if (!nm_auth_is_subject_in_acl (req->con.connection, subject, NULL)) { + _LOGD (agent, "agent ignored for secrets request "LOG_REQ_FMT" (not in ACL)", + LOG_REQ_ARG (req)); + /* Connection not visible to this agent's user */ + return; + } + } /* If the request should filter agents by UID, do that now */ if (nm_auth_subject_is_unix_process (req->subject)) { @@ -570,18 +675,16 @@ request_add_agent (Request *req, NMSecretAgent *agent) agent_uid = nm_secret_agent_get_owner_uid (agent); subject_uid = nm_auth_subject_get_unix_process_uid (req->subject); if (agent_uid != subject_uid) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent ignored for secrets request %p/%s " - "(uid %ld not required %ld)", - nm_secret_agent_get_description (agent), - req, req->detail, - (long)agent_uid, (long)subject_uid); + _LOGD (agent, "agent ignored for secrets request "LOG_REQ_FMT" " + "(uid %ld not required %ld)", + LOG_REQ_ARG (req), + (long) agent_uid, (long) subject_uid); return; } } - nm_log_dbg (LOGD_AGENTS, "(%s) agent allowed for secrets request %p/%s", - nm_secret_agent_get_description (agent), - req, req->detail); + _LOGD (agent, "agent allowed for secrets request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); /* Add this agent to the list, sorted appropriately */ req->pending = g_slist_insert_sorted_with_data (req->pending, @@ -605,25 +708,41 @@ request_add_agents (NMAgentManager *self, Request *req) static void request_next_agent (Request *req) { + NMAgentManager *self; GError *error = NULL; - req->current_call_id = NULL; - if (req->current) - g_object_unref (req->current); + self = req->self; + + if (req->current) { + if (req->current_call_id) + nm_secret_agent_cancel_secrets (req->current, req->current_call_id); + g_clear_object (&req->current); + } + g_warn_if_fail (!req->current_call_id); if (req->pending) { /* Send the request to the next agent */ req->current = req->pending->data; req->pending = g_slist_remove (req->pending, req->current); - nm_log_dbg (LOGD_AGENTS, "(%s) agent %s secrets for request %p/%s", - nm_secret_agent_get_description (req->current), - req->verb, req, req->detail); - - req->next_callback (req); + _LOGD (req->current, "agent %s secrets for request "LOG_REQ_FMT, + _request_type_to_string (req->request_type, TRUE), + LOG_REQ_ARG (req)); + + switch (req->request_type) { + case REQUEST_TYPE_CON_GET: + _con_get_request_start (req); + break; + case REQUEST_TYPE_CON_SAVE: + _con_save_request_start (req); + break; + case REQUEST_TYPE_CON_DEL: + _con_del_request_start (req); + break; + default: + g_assert_not_reached (); + } } else { - req->current = NULL; - /* No more secret agents are available to fulfill this secrets request */ error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS, @@ -636,25 +755,41 @@ request_next_agent (Request *req) static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **pending_reqs) { + NMAgentManager *self; + g_return_if_fail (req != NULL); g_return_if_fail (agent != NULL); - req->pending = g_slist_remove (req->pending, agent); + self = req->self; if (agent == req->current) { - nm_log_dbg (LOGD_AGENTS, "(%s) current agent removed from secrets request %p/%s", - nm_secret_agent_get_description (agent), req, req->detail); - - if (req->chain) { - /* This cancels the pending authorization requests. */ - nm_auth_chain_unref (req->chain); - req->chain = NULL; + nm_assert (!g_slist_find (req->pending, agent)); + + _LOGD (agent, "current agent removed from secrets request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); + + switch (req->request_type) { + case REQUEST_TYPE_CON_GET: + case REQUEST_TYPE_CON_SAVE: + case REQUEST_TYPE_CON_DEL: + if (req->con.chain) { + /* This cancels the pending authorization requests. */ + nm_auth_chain_unref (req->con.chain); + req->con.chain = NULL; + } + break; + default: + g_assert_not_reached (); } *pending_reqs = g_slist_prepend (*pending_reqs, req); - } else { - nm_log_dbg (LOGD_AGENTS, "(%s) agent removed from secrets request %p/%s", - nm_secret_agent_get_description (agent), req, req->detail); + } else if (g_slist_find (req->pending, agent)) { + req->pending = g_slist_remove (req->pending, agent); + + _LOGD (agent, "agent removed from secrets request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); + + g_object_unref (agent); } } @@ -664,190 +799,87 @@ request_start (gpointer user_data) Request *req = user_data; req->idle_id = 0; - request_next_agent (req); - return FALSE; -} - -/*************************************************************/ - -/* Request subclass for connection secrets */ -typedef struct { - Request parent; - - NMSecretAgentGetSecretsFlags flags; - NMConnection *connection; - char *setting_name; - char **hints; - - GHashTable *existing_secrets; - NMAgentSecretsResultFunc callback; - gpointer callback_data; - gpointer other_data2; - gpointer other_data3; - - /* Whether the agent currently being asked for secrets - * has the system.modify privilege. - */ - gboolean current_has_modify; -} ConnectionRequest; - -static void -connection_request_free (gpointer data) -{ - ConnectionRequest *req = data; - - g_object_unref (req->connection); - g_free (req->setting_name); - g_strfreev (req->hints); - if (req->existing_secrets) - g_hash_table_unref (req->existing_secrets); -} - -static gboolean -connection_request_add_agent (Request *parent, NMSecretAgent *agent) -{ - ConnectionRequest *req = (ConnectionRequest *) parent; - NMAuthSubject *subject = nm_secret_agent_get_subject(agent); - - /* Ensure the caller's username exists in the connection's permissions, - * or that the permissions is empty (ie, visible by everyone). - */ - if (!nm_auth_is_subject_in_acl (req->connection, nm_session_monitor_get (), subject, NULL)) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent ignored for secrets request %p/%s (not in ACL)", - nm_secret_agent_get_description (agent), - parent, parent->detail); - /* Connection not visible to this agent's user */ - return FALSE; + switch (req->request_type) { + case REQUEST_TYPE_CON_GET: + if (_con_get_try_complete_early (req)) + goto out; + break; + default: + break; } + request_next_agent (req); - return TRUE; -} - -static ConnectionRequest * -connection_request_new_get (NMConnection *connection, - NMAuthSubject *subject, - GHashTable *existing_secrets, - const char *setting_name, - const char *verb, - NMSecretAgentGetSecretsFlags flags, - const char **hints, - NMAgentSecretsResultFunc callback, - gpointer callback_data, - gpointer other_data2, - gpointer other_data3, - RequestCompleteFunc complete_callback, - gpointer complete_callback_data, - RequestNextFunc next_callback, - RequestCancelFunc cancel_callback) -{ - ConnectionRequest *req; - - req = (ConnectionRequest *) request_new (sizeof (ConnectionRequest), - nm_connection_get_id (connection), - verb, - subject, - complete_callback, - complete_callback_data, - connection_request_add_agent, - next_callback, - cancel_callback, - connection_request_free); - g_assert (req); - - req->connection = g_object_ref (connection); - if (existing_secrets) - req->existing_secrets = g_hash_table_ref (existing_secrets); - req->setting_name = g_strdup (setting_name); - req->hints = g_strdupv ((char **) hints); - req->flags = flags; - req->callback = callback; - req->callback_data = callback_data; - req->other_data2 = other_data2; - req->other_data3 = other_data3; - return req; +out: + return FALSE; } -static ConnectionRequest * -connection_request_new_other (NMConnection *connection, - NMAuthSubject *subject, - const char *verb, - RequestCompleteFunc complete_callback, - gpointer complete_callback_data, - RequestNextFunc next_callback) -{ - ConnectionRequest *req; - - req = (ConnectionRequest *) request_new (sizeof (ConnectionRequest), - nm_connection_get_id (connection), - verb, - subject, - complete_callback, - complete_callback_data, - NULL, - next_callback, - NULL, - connection_request_free); - g_assert (req); - req->connection = g_object_ref (connection); - return req; -} +/*************************************************************/ static void -get_done_cb (NMSecretAgent *agent, - gconstpointer call_id, - GHashTable *secrets, - GError *error, - gpointer user_data) +_con_get_request_done (NMSecretAgent *agent, + NMSecretAgentCallId call_id, + GVariant *secrets, + GError *error, + gpointer user_data) { - Request *parent = user_data; - ConnectionRequest *req = user_data; - GHashTable *setting_secrets; + NMAgentManager *self; + Request *req = user_data; + GVariant *setting_secrets; const char *agent_dbus_owner; struct passwd *pw; char *agent_uname = NULL; - g_return_if_fail (call_id == parent->current_call_id); + g_return_if_fail (call_id == req->current_call_id); + g_return_if_fail (agent == req->current); + g_return_if_fail (req->request_type == REQUEST_TYPE_CON_GET); + + self = req->self; + + req->current_call_id = NULL; if (error) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent failed secrets request %p/%s/%s: (%d) %s", - nm_secret_agent_get_description (agent), - req, parent->detail, req->setting_name, - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + _LOGD (agent, "get secrets request cancelled: "LOG_REQ_FMT, + LOG_REQ_ARG (req)); + return; + } - if (dbus_g_error_has_name (error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) { + _LOGD (agent, "agent failed secrets request "LOG_REQ_FMT": %s", + LOG_REQ_ARG (req), + error->message); + + if (g_error_matches (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_USER_CANCELED)) { error = g_error_new_literal (NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_USER_CANCELED, "User canceled the secrets request."); - req_complete_error (parent, error); + req_complete_error (req, error); g_error_free (error); } else { - if (parent->current_call_id) { + if (req->current_call_id) { /* Tell the failed agent we're no longer interested. */ - nm_secret_agent_cancel_secrets (parent->current, parent->current_call_id); + nm_secret_agent_cancel_secrets (req->current, req->current_call_id); } /* Try the next agent */ - request_next_agent (parent); + request_next_agent (req); + maybe_remove_agent_on_error (agent, error); } return; } /* Ensure the setting we wanted secrets for got returned and has something in it */ - setting_secrets = g_hash_table_lookup (secrets, req->setting_name); - if (!setting_secrets || !g_hash_table_size (setting_secrets)) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent returned no secrets for request %p/%s/%s", - nm_secret_agent_get_description (agent), - req, parent->detail, req->setting_name); + setting_secrets = g_variant_lookup_value (secrets, req->con.get.setting_name, NM_VARIANT_TYPE_SETTING); + if (!setting_secrets || !g_variant_n_children (setting_secrets)) { + _LOGD (agent, "agent returned no secrets for request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); /* Try the next agent */ - request_next_agent (parent); + request_next_agent (req); return; } - nm_log_dbg (LOGD_AGENTS, "(%s) agent returned secrets for request %p/%s/%s", - nm_secret_agent_get_description (agent), - req, parent->detail, req->setting_name); + _LOGD (agent, "agent returned secrets for request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); /* Get the agent's username */ pw = getpwuid (nm_secret_agent_get_owner_uid (agent)); @@ -858,110 +890,109 @@ get_done_cb (NMSecretAgent *agent, } agent_dbus_owner = nm_secret_agent_get_dbus_owner (agent); - req_complete_success (parent, secrets, agent_dbus_owner, agent_uname); + req_complete (req, secrets, agent_dbus_owner, agent_uname, NULL); g_free (agent_uname); } static void -set_secrets_not_required (NMConnection *connection, GHashTable *hash) +set_secrets_not_required (NMConnection *connection, GVariant *dict) { - GHashTableIter iter, setting_iter; + GVariantIter iter, setting_iter; const char *setting_name = NULL; - GHashTable *setting_hash = NULL; + GVariant *setting_dict = NULL; - /* Iterate through the settings hashes */ - g_hash_table_iter_init (&iter, hash); - while (g_hash_table_iter_next (&iter, - (gpointer *) &setting_name, - (gpointer *) &setting_hash)) { + /* Iterate through the settings dicts */ + g_variant_iter_init (&iter, dict); + while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) { const char *key_name = NULL; NMSetting *setting; - GValue *val; + GVariant *val; setting = nm_connection_get_setting_by_name (connection, setting_name); if (setting) { /* Now through each secret in the setting and mark it as not required */ - g_hash_table_iter_init (&setting_iter, setting_hash); - while (g_hash_table_iter_next (&setting_iter, (gpointer *) &key_name, (gpointer *) &val)) { + g_variant_iter_init (&setting_iter, setting_dict); + while (g_variant_iter_next (&setting_iter, "{&sv}", &key_name, &val)) { /* For each secret, set the flag that it's not required; VPN * secrets need slightly different treatment here since the - * "secrets" property is actually a hash table of secrets. + * "secrets" property is actually a dictionary of secrets. */ if ( strcmp (setting_name, NM_SETTING_VPN_SETTING_NAME) == 0 - && strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0) { - GHashTableIter vpn_secret_iter; - const char *secret_name; + && strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0 + && g_variant_is_of_type (val, G_VARIANT_TYPE ("a{ss}"))) { + GVariantIter vpn_secret_iter; + const char *secret_name, *secret; - g_hash_table_iter_init (&vpn_secret_iter, g_value_get_boxed (val)); - while (g_hash_table_iter_next (&vpn_secret_iter, (gpointer *) &secret_name, NULL)) + g_variant_iter_init (&vpn_secret_iter, val); + while (g_variant_iter_next (&vpn_secret_iter, "{&s&s}", &secret_name, &secret)) nm_setting_set_secret_flags (setting, secret_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL); } else nm_setting_set_secret_flags (setting, key_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL); + g_variant_unref (val); } } } } static void -get_agent_request_secrets (ConnectionRequest *req, gboolean include_system_secrets) +_con_get_request_start_proceed (Request *req, gboolean include_system_secrets) { - Request *parent = (Request *) req; NMConnection *tmp; - tmp = nm_simple_connection_new_clone (req->connection); + g_return_if_fail (req->request_type == REQUEST_TYPE_CON_GET); + + tmp = nm_simple_connection_new_clone (req->con.connection); nm_connection_clear_secrets (tmp); if (include_system_secrets) { - if (req->existing_secrets) { - GVariant *secrets_dict; - - secrets_dict = nm_utils_connection_hash_to_dict (req->existing_secrets); - (void) nm_connection_update_secrets (tmp, req->setting_name, secrets_dict, NULL); - g_variant_unref (secrets_dict); - } + if (req->con.get.existing_secrets) + (void) nm_connection_update_secrets (tmp, req->con.get.setting_name, req->con.get.existing_secrets, NULL); } else { /* Update secret flags in the temporary connection to indicate that * the system secrets we're not sending to the agent aren't required, * so the agent can properly validate UI controls and such. */ - if (req->existing_secrets) - set_secrets_not_required (tmp, req->existing_secrets); + if (req->con.get.existing_secrets) + set_secrets_not_required (tmp, req->con.get.existing_secrets); } - parent->current_call_id = nm_secret_agent_get_secrets (parent->current, - tmp, - req->setting_name, - (const char **) req->hints, - req->flags, - get_done_cb, - req); - if (parent->current_call_id == NULL) { - /* Shouldn't hit this, but handle it anyway */ - g_warn_if_fail (parent->current_call_id != NULL); - request_next_agent (parent); + req->current_call_id = nm_secret_agent_get_secrets (req->current, + req->con.path, + tmp, + req->con.get.setting_name, + (const char **) req->con.get.hints, + req->con.get.flags, + _con_get_request_done, + req); + if (!req->current_call_id) { + g_warn_if_reached (); + request_next_agent (req); } g_object_unref (tmp); } static void -get_agent_modify_auth_cb (NMAuthChain *chain, - GError *error, - DBusGMethodInvocation *context, - gpointer user_data) +_con_get_request_start_validated (NMAuthChain *chain, + GError *error, + GDBusMethodInvocation *context, + gpointer user_data) { - Request *parent = user_data; - ConnectionRequest *req = user_data; + NMAgentManager *self; + Request *req = user_data; const char *perm; - parent->chain = NULL; + g_return_if_fail (req->request_type == REQUEST_TYPE_CON_GET); + + self = req->self; + + req->con.chain = NULL; if (error) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent %p/%s/%s MODIFY check error: (%d) %s", - nm_secret_agent_get_description (parent->current), - req, parent->detail, req->setting_name, - error->code, error->message ? error->message : "(unknown)"); + _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: (%d) %s", + LOG_REQ_ARG (req), + error->code, error->message ? error->message : "(unknown)"); /* Try the next agent */ - request_next_agent (parent); + request_next_agent (req); } else { /* If the agent obtained the 'modify' permission, we send all system secrets * to it. If it didn't, we still ask it for secrets, but we don't send @@ -970,25 +1001,24 @@ get_agent_modify_auth_cb (NMAuthChain *chain, perm = nm_auth_chain_get_data (chain, "perm"); g_assert (perm); if (nm_auth_chain_get_result (chain, perm) == NM_AUTH_CALL_RESULT_YES) - req->current_has_modify = TRUE; + req->con.current_has_modify = TRUE; - nm_log_dbg (LOGD_AGENTS, "(%s) agent %p/%s/%s MODIFY check result %s", - nm_secret_agent_get_description (parent->current), - req, parent->detail, req->setting_name, - req->current_has_modify ? "YES" : "NO"); + _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check result %s", + LOG_REQ_ARG (req), + req->con.current_has_modify ? "YES" : "NO"); - get_agent_request_secrets (req, req->current_has_modify); + _con_get_request_start_proceed (req, req->con.current_has_modify); } nm_auth_chain_unref (chain); } static void -check_system_secrets_cb (NMSetting *setting, - const char *key, - const GValue *value, - GParamFlags flags, - gpointer user_data) +has_system_secrets_check (NMSetting *setting, + const char *key, + const GValue *value, + GParamFlags flags, + gpointer user_data) { NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; gboolean *has_system = user_data; @@ -1022,20 +1052,22 @@ has_system_secrets (NMConnection *connection) { gboolean has_system = FALSE; - nm_connection_for_each_setting_value (connection, check_system_secrets_cb, &has_system); + nm_connection_for_each_setting_value (connection, has_system_secrets_check, &has_system); return has_system; } static void -get_next_cb (Request *parent) +_con_get_request_start (Request *req) { - ConnectionRequest *req = (ConnectionRequest *) parent; + NMAgentManager *self; NMSettingConnection *s_con; const char *agent_dbus_owner, *perm; - req->current_has_modify = FALSE; + self = req->self; + + req->con.current_has_modify = FALSE; - agent_dbus_owner = nm_secret_agent_get_dbus_owner (parent->current); + agent_dbus_owner = nm_secret_agent_get_dbus_owner (req->current); /* If the request flags allow user interaction, and there are existing * system secrets (or blank secrets that are supposed to be system-owned), @@ -1043,168 +1075,144 @@ get_next_cb (Request *parent) * secrets to the agent. We shouldn't leak system-owned secrets to * unprivileged users. */ - if ( (req->flags != NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) - && (req->existing_secrets || has_system_secrets (req->connection))) { - nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) request has system secrets; checking agent %s for MODIFY", - req, parent->detail, req->setting_name, agent_dbus_owner); + if ( (req->con.get.flags != NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) + && (req->con.get.existing_secrets || has_system_secrets (req->con.connection))) { + _LOGD (NULL, "("LOG_REQ_FMT") request has system secrets; checking agent %s for MODIFY", + LOG_REQ_ARG (req), agent_dbus_owner); - parent->chain = nm_auth_chain_new_subject (nm_secret_agent_get_subject (parent->current), - NULL, - get_agent_modify_auth_cb, - req); - g_assert (parent->chain); + req->con.chain = nm_auth_chain_new_subject (nm_secret_agent_get_subject (req->current), + NULL, + _con_get_request_start_validated, + req); + g_assert (req->con.chain); /* If the caller is the only user in the connection's permissions, then * we use the 'modify.own' permission instead of 'modify.system'. If the * request affects more than just the caller, require 'modify.system'. */ - s_con = nm_connection_get_setting_connection (req->connection); + s_con = nm_connection_get_setting_connection (req->con.connection); g_assert (s_con); if (nm_setting_connection_get_num_permissions (s_con) == 1) perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN; else perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM; - nm_auth_chain_set_data (parent->chain, "perm", (gpointer) perm, NULL); + nm_auth_chain_set_data (req->con.chain, "perm", (gpointer) perm, NULL); - nm_auth_chain_add_call (parent->chain, perm, TRUE); + nm_auth_chain_add_call (req->con.chain, perm, TRUE); } else { - nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) requesting user-owned secrets from agent %s", - req, parent->detail, req->setting_name, agent_dbus_owner); + _LOGD (NULL, "("LOG_REQ_FMT") requesting user-owned secrets from agent %s", + LOG_REQ_ARG (req), agent_dbus_owner); - get_agent_request_secrets (req, FALSE); + _con_get_request_start_proceed (req, FALSE); } } static gboolean -get_start (gpointer user_data) +_con_get_try_complete_early (Request *req) { - Request *parent = user_data; - ConnectionRequest *req = user_data; - GHashTable *setting_secrets = NULL; + NMAgentManager *self; + gs_unref_variant GVariant *setting_secrets = NULL; + gs_unref_object NMConnection *tmp = NULL; + GError *error = NULL; - parent->idle_id = 0; + self = req->self; /* Check if there are any existing secrets */ - if (req->existing_secrets) - setting_secrets = g_hash_table_lookup (req->existing_secrets, req->setting_name); - - if (setting_secrets && g_hash_table_size (setting_secrets)) { - NMConnection *tmp; - GError *error = NULL; - gboolean new_secrets = (req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW); - GVariant *secrets_dict; - - /* The connection already had secrets; check if any more are required. - * If no more are required, we're done. If secrets are still needed, - * ask a secret agent for more. This allows admins to provide generic - * secrets but allow additional user-specific ones as well. - */ - tmp = nm_simple_connection_new_clone (req->connection); - g_assert (tmp); + if (req->con.get.existing_secrets) + setting_secrets = g_variant_lookup_value (req->con.get.existing_secrets, req->con.get.setting_name, NM_VARIANT_TYPE_SETTING); - secrets_dict = nm_utils_connection_hash_to_dict (req->existing_secrets); - if (!nm_connection_update_secrets (tmp, req->setting_name, secrets_dict, &error)) { - req_complete_error (parent, error); - g_clear_error (&error); - } else { - /* Do we have everything we need? */ - if ( (req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM) - || ((nm_connection_need_secrets (tmp, NULL) == NULL) && (new_secrets == FALSE))) { - nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) system settings secrets sufficient", - req, parent->detail, req->setting_name); - - /* Got everything, we're done */ - req_complete_success (parent, req->existing_secrets, NULL, NULL); - } else { - nm_log_dbg (LOGD_AGENTS, "(%p/%s/%s) system settings secrets insufficient, asking agents", - req, parent->detail, req->setting_name); - - /* We don't, so ask some agents for additional secrets */ - if ( req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS - && !parent->pending) { - /* The request initiated from GetSecrets() via DBus, - * don't error out if any secrets are missing. */ - req_complete_success (parent, req->existing_secrets, NULL, NULL); - } else - request_next_agent (parent); - } - } - g_variant_unref (secrets_dict); - g_object_unref (tmp); - } else { - /* Couldn't get secrets from system settings, so now we ask the - * agents for secrets. Let the Agent Manager handle which agents - * we'll ask and in which order. - */ - request_next_agent (parent); - } + if (!setting_secrets || !g_variant_n_children (setting_secrets)) + return FALSE; - return FALSE; -} + /* The connection already had secrets; check if any more are required. + * If no more are required, we're done. If secrets are still needed, + * ask a secret agent for more. This allows admins to provide generic + * secrets but allow additional user-specific ones as well. + */ + tmp = nm_simple_connection_new_clone (req->con.connection); + g_assert (tmp); -static void -get_complete_cb (Request *parent, - GHashTable *secrets, - const char *agent_dbus_owner, - const char *agent_username, - GError *error, - gpointer user_data) -{ - NMAgentManager *self = NM_AGENT_MANAGER (user_data); - NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); - ConnectionRequest *req = (ConnectionRequest *) parent; - - /* Send secrets back to the requesting object */ - req->callback (self, - parent->reqid, - agent_dbus_owner, - agent_username, - req->current_has_modify, - req->setting_name, - req->flags, - error ? NULL : secrets, - error, - req->callback_data, - req->other_data2, - req->other_data3); - - g_hash_table_remove (priv->requests, GUINT_TO_POINTER (parent->reqid)); -} + if (!nm_connection_update_secrets (tmp, req->con.get.setting_name, req->con.get.existing_secrets, &error)) { + req_complete_error (req, error); + g_clear_error (&error); + return TRUE; + } + /* Do we have everything we need? */ + if ( NM_FLAGS_HAS (req->con.get.flags, NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM) + || ( (nm_connection_need_secrets (tmp, NULL) == NULL) + && !NM_FLAGS_HAS(req->con.get.flags, NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW))) { + _LOGD (NULL, "("LOG_REQ_FMT") system settings secrets sufficient", + LOG_REQ_ARG (req)); + + /* Got everything, we're done */ + req_complete (req, req->con.get.existing_secrets, NULL, NULL, NULL); + return TRUE; + } -static void -get_cancel_cb (Request *parent) -{ - ConnectionRequest *req = (ConnectionRequest *) parent; + _LOGD (NULL, "("LOG_REQ_FMT") system settings secrets insufficient, asking agents", + LOG_REQ_ARG (req)); + + /* We don't, so ask some agents for additional secrets */ + if ( req->con.get.flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS + && !req->pending) { + /* The request initiated from GetSecrets() via DBus, + * don't error out if any secrets are missing. */ + req_complete (req, req->con.get.existing_secrets, NULL, NULL, NULL); + return TRUE; + } - req->current_has_modify = FALSE; - if (parent->current && parent->current_call_id) - nm_secret_agent_cancel_secrets (parent->current, parent->current_call_id); + /* Couldn't get secrets from system settings, so now we ask the + * agents for secrets. Let the Agent Manager handle which agents + * we'll ask and in which order. + */ + return FALSE; } -guint32 +/** + * nm_agent_manager_get_secrets: + * @self: + * @path: + * @connection: + * @subject: + * @existing_secrets: + * @flags: + * @hints: + * @callback: + * @callback_data: + * + * Requests secrets for a connection. + * + * This function cannot fail. The callback will be invoked + * asynchrnously, but it will always be invoked exactly once. + * Even for cancellation and disposing of @self. In those latter + * cases, the callback is invoked synchrnously during the cancellation/ + * disposal. + * + * Returns: a call-id to cancel the call. + */ +NMAgentManagerCallId nm_agent_manager_get_secrets (NMAgentManager *self, + const char *path, NMConnection *connection, NMAuthSubject *subject, - GHashTable *existing_secrets, + GVariant *existing_secrets, const char *setting_name, NMSecretAgentGetSecretsFlags flags, const char **hints, NMAgentSecretsResultFunc callback, - gpointer callback_data, - gpointer other_data2, - gpointer other_data3) + gpointer callback_data) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); - Request *parent; - ConnectionRequest *req; + Request *req; - g_return_val_if_fail (self != NULL, 0); - g_return_val_if_fail (NM_IS_CONNECTION (connection), 0); - g_return_val_if_fail (callback != NULL, 0); + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (path && *path, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (callback != NULL, NULL); nm_log_dbg (LOGD_SETTINGS, "Secrets requested for connection %s (%s/%s)", - nm_connection_get_path (connection), + path, nm_connection_get_id (connection), setting_name); @@ -1213,224 +1221,221 @@ nm_agent_manager_get_secrets (NMAgentManager *self, * This in turn depends on nm_connection_to_dbus() and nm_setting_to_hash() * both returning NULL if they didn't hash anything. */ + req = request_new (self, + REQUEST_TYPE_CON_GET, + nm_connection_get_id (connection), + subject); + + req->con.path = g_strdup (path); + req->con.connection = g_object_ref (connection); + if (existing_secrets) + req->con.get.existing_secrets = g_variant_ref (existing_secrets); + req->con.get.setting_name = g_strdup (setting_name); + req->con.get.hints = g_strdupv ((char **) hints); + req->con.get.flags = flags; + req->con.get.callback = callback; + req->con.get.callback_data = callback_data; - req = connection_request_new_get (connection, - subject, - existing_secrets, - setting_name, - "getting", - flags, - hints, - callback, - callback_data, - other_data2, - other_data3, - get_complete_cb, - self, - get_next_cb, - get_cancel_cb); - parent = (Request *) req; - g_hash_table_insert (priv->requests, GUINT_TO_POINTER (parent->reqid), req); + if (!nm_g_hash_table_add (priv->requests, req)) + g_assert_not_reached (); /* Kick off the request */ - if (!(req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM)) - request_add_agents (self, parent); - parent->idle_id = g_idle_add (get_start, req); - return parent->reqid; + if (!(req->con.get.flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM)) + request_add_agents (self, req); + req->idle_id = g_idle_add (request_start, req); + return req; } void nm_agent_manager_cancel_secrets (NMAgentManager *self, - guint32 request_id) + NMAgentManagerCallId request_id) { g_return_if_fail (self != NULL); - g_return_if_fail (request_id > 0); + g_return_if_fail (request_id); + g_return_if_fail (request_id->request_type == REQUEST_TYPE_CON_GET); - g_hash_table_remove (NM_AGENT_MANAGER_GET_PRIVATE (self)->requests, - GUINT_TO_POINTER (request_id)); + if (!g_hash_table_remove (NM_AGENT_MANAGER_GET_PRIVATE (self)->requests, + request_id)) + g_return_if_reached (); + + req_complete_cancel (request_id, FALSE); } /*************************************************************/ static void -save_done_cb (NMSecretAgent *agent, - gconstpointer call_id, - GHashTable *secrets, - GError *error, - gpointer user_data) +_con_save_request_done (NMSecretAgent *agent, + NMSecretAgentCallId call_id, + GVariant *secrets, + GError *error, + gpointer user_data) { - Request *parent = user_data; - ConnectionRequest *req = user_data; + NMAgentManager *self; + Request *req = user_data; const char *agent_dbus_owner; - g_return_if_fail (call_id == parent->current_call_id); + g_return_if_fail (call_id == req->current_call_id); + g_return_if_fail (agent == req->current); + g_return_if_fail (req->request_type == REQUEST_TYPE_CON_SAVE); + + self = req->self; + + req->current_call_id = NULL; if (error) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent failed save secrets request %p/%s: (%d) %s", - nm_secret_agent_get_description (agent), - req, parent->detail, - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + _LOGD (agent, "save secrets request cancelled: "LOG_REQ_FMT, + LOG_REQ_ARG (req)); + return; + } + + _LOGD (agent, "agent failed save secrets request "LOG_REQ_FMT": %s", + LOG_REQ_ARG (req), error->message); /* Try the next agent */ - request_next_agent (parent); + request_next_agent (req); + maybe_remove_agent_on_error (agent, error); return; } - nm_log_dbg (LOGD_AGENTS, "(%s) agent saved secrets for request %p/%s", - nm_secret_agent_get_description (agent), - req, parent->detail); + _LOGD (agent, "agent saved secrets for request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); agent_dbus_owner = nm_secret_agent_get_dbus_owner (agent); - req_complete_success (parent, NULL, NULL, agent_dbus_owner); + req_complete (req, NULL, NULL, agent_dbus_owner, NULL); } static void -save_next_cb (Request *parent) +_con_save_request_start (Request *req) { - ConnectionRequest *req = (ConnectionRequest *) parent; - - parent->current_call_id = nm_secret_agent_save_secrets (parent->current, - req->connection, - save_done_cb, - req); - if (parent->current_call_id == NULL) { - /* Shouldn't hit this, but handle it anyway */ - g_warn_if_fail (parent->current_call_id != NULL); - request_next_agent (parent); + req->current_call_id = nm_secret_agent_save_secrets (req->current, + req->con.path, + req->con.connection, + _con_save_request_done, + req); + if (!req->current_call_id) { + g_warn_if_reached (); + request_next_agent (req); } } -static void -save_complete_cb (Request *req, - GHashTable *secrets, - const char *agent_dbus_owner, - const char *agent_username, - GError *error, - gpointer user_data) -{ - g_hash_table_remove (NM_AGENT_MANAGER_GET_PRIVATE (user_data)->requests, - GUINT_TO_POINTER (req->reqid)); -} - -guint32 +void nm_agent_manager_save_secrets (NMAgentManager *self, + const char *path, NMConnection *connection, NMAuthSubject *subject) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); - ConnectionRequest *req; - Request *parent; + Request *req; - g_return_val_if_fail (self != NULL, 0); - g_return_val_if_fail (NM_IS_CONNECTION (connection), 0); + g_return_if_fail (self); + g_return_if_fail (path && *path); + g_return_if_fail (NM_IS_CONNECTION (connection)); nm_log_dbg (LOGD_SETTINGS, "Saving secrets for connection %s (%s)", - nm_connection_get_path (connection), + path, nm_connection_get_id (connection)); - req = connection_request_new_other (connection, - subject, - "saving", - save_complete_cb, - self, - save_next_cb); - parent = (Request *) req; - g_hash_table_insert (priv->requests, GUINT_TO_POINTER (parent->reqid), req); + req = request_new (self, + REQUEST_TYPE_CON_SAVE, + nm_connection_get_id (connection), + subject); + req->con.path = g_strdup (path); + req->con.connection = g_object_ref (connection); + if (!nm_g_hash_table_add (priv->requests, req)) + g_assert_not_reached (); /* Kick off the request */ - request_add_agents (self, parent); - parent->idle_id = g_idle_add (request_start, req); - return parent->reqid; + request_add_agents (self, req); + req->idle_id = g_idle_add (request_start, req); } /*************************************************************/ static void -delete_done_cb (NMSecretAgent *agent, - gconstpointer call_id, - GHashTable *secrets, - GError *error, - gpointer user_data) +_con_del_request_done (NMSecretAgent *agent, + NMSecretAgentCallId call_id, + GVariant *secrets, + GError *error, + gpointer user_data) { + NMAgentManager *self; Request *req = user_data; g_return_if_fail (call_id == req->current_call_id); + g_return_if_fail (agent == req->current); + g_return_if_fail (req->request_type == REQUEST_TYPE_CON_DEL); + + self = req->self; + + req->current_call_id = NULL; if (error) { - nm_log_dbg (LOGD_AGENTS, "(%s) agent failed delete secrets request %p/%s: (%d) %s", - nm_secret_agent_get_description (agent), req, req->detail, - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + _LOGD (agent, "delete secrets request cancelled: "LOG_REQ_FMT, + LOG_REQ_ARG (req)); + return; + } + + _LOGD (agent, "agent failed delete secrets request "LOG_REQ_FMT": %s", + LOG_REQ_ARG (req), error->message); } else { - nm_log_dbg (LOGD_AGENTS, "(%s) agent deleted secrets for request %p/%s", - nm_secret_agent_get_description (agent), req, req->detail); + _LOGD (agent, "agent deleted secrets for request "LOG_REQ_FMT, + LOG_REQ_ARG (req)); } /* Tell the next agent to delete secrets */ request_next_agent (req); + if (error) + maybe_remove_agent_on_error (agent, error); } static void -delete_next_cb (Request *parent) +_con_del_request_start (Request *req) { - ConnectionRequest *req = (ConnectionRequest *) parent; - - parent->current_call_id = nm_secret_agent_delete_secrets (parent->current, - req->connection, - delete_done_cb, - req); - if (parent->current_call_id == NULL) { - /* Shouldn't hit this, but handle it anyway */ - g_warn_if_fail (parent->current_call_id != NULL); - request_next_agent (parent); + req->current_call_id = nm_secret_agent_delete_secrets (req->current, + req->con.path, + req->con.connection, + _con_del_request_done, + req); + if (!req->current_call_id) { + g_warn_if_reached (); + request_next_agent (req); } } -static void -delete_complete_cb (Request *req, - GHashTable *secrets, - const char *agent_dbus_owner, - const char *agent_username, - GError *error, - gpointer user_data) -{ - g_hash_table_remove (NM_AGENT_MANAGER_GET_PRIVATE (user_data)->requests, - GUINT_TO_POINTER (req->reqid)); -} - -guint32 +void nm_agent_manager_delete_secrets (NMAgentManager *self, + const char *path, NMConnection *connection) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); NMAuthSubject *subject; - ConnectionRequest *req; - Request *parent; + Request *req; - g_return_val_if_fail (self != NULL, 0); - g_return_val_if_fail (NM_IS_CONNECTION (connection), 0); + g_return_if_fail (self != NULL); + g_return_if_fail (path && *path); + g_return_if_fail (NM_IS_CONNECTION (connection)); nm_log_dbg (LOGD_SETTINGS, "Deleting secrets for connection %s (%s)", - nm_connection_get_path (connection), + path, nm_connection_get_id (connection)); subject = nm_auth_subject_new_internal (); - req = connection_request_new_other (connection, - subject, - "deleting", - delete_complete_cb, - self, - delete_next_cb); + req = request_new (self, + REQUEST_TYPE_CON_DEL, + nm_connection_get_id (connection), + subject); + req->con.path = g_strdup (path); + req->con.connection = g_object_ref (connection); g_object_unref (subject); - parent = (Request *) req; - g_hash_table_insert (priv->requests, GUINT_TO_POINTER (parent->reqid), req); + if (!nm_g_hash_table_add (priv->requests, req)) + g_assert_not_reached (); /* Kick off the request */ - request_add_agents (self, parent); - parent->idle_id = g_idle_add (request_start, req); - return parent->reqid; + request_add_agents (self, req); + req->idle_id = g_idle_add (request_start, req); } /*************************************************************/ @@ -1480,22 +1485,9 @@ nm_agent_manager_all_agents_have_capability (NMAgentManager *manager, /*************************************************************/ static void -name_owner_changed_cb (NMDBusManager *dbus_mgr, - const char *name, - const char *old_owner, - const char *new_owner, - gpointer user_data) -{ - if (old_owner) { - /* The agent quit, so remove it and let interested clients know */ - remove_agent (NM_AGENT_MANAGER (user_data), old_owner); - } -} - -static void agent_permissions_changed_done (NMAuthChain *chain, GError *error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, gpointer user_data) { NMAgentManager *self = NM_AGENT_MANAGER (user_data); @@ -1508,12 +1500,10 @@ agent_permissions_changed_done (NMAuthChain *chain, agent = nm_auth_chain_get_data (chain, "agent"); g_assert (agent); - if (error) { - nm_log_dbg (LOGD_AGENTS, "(%s) failed to request updated agent permissions", - nm_secret_agent_get_description (agent)); - } else { - nm_log_dbg (LOGD_AGENTS, "(%s) updated agent permissions", - nm_secret_agent_get_description (agent)); + if (error) + _LOGD (agent, "failed to request updated agent permissions"); + else { + _LOGD (agent, "updated agent permissions"); if (nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_WIFI_SHARE_PROTECTED) == NM_AUTH_CALL_RESULT_YES) share_protected = TRUE; @@ -1566,10 +1556,7 @@ nm_agent_manager_init (NMAgentManager *self) NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self); priv->agents = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - priv->requests = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - NULL, - (GDestroyNotify) request_free); + priv->requests = g_hash_table_new (g_direct_hash, g_direct_equal); } static void @@ -1579,20 +1566,16 @@ constructed (GObject *object) G_OBJECT_CLASS (nm_agent_manager_parent_class)->constructed (object); - priv->dbus_mgr = g_object_ref (nm_dbus_manager_get ()); priv->auth_mgr = g_object_ref (nm_auth_manager_get ()); - nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH_AGENT_MANAGER, object); - - g_signal_connect (priv->dbus_mgr, - NM_DBUS_MANAGER_NAME_OWNER_CHANGED, - G_CALLBACK (name_owner_changed_cb), - object); + nm_exported_object_export (NM_EXPORTED_OBJECT (object)); g_signal_connect (priv->auth_mgr, NM_AUTH_MANAGER_SIGNAL_CHANGED, G_CALLBACK (authority_changed_cb), object); + + NM_UTILS_KEEP_ALIVE (object, nm_session_monitor_get (), "NMAgentManager-depends-on-NMSessionMonitor"); } static void @@ -1600,6 +1583,21 @@ dispose (GObject *object) { NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (object); + if (priv->requests) { + GHashTableIter iter; + Request *req; + +cancel_more: + g_hash_table_iter_init (&iter, priv->requests); + if (g_hash_table_iter_next (&iter, (gpointer *) &req, NULL)) { + g_hash_table_iter_remove (&iter); + req_complete_cancel (req, TRUE); + goto cancel_more; + } + g_hash_table_unref (priv->requests); + priv->requests = NULL; + } + g_slist_free_full (priv->chains, (GDestroyNotify) nm_auth_chain_unref); priv->chains = NULL; @@ -1607,10 +1605,6 @@ dispose (GObject *object) g_hash_table_destroy (priv->agents); priv->agents = NULL; } - if (priv->requests) { - g_hash_table_destroy (priv->requests); - priv->requests = NULL; - } if (priv->auth_mgr) { g_signal_handlers_disconnect_by_func (priv->auth_mgr, @@ -1618,13 +1612,8 @@ dispose (GObject *object) object); g_clear_object (&priv->auth_mgr); } - if (priv->dbus_mgr) { - g_signal_handlers_disconnect_by_func (priv->dbus_mgr, - G_CALLBACK (name_owner_changed_cb), - object); - nm_dbus_manager_unregister_object (priv->dbus_mgr, object); - g_clear_object (&priv->dbus_mgr); - } + + nm_exported_object_unexport (NM_EXPORTED_OBJECT (object)); G_OBJECT_CLASS (nm_agent_manager_parent_class)->dispose (object); } @@ -1633,9 +1622,12 @@ static void nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class) { GObjectClass *object_class = G_OBJECT_CLASS (agent_manager_class); + NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (agent_manager_class); g_type_class_add_private (agent_manager_class, sizeof (NMAgentManagerPrivate)); + exported_object_class->export_path = NM_DBUS_PATH_AGENT_MANAGER; + /* virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; @@ -1651,10 +1643,10 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class) G_TYPE_NONE, 1, G_TYPE_OBJECT); - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (agent_manager_class), - &dbus_glib_nm_agent_manager_object_info); - - dbus_g_error_domain_register (NM_AGENT_MANAGER_ERROR, - NM_DBUS_INTERFACE_AGENT_MANAGER, - NM_TYPE_AGENT_MANAGER_ERROR); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (agent_manager_class), + NMDBUS_TYPE_AGENT_MANAGER_SKELETON, + "Register", impl_agent_manager_register, + "RegisterWithCapabilities", impl_agent_manager_register_with_capabilities, + "Unregister", impl_agent_manager_unregister, + NULL); } diff --git a/src/settings/nm-agent-manager.h b/src/settings/nm-agent-manager.h index ac29df22..2f505537 100644 --- a/src/settings/nm-agent-manager.h +++ b/src/settings/nm-agent-manager.h @@ -21,11 +21,10 @@ #ifndef __NETWORKMANAGER_AGENT_MANAGER_H__ #define __NETWORKMANAGER_AGENT_MANAGER_H__ -#include <glib.h> -#include <glib-object.h> #include <nm-connection.h> + +#include "nm-exported-object.h" #include "nm-secret-agent.h" -#include "nm-types.h" #define NM_TYPE_AGENT_MANAGER (nm_agent_manager_get_type ()) #define NM_AGENT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManager)) @@ -34,12 +33,15 @@ #define NM_IS_AGENT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AGENT_MANAGER)) #define NM_AGENT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AGENT_MANAGER, NMAgentManagerClass)) +struct _NMAgentManagerCallId; +typedef struct _NMAgentManagerCallId *NMAgentManagerCallId; + struct _NMAgentManager { - GObject parent; + NMExportedObject parent; }; typedef struct { - GObjectClass parent; + NMExportedObjectClass parent; /* Signals */ void (*agent_registered) (NMAgentManager *agent_mgr, NMSecretAgent *agent); @@ -51,39 +53,38 @@ NMAgentManager *nm_agent_manager_get (void); /* If no agent fulfilled the secrets request, agent_dbus_owner will be NULL */ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager, - guint32 call_id, + NMAgentManagerCallId call_id, const char *agent_dbus_owner, const char *agent_uname, gboolean agent_has_modify, const char *setting_name, NMSecretAgentGetSecretsFlags flags, - GHashTable *secrets, + GVariant *secrets, GError *error, - gpointer user_data, - gpointer other_data2, - gpointer other_data3); - -guint32 nm_agent_manager_get_secrets (NMAgentManager *manager, - NMConnection *connection, - NMAuthSubject *subject, - GHashTable *existing_secrets, - const char *setting_name, - NMSecretAgentGetSecretsFlags flags, - const char **hints, - NMAgentSecretsResultFunc callback, - gpointer callback_data, - gpointer other_data2, - gpointer other_data3); + gpointer user_data); + +NMAgentManagerCallId nm_agent_manager_get_secrets (NMAgentManager *manager, + const char *path, + NMConnection *connection, + NMAuthSubject *subject, + GVariant *existing_secrets, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags, + const char **hints, + NMAgentSecretsResultFunc callback, + gpointer callback_data); void nm_agent_manager_cancel_secrets (NMAgentManager *manager, - guint32 request_id); + NMAgentManagerCallId request_id); -guint32 nm_agent_manager_save_secrets (NMAgentManager *manager, - NMConnection *connection, - NMAuthSubject *subject); +void nm_agent_manager_save_secrets (NMAgentManager *manager, + const char *path, + NMConnection *connection, + NMAuthSubject *subject); -guint32 nm_agent_manager_delete_secrets (NMAgentManager *manager, - NMConnection *connection); +void nm_agent_manager_delete_secrets (NMAgentManager *manager, + const char *path, + NMConnection *connection); NMSecretAgent *nm_agent_manager_get_agent_by_user (NMAgentManager *manager, const char *username); diff --git a/src/settings/nm-inotify-helper.c b/src/settings/nm-inotify-helper.c index 3732e77a..681933cd 100644 --- a/src/settings/nm-inotify-helper.c +++ b/src/settings/nm-inotify-helper.c @@ -23,11 +23,11 @@ #include <unistd.h> #include <string.h> #include <sys/inotify.h> -#include <glib.h> #include <errno.h> +#include "nm-default.h" #include "nm-inotify-helper.h" -#include "nm-logging.h" +#include "NetworkManagerUtils.h" /* NOTE: this code should be killed once we depend on a new enough glib to * include the patches from https://bugzilla.gnome.org/show_bug.cgi?id=532815 diff --git a/src/settings/nm-inotify-helper.h b/src/settings/nm-inotify-helper.h index 31e6b9ff..b4e2c612 100644 --- a/src/settings/nm-inotify-helper.h +++ b/src/settings/nm-inotify-helper.h @@ -21,10 +21,10 @@ #ifndef __INOTIFY_HELPER_H__ #define __INOTIFY_HELPER_H__ -#include <glib.h> -#include <glib-object.h> #include <sys/inotify.h> +#include "nm-default.h" + /* NOTE: this code should be killed once we depend on a new enough glib to * include the patches from https://bugzilla.gnome.org/show_bug.cgi?id=532815 */ diff --git a/src/settings/nm-secret-agent.c b/src/settings/nm-secret-agent.c index 69a5cea2..89e84c26 100644 --- a/src/settings/nm-secret-agent.c +++ b/src/settings/nm-secret-agent.c @@ -23,20 +23,36 @@ #include <sys/types.h> #include <pwd.h> -#include <glib.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - +#include "nm-default.h" #include "nm-dbus-interface.h" #include "nm-secret-agent.h" -#include "nm-dbus-manager.h" -#include "nm-dbus-glib-types.h" -#include "nm-glib-compat.h" -#include "nm-logging.h" +#include "nm-bus-manager.h" #include "nm-auth-subject.h" #include "nm-simple-connection.h" #include "NetworkManagerUtils.h" +#include "nmdbus-secret-agent.h" + +#define _NMLOG_PREFIX_NAME "secret-agent" +#define _NMLOG_DOMAIN LOGD_AGENTS +#define _NMLOG(level, ...) \ + G_STMT_START { \ + if (nm_logging_enabled ((level), (_NMLOG_DOMAIN))) { \ + char __prefix[32]; \ + \ + if ((self)) \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \ + else \ + g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \ + _nm_log ((level), (_NMLOG_DOMAIN), 0, \ + "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + __prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + } G_STMT_END + +#define LOG_REQ_FMT "req[%p,%s,%s%s%s%s]" +#define LOG_REQ_ARG(req) (req), (req)->dbus_command, NM_PRINT_FMT_QUOTE_STRING ((req)->path), ((req)->cancellable ? "" : " (cancelled)") + G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT) #define NM_SECRET_AGENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ @@ -48,30 +64,45 @@ typedef struct { NMAuthSubject *subject; char *identifier; char *owner_username; + char *dbus_owner; NMSecretAgentCapabilities capabilities; - guint32 hash; GSList *permissions; - DBusGProxy *proxy; - guint proxy_destroy_id; + NMDBusSecretAgent *proxy; + NMBusManager *bus_mgr; + GDBusConnection *connection; + gboolean connection_is_private; + gulong on_disconnected_id; GHashTable *requests; } NMSecretAgentPrivate; +enum { + DISCONNECTED, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + /*************************************************************/ -typedef struct { +struct _NMSecretAgentCallId { NMSecretAgent *agent; - DBusGProxyCall *call; + GCancellable *cancellable; char *path; + const char *dbus_command; char *setting_name; + gboolean is_get_secrets; NMSecretAgentCallback callback; gpointer callback_data; -} Request; +}; + +typedef struct _NMSecretAgentCallId Request; static Request * -request_new (NMSecretAgent *agent, +request_new (NMSecretAgent *self, + const char *dbus_command, /* this must be a static string. */ const char *path, const char *setting_name, NMSecretAgentCallback callback, @@ -80,24 +111,60 @@ request_new (NMSecretAgent *agent, Request *r; r = g_slice_new0 (Request); - r->agent = agent; + r->agent = self; r->path = g_strdup (path); r->setting_name = g_strdup (setting_name); + r->dbus_command = dbus_command, r->callback = callback; r->callback_data = callback_data; + r->cancellable = g_cancellable_new (); + _LOGt ("request "LOG_REQ_FMT": created", LOG_REQ_ARG (r)); return r; } +#define request_new(self,dbus_command,path,setting_name,callback,callback_data) request_new(self,""dbus_command"",path,setting_name,callback,callback_data) static void request_free (Request *r) { + NMSecretAgent *self = r->agent; + + _LOGt ("request "LOG_REQ_FMT": destroyed", LOG_REQ_ARG (r)); g_free (r->path); g_free (r->setting_name); + if (r->cancellable) + g_object_unref (r->cancellable); g_slice_free (Request, r); } +static gboolean +request_check_return (Request *r) +{ + NMSecretAgentPrivate *priv; + + if (!r->cancellable) + return FALSE; + + g_return_val_if_fail (NM_IS_SECRET_AGENT (r->agent), FALSE); + + priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); + + if (!g_hash_table_remove (priv->requests, r)) + g_return_val_if_reached (FALSE); + + return TRUE; +} + /*************************************************************/ +static char * +_create_description (const char *dbus_owner, const char *identifier, gulong uid) +{ + return g_strdup_printf ("%s/%s/%lu", + dbus_owner, + identifier, + uid); +} + const char * nm_secret_agent_get_description (NMSecretAgent *agent) { @@ -107,10 +174,9 @@ nm_secret_agent_get_description (NMSecretAgent *agent) priv = NM_SECRET_AGENT_GET_PRIVATE (agent); if (!priv->description) { - priv->description = g_strdup_printf ("%s/%s/%lu", - nm_auth_subject_get_unix_process_dbus_sender (priv->subject), - priv->identifier, - nm_auth_subject_get_unix_process_uid (priv->subject)); + priv->description = _create_description (priv->dbus_owner, + priv->identifier, + nm_auth_subject_get_unix_process_uid (priv->subject)); } return priv->description; @@ -121,7 +187,7 @@ nm_secret_agent_get_dbus_owner (NMSecretAgent *agent) { g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), NULL); - return nm_auth_subject_get_unix_process_dbus_sender (NM_SECRET_AGENT_GET_PRIVATE (agent)->subject); + return NM_SECRET_AGENT_GET_PRIVATE (agent)->dbus_owner; } const char * @@ -164,14 +230,6 @@ nm_secret_agent_get_capabilities (NMSecretAgent *agent) return NM_SECRET_AGENT_GET_PRIVATE (agent)->capabilities; } -guint32 -nm_secret_agent_get_hash (NMSecretAgent *agent) -{ - g_return_val_if_fail (NM_IS_SECRET_AGENT (agent), 0); - - return NM_SECRET_AGENT_GET_PRIVATE (agent)->hash; -} - NMAuthSubject * nm_secret_agent_get_subject (NMSecretAgent *agent) { @@ -253,29 +311,29 @@ nm_secret_agent_has_permission (NMSecretAgent *agent, const char *permission) /*************************************************************/ static void -get_callback (DBusGProxy *proxy, - DBusGProxyCall *call, - void *user_data) +get_callback (GObject *proxy, + GAsyncResult *result, + gpointer user_data) { Request *r = user_data; - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); - GError *error = NULL; - GHashTable *secrets = NULL; - - g_return_if_fail (call == r->call); - - dbus_g_proxy_end_call (proxy, call, &error, - DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &secrets, - G_TYPE_INVALID); - r->callback (r->agent, r->call, secrets, error, r->callback_data); - if (secrets) - g_hash_table_unref (secrets); - g_clear_error (&error); - g_hash_table_remove (priv->requests, call); + + if (request_check_return (r)) { + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *secrets = NULL; + + nmdbus_secret_agent_call_get_secrets_finish (priv->proxy, &secrets, result, &error); + if (error) + g_dbus_error_strip_remote_error (error); + r->callback (r->agent, r, secrets, error, r->callback_data); + } + + request_free (r); } -gconstpointer +NMSecretAgentCallId nm_secret_agent_get_secrets (NMSecretAgent *self, + const char *path, NMConnection *connection, const char *setting_name, const char **hints, @@ -284,230 +342,388 @@ nm_secret_agent_get_secrets (NMSecretAgent *self, gpointer callback_data) { NMSecretAgentPrivate *priv; + static const char *no_hints[] = { NULL }; GVariant *dict; - GHashTable *hash; Request *r; - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_SECRET_AGENT (self), NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (path && *path, NULL); g_return_val_if_fail (setting_name != NULL, NULL); priv = NM_SECRET_AGENT_GET_PRIVATE (self); g_return_val_if_fail (priv->proxy != NULL, NULL); dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL); - hash = nm_utils_connection_dict_to_hash (dict); - g_variant_unref (dict); /* Mask off the private flags if present */ flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM; flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS; - r = request_new (self, nm_connection_get_path (connection), setting_name, callback, callback_data); - r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy, - "GetSecrets", - get_callback, - r, - NULL, - 120000, /* 120 seconds */ - DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash, - DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection), - G_TYPE_STRING, setting_name, - G_TYPE_STRV, hints, - G_TYPE_UINT, flags, - G_TYPE_INVALID); - g_hash_table_insert (priv->requests, r->call, r); - - g_hash_table_destroy (hash); - return r->call; + r = request_new (self, "GetSecrets", path, setting_name, callback, callback_data); + r->is_get_secrets = TRUE; + g_hash_table_add (priv->requests, r); + nmdbus_secret_agent_call_get_secrets (priv->proxy, + dict, + path, + setting_name, + hints ? hints : no_hints, + flags, + r->cancellable, + get_callback, r); + + return r; } +/*************************************************************/ + static void -cancel_done (DBusGProxy *proxy, DBusGProxyCall *call_id, void *user_data) +cancel_done (GObject *proxy, GAsyncResult *result, gpointer user_data) { + char *description = user_data; GError *error = NULL; - if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) { - nm_log_dbg (LOGD_AGENTS, "(%s): agent failed to cancel secrets: (%d) %s", - (const char *) user_data, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + if (!nmdbus_secret_agent_call_cancel_get_secrets_finish (NMDBUS_SECRET_AGENT (proxy), result, &error)) { + nm_log_dbg (LOGD_AGENTS, "%s%s%s: agent failed to cancel secrets: %s", + NM_PRINT_FMT_QUOTED (description, "(", description, ")", "???"), + error->message); g_clear_error (&error); } + + g_free (description); +} + +static void +do_cancel_secrets (NMSecretAgent *self, Request *r, gboolean disposing) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GCancellable *cancellable; + NMSecretAgentCallback callback; + gpointer callback_data; + + g_return_if_fail (r->agent == self); + g_return_if_fail (r->cancellable); + + if ( r->is_get_secrets + && priv->proxy) { + /* for GetSecrets call, we must cancel the request. */ + nmdbus_secret_agent_call_cancel_get_secrets (priv->proxy, + r->path, r->setting_name, + NULL, + cancel_done, + g_strdup (nm_secret_agent_get_description (self))); + } + + cancellable = r->cancellable; + callback = r->callback; + callback_data = r->callback_data; + + /* During g_cancellable_cancel() the d-bus method might return synchronously. + * Clear r->cancellable first, so that it doesn't actually do anything. + * After that, @r might be already freed. */ + r->cancellable = NULL; + g_cancellable_cancel (cancellable); + g_object_unref (cancellable); + + /* Don't free the request @r. It will be freed when the d-bus call returns. + * Only clear r->cancellable to indicate that the request was cancelled. */ + + if (callback) { + gs_free_error GError *error = NULL; + + nm_utils_error_set_cancelled (&error, disposing, "NMSecretAgent"); + /* @r might be a dangling pointer at this point. However, that is no problem + * to pass it as (opaque) call_id. */ + callback (self, r, NULL, error, callback_data); + } } +/** + * nm_secret_agent_cancel_secrets: + * @self: #NMSecretAgent instance + * @call_id: the call id to cancel + * + * It is an error to pass an invalid @call_id or a @call_id for an operation + * that already completed. NMSecretAgent will always invoke the callback, + * also for cancel() and dispose(). + * In case of nm_secret_agent_cancel_secrets() this will synchronously invoke the + * callback before nm_secret_agent_cancel_secrets() returns. + */ void -nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call) +nm_secret_agent_cancel_secrets (NMSecretAgent *self, NMSecretAgentCallId call_id) { NMSecretAgentPrivate *priv; - Request *r; + Request *r = call_id; + + g_return_if_fail (NM_IS_SECRET_AGENT (self)); + g_return_if_fail (r); - g_return_if_fail (self != NULL); priv = NM_SECRET_AGENT_GET_PRIVATE (self); - g_return_if_fail (priv->proxy != NULL); - - r = g_hash_table_lookup (priv->requests, call); - g_return_if_fail (r != NULL); - - dbus_g_proxy_cancel_call (priv->proxy, (gpointer) call); - - dbus_g_proxy_begin_call (priv->proxy, - "CancelGetSecrets", - cancel_done, - g_strdup (nm_secret_agent_get_description (self)), - g_free, - DBUS_TYPE_G_OBJECT_PATH, r->path, - G_TYPE_STRING, r->setting_name, - G_TYPE_INVALID); - g_hash_table_remove (priv->requests, call); + if (!g_hash_table_remove (priv->requests, r)) + g_return_if_reached (); + + do_cancel_secrets (self, r, FALSE); } /*************************************************************/ static void -agent_save_delete_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - void *user_data) +agent_save_cb (GObject *proxy, + GAsyncResult *result, + gpointer user_data) { Request *r = user_data; - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); - GError *error = NULL; - g_return_if_fail (call == r->call); + if (request_check_return (r)) { + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); + gs_free_error GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - r->callback (r->agent, r->call, NULL, error, r->callback_data); - g_clear_error (&error); - g_hash_table_remove (priv->requests, call); -} + nmdbus_secret_agent_call_save_secrets_finish (priv->proxy, result, &error); + if (error) + g_dbus_error_strip_remote_error (error); + r->callback (r->agent, r, NULL, error, r->callback_data); + } -static gpointer -agent_new_save_delete (NMSecretAgent *self, - NMConnection *connection, - NMConnectionSerializationFlags flags, - const char *method, - NMSecretAgentCallback callback, - gpointer callback_data) -{ - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); - GVariant *dict; - GHashTable *hash; - Request *r; - const char *cpath = nm_connection_get_path (connection); - - dict = nm_connection_to_dbus (connection, flags); - hash = nm_utils_connection_dict_to_hash (dict); - g_variant_unref (dict); - - r = request_new (self, cpath, NULL, callback, callback_data); - r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy, - method, - agent_save_delete_cb, - r, - NULL, - 10000, /* 10 seconds */ - DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash, - DBUS_TYPE_G_OBJECT_PATH, cpath, - G_TYPE_INVALID); - g_hash_table_insert (priv->requests, r->call, r); - - g_hash_table_destroy (hash); - return r->call; + request_free (r); } -gconstpointer +NMSecretAgentCallId nm_secret_agent_save_secrets (NMSecretAgent *self, + const char *path, NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data) { - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (connection != NULL, NULL); + NMSecretAgentPrivate *priv; + GVariant *dict; + Request *r; + + g_return_val_if_fail (NM_IS_SECRET_AGENT (self), NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (path && *path, NULL); + + priv = NM_SECRET_AGENT_GET_PRIVATE (self); /* Caller should have ensured that only agent-owned secrets exist in 'connection' */ - return agent_new_save_delete (self, - connection, - NM_CONNECTION_SERIALIZE_ALL, - "SaveSecrets", - callback, - callback_data); + dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL); + + r = request_new (self, "SaveSecrets", path, NULL, callback, callback_data); + g_hash_table_add (priv->requests, r); + nmdbus_secret_agent_call_save_secrets (priv->proxy, + dict, + path, + NULL, /* cancelling the request does *not* cancel the D-Bus call. */ + agent_save_cb, r); + + return r; +} + +/*************************************************************/ + +static void +agent_delete_cb (GObject *proxy, + GAsyncResult *result, + gpointer user_data) +{ + Request *r = user_data; + + if (request_check_return (r)) { + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent); + gs_free_error GError *error = NULL; + + nmdbus_secret_agent_call_delete_secrets_finish (priv->proxy, result, &error); + if (error) + g_dbus_error_strip_remote_error (error); + r->callback (r->agent, r, NULL, error, r->callback_data); + } + + request_free (r); } -gconstpointer +NMSecretAgentCallId nm_secret_agent_delete_secrets (NMSecretAgent *self, + const char *path, NMConnection *connection, NMSecretAgentCallback callback, gpointer callback_data) { - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (connection != NULL, NULL); + NMSecretAgentPrivate *priv; + GVariant *dict; + Request *r; + + g_return_val_if_fail (NM_IS_SECRET_AGENT (self), NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + g_return_val_if_fail (path && *path, NULL); + + priv = NM_SECRET_AGENT_GET_PRIVATE (self); /* No secrets sent; agents must be smart enough to track secrets using the UUID or something */ - return agent_new_save_delete (self, - connection, - NM_CONNECTION_SERIALIZE_NO_SECRETS, - "DeleteSecrets", - callback, - callback_data); + dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_NO_SECRETS); + + r = request_new (self, "DeleteSecrets", path, NULL, callback, callback_data); + g_hash_table_add (priv->requests, r); + nmdbus_secret_agent_call_delete_secrets (priv->proxy, + dict, + path, + NULL, /* cancelling the request does *not* cancel the D-Bus call. */ + agent_delete_cb, r); + + return r; } +/*************************************************************/ + static void -proxy_cleanup (NMSecretAgent *self) +_on_disconnected_cleanup (NMSecretAgentPrivate *priv) { + if (priv->on_disconnected_id) { + if (priv->connection_is_private) { + g_signal_handler_disconnect (priv->bus_mgr, + priv->on_disconnected_id); + } else { + g_dbus_connection_signal_unsubscribe (priv->connection, + priv->on_disconnected_id); + } + priv->on_disconnected_id = 0; + } + + g_clear_object (&priv->connection); + g_clear_object (&priv->proxy); + g_clear_object (&priv->bus_mgr); +} + +static void +_on_disconnected_private_connection (NMBusManager *mgr, + GDBusConnection *connection, + NMSecretAgent *self) +{ + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + + if (priv->connection != connection) + return; + + _LOGt ("private connection disconnected"); + + _on_disconnected_cleanup (priv); + g_signal_emit (self, signals[DISCONNECTED], 0); +} + +static void +_on_disconnected_name_owner_changed (GDBusConnection *connection, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + NMSecretAgent *self = NM_SECRET_AGENT (user_data); NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + const char *old_owner, *new_owner; - if (priv->proxy) { - g_signal_handler_disconnect (priv->proxy, priv->proxy_destroy_id); - priv->proxy_destroy_id = 0; - g_clear_object (&priv->proxy); + g_variant_get (parameters, + "(&s&s&s)", + NULL, + &old_owner, + &new_owner); + + _LOGt ("name-owner-changed: %s%s%s => %s%s%s", + NM_PRINT_FMT_QUOTE_STRING (old_owner), + NM_PRINT_FMT_QUOTE_STRING (new_owner)); + + if (!*new_owner) { + _on_disconnected_cleanup (priv); + g_signal_emit (self, signals[DISCONNECTED], 0); } } /*************************************************************/ NMSecretAgent * -nm_secret_agent_new (DBusGMethodInvocation *context, +nm_secret_agent_new (GDBusMethodInvocation *context, NMAuthSubject *subject, const char *identifier, NMSecretAgentCapabilities capabilities) { NMSecretAgent *self; NMSecretAgentPrivate *priv; - char *hash_str, *username; + const char *dbus_owner; struct passwd *pw; + GDBusProxy *proxy; + char *owner_username = NULL; + char *description = NULL; + char buf_subject[64]; + gulong uid; + GDBusConnection *connection; g_return_val_if_fail (context != NULL, NULL); g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL); g_return_val_if_fail (nm_auth_subject_is_unix_process (subject), NULL); g_return_val_if_fail (identifier != NULL, NULL); - pw = getpwuid (nm_auth_subject_get_unix_process_uid (subject)); - g_return_val_if_fail (pw != NULL, NULL); - g_return_val_if_fail (pw->pw_name[0] != '\0', NULL); - username = g_strdup (pw->pw_name); + connection = g_dbus_method_invocation_get_connection (context); + + g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); + + uid = nm_auth_subject_get_unix_process_uid (subject); + + pw = getpwuid (uid); + if (pw && pw->pw_name && pw->pw_name[0]) + owner_username = g_strdup (pw->pw_name); + + dbus_owner = nm_auth_subject_get_unix_process_dbus_sender (subject); self = (NMSecretAgent *) g_object_new (NM_TYPE_SECRET_AGENT, NULL); + priv = NM_SECRET_AGENT_GET_PRIVATE (self); + priv->bus_mgr = g_object_ref (nm_bus_manager_get ()); + priv->connection = g_object_ref (connection); + priv->connection_is_private = !!nm_bus_manager_connection_get_private_name (priv->bus_mgr, connection); + + _LOGt ("constructed: %s, owner=%s%s%s (%s), private-connection=%d, unique-name=%s%s%s", + (description = _create_description (dbus_owner, identifier, uid)), + NM_PRINT_FMT_QUOTE_STRING (owner_username), + nm_auth_subject_to_string (subject, buf_subject, sizeof (buf_subject)), + priv->connection_is_private, + NM_PRINT_FMT_QUOTE_STRING (g_dbus_connection_get_unique_name (priv->connection))); + priv->identifier = g_strdup (identifier); - priv->owner_username = g_strdup (username); + priv->owner_username = owner_username; + priv->dbus_owner = g_strdup (dbus_owner); + priv->description = description; priv->capabilities = capabilities; priv->subject = g_object_ref (subject); - hash_str = g_strdup_printf ("%16lu%s", nm_auth_subject_get_unix_process_uid (subject), identifier); - priv->hash = g_str_hash (hash_str); - g_free (hash_str); - - priv->proxy = nm_dbus_manager_new_proxy (nm_dbus_manager_get (), - context, - nm_auth_subject_get_unix_process_dbus_sender (subject), - NM_DBUS_PATH_SECRET_AGENT, - NM_DBUS_INTERFACE_SECRET_AGENT); - g_assert (priv->proxy); - priv->proxy_destroy_id = g_signal_connect_swapped (priv->proxy, "destroy", - G_CALLBACK (proxy_cleanup), self); + proxy = nm_bus_manager_new_proxy (priv->bus_mgr, + priv->connection, + NMDBUS_TYPE_SECRET_AGENT_PROXY, + priv->dbus_owner, + NM_DBUS_PATH_SECRET_AGENT, + NM_DBUS_INTERFACE_SECRET_AGENT); + g_assert (proxy); + priv->proxy = NMDBUS_SECRET_AGENT (proxy); + + /* we cannot subscribe to notify::g-name-owner because that doesn't work + * for unique names and it doesn't work for private connections. */ + if (priv->connection_is_private) { + priv->on_disconnected_id = g_signal_connect (priv->bus_mgr, + NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED, + G_CALLBACK (_on_disconnected_private_connection), + self); + } else { + priv->on_disconnected_id = g_dbus_connection_signal_subscribe (priv->connection, + "org.freedesktop.DBus", /* name */ + "org.freedesktop.DBus", /* interface */ + "NameOwnerChanged", /* signal name */ + "/org/freedesktop/DBus", /* path */ + priv->dbus_owner, /* arg0 */ + G_DBUS_SIGNAL_FLAGS_NONE, + _on_disconnected_name_owner_changed, + self, + NULL); + } - g_free (username); return self; } @@ -516,16 +732,25 @@ nm_secret_agent_init (NMSecretAgent *self) { NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); - priv->requests = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) request_free); + priv->requests = g_hash_table_new (g_direct_hash, g_direct_equal); } static void dispose (GObject *object) { - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object); + NMSecretAgent *self = NM_SECRET_AGENT (object); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); + GHashTableIter iter; + Request *r; + + g_hash_table_iter_init (&iter, priv->requests); + while (g_hash_table_iter_next (&iter, (gpointer *) &r, NULL)) { + g_hash_table_iter_remove (&iter); + do_cancel_secrets (self, r, TRUE); + } + + _on_disconnected_cleanup (priv); - proxy_cleanup (NM_SECRET_AGENT (object)); g_clear_object (&priv->subject); G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object); @@ -534,16 +759,20 @@ dispose (GObject *object) static void finalize (GObject *object) { - NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object); + NMSecretAgent *self = NM_SECRET_AGENT (object); + NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self); g_free (priv->description); g_free (priv->identifier); g_free (priv->owner_username); + g_free (priv->dbus_owner); g_slist_free_full (priv->permissions, g_free); g_hash_table_destroy (priv->requests); G_OBJECT_CLASS (nm_secret_agent_parent_class)->finalize (object); + + _LOGt ("finalized"); } static void @@ -556,5 +785,15 @@ nm_secret_agent_class_init (NMSecretAgentClass *config_class) /* virtual methods */ object_class->dispose = dispose; object_class->finalize = finalize; + + /* signals */ + signals[DISCONNECTED] = + g_signal_new (NM_SECRET_AGENT_DISCONNECTED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMSecretAgentClass, disconnected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } diff --git a/src/settings/nm-secret-agent.h b/src/settings/nm-secret-agent.h index f3f4ff89..333aa461 100644 --- a/src/settings/nm-secret-agent.h +++ b/src/settings/nm-secret-agent.h @@ -21,11 +21,8 @@ #ifndef __NETWORKMANAGER_SECRET_AGENT_H__ #define __NETWORKMANAGER_SECRET_AGENT_H__ -#include <glib.h> -#include <glib-object.h> - #include <nm-connection.h> -#include "nm-types.h" +#include "nm-default.h" #define NM_TYPE_SECRET_AGENT (nm_secret_agent_get_type ()) #define NM_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent)) @@ -34,17 +31,23 @@ #define NM_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT)) #define NM_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentClass)) +#define NM_SECRET_AGENT_DISCONNECTED "disconnected" + struct _NMSecretAgent { GObject parent; }; typedef struct { GObjectClass parent; + + void (*disconnected) (NMSecretAgent *self); } NMSecretAgentClass; +typedef struct _NMSecretAgentCallId *NMSecretAgentCallId; + GType nm_secret_agent_get_type (void); -NMSecretAgent *nm_secret_agent_new (DBusGMethodInvocation *context, +NMSecretAgent *nm_secret_agent_new (GDBusMethodInvocation *context, NMAuthSubject *subject, const char *identifier, NMSecretAgentCapabilities capabilities); @@ -63,8 +66,6 @@ gulong nm_secret_agent_get_pid (NMSecretAgent *agent); NMSecretAgentCapabilities nm_secret_agent_get_capabilities (NMSecretAgent *agent); -guint32 nm_secret_agent_get_hash (NMSecretAgent *agent); - NMAuthSubject *nm_secret_agent_get_subject (NMSecretAgent *agent); void nm_secret_agent_add_permission (NMSecretAgent *agent, @@ -75,30 +76,33 @@ gboolean nm_secret_agent_has_permission (NMSecretAgent *agent, const char *permission); typedef void (*NMSecretAgentCallback) (NMSecretAgent *agent, - gconstpointer call, - GHashTable *new_secrets, /* NULL for save & delete */ + NMSecretAgentCallId call_id, + GVariant *new_secrets, /* NULL for save & delete */ GError *error, gpointer user_data); -gconstpointer nm_secret_agent_get_secrets (NMSecretAgent *agent, - NMConnection *connection, - const char *setting_name, - const char **hints, - NMSecretAgentGetSecretsFlags flags, - NMSecretAgentCallback callback, - gpointer callback_data); +NMSecretAgentCallId nm_secret_agent_get_secrets (NMSecretAgent *agent, + const char *path, + NMConnection *connection, + const char *setting_name, + const char **hints, + NMSecretAgentGetSecretsFlags flags, + NMSecretAgentCallback callback, + gpointer callback_data); void nm_secret_agent_cancel_secrets (NMSecretAgent *agent, - gconstpointer call_id); - -gconstpointer nm_secret_agent_save_secrets (NMSecretAgent *agent, - NMConnection *connection, - NMSecretAgentCallback callback, - gpointer callback_data); - -gconstpointer nm_secret_agent_delete_secrets (NMSecretAgent *agent, - NMConnection *connection, - NMSecretAgentCallback callback, - gpointer callback_data); + NMSecretAgentCallId call_id); + +NMSecretAgentCallId nm_secret_agent_save_secrets (NMSecretAgent *agent, + const char *path, + NMConnection *connection, + NMSecretAgentCallback callback, + gpointer callback_data); + +NMSecretAgentCallId nm_secret_agent_delete_secrets (NMSecretAgent *agent, + const char *path, + NMConnection *connection, + NMSecretAgentCallback callback, + gpointer callback_data); #endif /* __NETWORKMANAGER_SECRET_AGENT_H__ */ diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 1fa19237..f7e5002c 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -23,22 +23,18 @@ #include <string.h> -#include <nm-dbus-interface.h> -#include <dbus/dbus-glib-lowlevel.h> - +#include "nm-default.h" +#include "nm-dbus-interface.h" #include "nm-settings-connection.h" #include "nm-session-monitor.h" -#include "nm-dbus-manager.h" -#include "nm-dbus-glib-types.h" -#include "nm-logging.h" #include "nm-auth-utils.h" #include "nm-auth-subject.h" #include "nm-agent-manager.h" #include "NetworkManagerUtils.h" -#include "nm-properties-changed-signal.h" #include "nm-core-internal.h" -#include "nm-glib-compat.h" -#include "gsystem-local-alloc.h" +#include "nm-audit-manager.h" + +#include "nmdbus-settings-connection.h" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" @@ -52,12 +48,11 @@ if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \ char __prefix[128]; \ const char *__p_prefix = _NMLOG_PREFIX_NAME; \ - const void *const __self = (self); \ \ - if (__self) { \ - const char *__uuid = nm_connection_get_uuid ((NMConnection *) __self); \ + if (self) { \ + const char *__uuid = nm_settings_connection_get_uuid (self); \ \ - g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, __self, __uuid ? "," : "", __uuid ? __uuid : ""); \ + g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ? __uuid : ""); \ __p_prefix = __prefix; \ } \ _nm_log (__level, _NMLOG_DOMAIN, 0, \ @@ -66,36 +61,9 @@ } \ } G_STMT_END - -static void impl_settings_connection_get_settings (NMSettingsConnection *self, - DBusGMethodInvocation *context); - -static void impl_settings_connection_update (NMSettingsConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context); - -static void impl_settings_connection_update_unsaved (NMSettingsConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context); - -static void impl_settings_connection_save (NMSettingsConnection *self, - DBusGMethodInvocation *context); - -static void impl_settings_connection_delete (NMSettingsConnection *self, - DBusGMethodInvocation *context); - -static void impl_settings_connection_get_secrets (NMSettingsConnection *self, - const gchar *setting_name, - DBusGMethodInvocation *context); - -static void impl_settings_connection_clear_secrets (NMSettingsConnection *self, - DBusGMethodInvocation *context); - -#include "nm-settings-connection-glue.h" - static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface); -G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, G_TYPE_OBJECT, +G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT, G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init) ) @@ -134,7 +102,8 @@ typedef struct { GSList *pending_auths; /* List of pending authentication requests */ gboolean visible; /* Is this connection is visible by some session? */ - GSList *reqs; /* in-progress secrets requests */ + + GSList *get_secret_requests; /* in-progress secrets requests */ /* Caches secrets from on-disk connections; were they not cached any * call to nm_connection_clear_secrets() wipes them out and we'd have @@ -163,91 +132,155 @@ typedef struct { } NMSettingsConnectionPrivate; +/*******************************************************************/ + +gboolean +nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self, + NMConnection *applied_connection, + NMSettingCompareFlags compare_flags) +{ + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), FALSE); + g_return_val_if_fail (NM_IS_CONNECTION (applied_connection), FALSE); + + /* for convenience, we *always* ignore certain settings. */ + compare_flags |= NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS | NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP; + + return nm_connection_compare (NM_CONNECTION (self), applied_connection, compare_flags); +} + /**************************************************************/ -/* Return TRUE to continue, FALSE to stop */ -typedef gboolean (*ForEachSecretFunc) (GHashTableIter *iter, - NMSettingSecretFlags flags, +/* Return TRUE to keep, FALSE to drop */ +typedef gboolean (*ForEachSecretFunc) (NMSettingSecretFlags flags, gpointer user_data); -static void +/* Returns always a non-NULL, non-floating variant that must + * be unrefed by the caller. */ +static GVariant * for_each_secret (NMConnection *self, - GHashTable *secrets, + GVariant *secrets, gboolean remove_non_secrets, ForEachSecretFunc callback, gpointer callback_data) { - GHashTableIter iter; + GVariantBuilder secrets_builder, setting_builder; + GVariantIter secrets_iter, *setting_iter; const char *setting_name; - GHashTable *setting_hash; - /* This function, given a hash of hashes representing new secrets of - * an NMConnection, walks through each toplevel hash (which represents a - * NMSetting), and for each setting, walks through that setting hash's + /* This function, given a dict of dicts representing new secrets of + * an NMConnection, walks through each toplevel dict (which represents a + * NMSetting), and for each setting, walks through that setting dict's * properties. For each property that's a secret, it will check that * secret's flags in the backing NMConnection object, and call a supplied * callback. * * The one complexity is that the VPN setting's 'secrets' property is - * *also* a hash table (since the key/value pairs are arbitrary and known + * *also* a dict (since the key/value pairs are arbitrary and known * only to the VPN plugin itself). That means we have three levels of - * GHashTables that we potentially have to traverse here. When we hit the + * dicts that we potentially have to traverse here. When we hit the * VPN setting's 'secrets' property, we special-case that and iterate over - * each item in that 'secrets' hash table, calling the supplied callback + * each item in that 'secrets' dict, calling the supplied callback * each time. */ - g_return_if_fail (callback); + g_return_val_if_fail (callback, NULL); - /* Walk through the list of setting hashes */ - g_hash_table_iter_init (&iter, secrets); - while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) { + g_variant_iter_init (&secrets_iter, secrets); + g_variant_builder_init (&secrets_builder, NM_VARIANT_TYPE_CONNECTION); + while (g_variant_iter_next (&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) { NMSetting *setting; - GHashTableIter secret_iter; const char *secret_name; - GValue *val; + GVariant *val; - if (g_hash_table_size (setting_hash) == 0) - continue; - - /* Get the actual NMSetting from the connection so we can get secret flags - * from the connection data, since flags aren't secrets. What we're - * iterating here is just the secrets, not a whole connection. - */ setting = nm_connection_get_setting_by_name (self, setting_name); - if (setting == NULL) + if (setting == NULL) { + g_variant_iter_free (setting_iter); continue; + } - /* Walk through the list of keys in each setting hash */ - g_hash_table_iter_init (&secret_iter, setting_hash); - while (g_hash_table_iter_next (&secret_iter, (gpointer) &secret_name, (gpointer) &val)) { + g_variant_builder_init (&setting_builder, NM_VARIANT_TYPE_SETTING); + while (g_variant_iter_next (setting_iter, "{&sv}", &secret_name, &val)) { NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; /* VPN secrets need slightly different treatment here since the * "secrets" property is actually a hash table of secrets. */ - if (NM_IS_SETTING_VPN (setting) && (g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS) == 0)) { - GHashTableIter vpn_secrets_iter; - - /* Iterate through each secret from the VPN hash in the overall secrets hash */ - g_hash_table_iter_init (&vpn_secrets_iter, g_value_get_boxed (val)); - while (g_hash_table_iter_next (&vpn_secrets_iter, (gpointer) &secret_name, NULL)) { - secret_flags = NM_SETTING_SECRET_FLAG_NONE; - nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL); - if (callback (&vpn_secrets_iter, secret_flags, callback_data) == FALSE) - return; + if (NM_IS_SETTING_VPN (setting) && !g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS)) { + GVariantBuilder vpn_secrets_builder; + GVariantIter vpn_secrets_iter; + const char *vpn_secret_name, *secret; + + /* Iterate through each secret from the VPN dict in the overall secrets dict */ + g_variant_builder_init (&vpn_secrets_builder, G_VARIANT_TYPE ("a{ss}")); + g_variant_iter_init (&vpn_secrets_iter, val); + while (g_variant_iter_next (&vpn_secrets_iter, "{&s&s}", &vpn_secret_name, &secret)) { + if (!nm_setting_get_secret_flags (setting, vpn_secret_name, &secret_flags, NULL)) { + if (!remove_non_secrets) + g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret); + continue; + } + + if (callback (secret_flags, callback_data)) + g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret); } + + g_variant_builder_add (&setting_builder, "{sv}", + secret_name, g_variant_builder_end (&vpn_secrets_builder)); } else { if (!nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL)) { - if (remove_non_secrets) - g_hash_table_iter_remove (&secret_iter); + if (!remove_non_secrets) + g_variant_builder_add (&setting_builder, "{sv}", secret_name, val); continue; } - if (callback (&secret_iter, secret_flags, callback_data) == FALSE) - return; + if (callback (secret_flags, callback_data)) + g_variant_builder_add (&setting_builder, "{sv}", secret_name, val); } + g_variant_unref (val); } + + g_variant_iter_free (setting_iter); + g_variant_builder_add (&secrets_builder, "{sa{sv}}", setting_name, &setting_builder); } + + return g_variant_ref_sink (g_variant_builder_end (&secrets_builder)); +} + +typedef gboolean (*FindSecretFunc) (NMSettingSecretFlags flags, + gpointer user_data); + +typedef struct { + FindSecretFunc find_func; + gpointer find_func_data; + gboolean found; +} FindSecretData; + +static gboolean +find_secret_for_each_func (NMSettingSecretFlags flags, + gpointer user_data) +{ + FindSecretData *data = user_data; + + if (!data->found) + data->found = data->find_func (flags, data->find_func_data); + return FALSE; +} + +static gboolean +find_secret (NMConnection *self, + GVariant *secrets, + FindSecretFunc callback, + gpointer callback_data) +{ + FindSecretData data; + GVariant *dummy; + + data.find_func = callback; + data.find_func_data = callback_data; + data.found = FALSE; + + dummy = for_each_secret (self, secrets, FALSE, find_secret_for_each_func, &data); + g_variant_unref (dummy); + return data.found; } /**************************************************************/ @@ -294,14 +327,18 @@ nm_settings_connection_recheck_visibility (NMSettingsConnection *self) } for (i = 0; i < num; i++) { - const char *puser; + const char *user; + uid_t uid; - if (nm_setting_connection_get_permission (s_con, i, NULL, &puser, NULL)) { - if (nm_session_monitor_user_has_session (priv->session_monitor, puser, NULL, NULL)) { - set_visible (self, TRUE); - return; - } - } + if (!nm_setting_connection_get_permission (s_con, i, NULL, &user, NULL)) + continue; + if (!nm_session_monitor_user_to_uid (user, &uid)) + continue; + if (!nm_session_monitor_session_exists (priv->session_monitor, uid, FALSE)) + continue; + + set_visible (self, TRUE); + return; } set_visible (self, FALSE); @@ -489,11 +526,11 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self, return FALSE; if ( nm_connection_get_path (NM_CONNECTION (self)) - && g_strcmp0 (nm_connection_get_uuid (NM_CONNECTION (self)), nm_connection_get_uuid (new_connection)) != 0) { + && g_strcmp0 (nm_settings_connection_get_uuid (self), nm_connection_get_uuid (new_connection)) != 0) { /* Updating the UUID is not allowed once the path is exported. */ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "connection %s cannot change the UUID from %s to %s", nm_connection_get_id (NM_CONNECTION (self)), - nm_connection_get_uuid (NM_CONNECTION (self)), nm_connection_get_uuid (new_connection)); + "connection %s cannot change the UUID from %s to %s", nm_settings_connection_get_id (self), + nm_settings_connection_get_uuid (self), nm_connection_get_uuid (new_connection)); return FALSE; } @@ -572,9 +609,14 @@ replace_and_commit (NMSettingsConnection *self, gpointer user_data) { GError *error = NULL; + NMSettingsConnectionCommitReason commit_reason = NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION; + + if (g_strcmp0 (nm_connection_get_id (NM_CONNECTION (self)), + nm_connection_get_id (new_connection)) != 0) + commit_reason |= NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED; if (nm_settings_connection_replace_settings (self, new_connection, TRUE, "replace-and-commit-disk", &error)) - nm_settings_connection_commit_changes (self, callback, user_data); + nm_settings_connection_commit_changes (self, commit_reason, callback, user_data); else { g_assert (error); if (callback) @@ -597,6 +639,7 @@ nm_settings_connection_replace_and_commit (NMSettingsConnection *self, static void commit_changes (NMSettingsConnection *self, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -612,6 +655,7 @@ commit_changes (NMSettingsConnection *self, void nm_settings_connection_commit_changes (NMSettingsConnection *self, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -619,6 +663,7 @@ nm_settings_connection_commit_changes (NMSettingsConnection *self, if (NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes) { NM_SETTINGS_CONNECTION_GET_CLASS (self)->commit_changes (self, + commit_reason, callback ? callback : ignore_cb, user_data); } else { @@ -672,7 +717,7 @@ remove_entry_from_db (NMSettingsConnection *self, const char* db_name) gsize len; GError *error = NULL; - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); + connection_uuid = nm_settings_connection_get_uuid (self); g_key_file_remove_key (key_file, db_name, connection_uuid, NULL); data = g_key_file_to_data (key_file, &len, &error); @@ -702,7 +747,9 @@ do_delete (NMSettingsConnection *self, /* Tell agents to remove secrets for this connection */ for_agents = nm_simple_connection_new_clone (NM_CONNECTION (self)); nm_connection_clear_secrets (for_agents); - nm_agent_manager_delete_secrets (priv->agent_mgr, for_agents); + nm_agent_manager_delete_secrets (priv->agent_mgr, + nm_connection_get_path (NM_CONNECTION (self)), + for_agents); g_object_unref (for_agents); /* Remove timestamp from timestamps database file */ @@ -720,47 +767,118 @@ do_delete (NMSettingsConnection *self, /**************************************************************/ -static gboolean -supports_secrets (NMSettingsConnection *self, const char *setting_name) + +typedef enum { + GET_SECRETS_INFO_TYPE_REQ, + GET_SECRETS_INFO_TYPE_IDLE, +} GetSecretsInfoType; + +struct _NMSettingsConnectionCallId { + NMSettingsConnection *self; + gboolean had_applied_connection; + NMConnection *applied_connection; + NMSettingsConnectionSecretsFunc callback; + gpointer callback_data; + + GetSecretsInfoType type; + union { + struct { + NMAgentManagerCallId id; + } req; + struct { + guint32 id; + GError *error; + } idle; + } t; +}; + +typedef struct _NMSettingsConnectionCallId GetSecretsInfo; + +static GetSecretsInfo * +_get_secrets_info_new (NMSettingsConnection *self, + NMConnection *applied_connection, + NMSettingsConnectionSecretsFunc callback, + gpointer callback_data) { - /* All secrets supported */ - return TRUE; + GetSecretsInfo *info; + + info = g_slice_new0 (GetSecretsInfo); + + info->self = self; + if (applied_connection) { + info->had_applied_connection = TRUE; + info->applied_connection = applied_connection; + g_object_add_weak_pointer (G_OBJECT (applied_connection), (gpointer *) &info->applied_connection); + } + info->callback = callback; + info->callback_data = callback_data; + + return info; } -static gboolean -clear_nonagent_secrets (GHashTableIter *iter, - NMSettingSecretFlags flags, - gpointer user_data) +static void +_get_secrets_info_callback (GetSecretsInfo *info, + const char *agent_username, + const char *setting_name, + GError *error) { - if (flags != NM_SETTING_SECRET_FLAG_AGENT_OWNED) - g_hash_table_iter_remove (iter); - return TRUE; + if (info->callback) { + info->callback (info->self, + info, + agent_username, + setting_name, + error, + info->callback_data); + } +} + +static void +_get_secrets_info_free (GetSecretsInfo *info) +{ + g_return_if_fail (info && info->self); + + if (info->applied_connection) + g_object_remove_weak_pointer (G_OBJECT (info->applied_connection), (gpointer *) &info->applied_connection); + + if (info->type == GET_SECRETS_INFO_TYPE_IDLE) + g_clear_error (&info->t.idle.error); + + memset (info, 0, sizeof (*info)); + g_slice_free (GetSecretsInfo, info); } static gboolean -clear_unsaved_secrets (GHashTableIter *iter, - NMSettingSecretFlags flags, - gpointer user_data) +supports_secrets (NMSettingsConnection *self, const char *setting_name) { - if (flags & (NM_SETTING_SECRET_FLAG_NOT_SAVED | NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) - g_hash_table_iter_remove (iter); + /* All secrets supported */ return TRUE; } +typedef struct { + NMSettingSecretFlags required; + NMSettingSecretFlags forbidden; +} ForEachSecretFlags; + static gboolean -has_system_owned_secrets (GHashTableIter *iter, - NMSettingSecretFlags flags, - gpointer user_data) +validate_secret_flags (NMSettingSecretFlags flags, + gpointer user_data) { - gboolean *has_system_owned = user_data; + ForEachSecretFlags *cmp_flags = user_data; - if (flags == NM_SETTING_SECRET_FLAG_NONE) { - *has_system_owned = TRUE; + if (!NM_FLAGS_ALL (flags, cmp_flags->required)) + return FALSE; + if (NM_FLAGS_ANY (flags, cmp_flags->forbidden)) return FALSE; - } return TRUE; } +static gboolean +secret_is_system_owned (NMSettingSecretFlags flags, + gpointer user_data) +{ + return !NM_FLAGS_HAS (flags, NM_SETTING_SECRET_FLAG_AGENT_OWNED); +} + static void new_secrets_commit_cb (NMSettingsConnection *self, GError *error, @@ -773,53 +891,33 @@ new_secrets_commit_cb (NMSettingsConnection *self, } static void -agent_secrets_done_cb (NMAgentManager *manager, - guint32 call_id, - const char *agent_dbus_owner, - const char *agent_username, - gboolean agent_has_modify, - const char *setting_name, - NMSecretAgentGetSecretsFlags flags, - GHashTable *secrets, - GError *error, - gpointer user_data, - gpointer other_data2, - gpointer other_data3) +get_cmp_flags (NMSettingsConnection *self, /* only needed for logging */ + GetSecretsInfo *info, /* only needed for logging */ + NMConnection *connection, + const char *agent_dbus_owner, + gboolean agent_has_modify, + const char *setting_name, /* only needed for logging */ + NMSecretAgentGetSecretsFlags flags, + GVariant *secrets, + gboolean *agent_had_system, + ForEachSecretFlags *cmp_flags) { - NMSettingsConnection *self = NM_SETTINGS_CONNECTION (user_data); - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - NMSettingsConnectionSecretsFunc callback = other_data2; - gpointer callback_data = other_data3; - GError *local = NULL; - GVariant *dict; - gboolean agent_had_system = FALSE; + gboolean is_self = (((NMConnection *) self) == connection); - if (error) { - _LOGD ("(%s:%u) secrets request error: (%d) %s", - setting_name, - call_id, - error->code, - error->message ? error->message : "(unknown)"); + g_return_if_fail (secrets); - callback (self, call_id, NULL, setting_name, error, callback_data); - return; - } + cmp_flags->required = NM_SETTING_SECRET_FLAG_NONE; + cmp_flags->forbidden = NM_SETTING_SECRET_FLAG_NONE; - if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) { - local = g_error_new (NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, - "%s.%d - Connection didn't have requested setting '%s'.", - __FILE__, __LINE__, setting_name); - callback (self, call_id, NULL, setting_name, local, callback_data); - g_clear_error (&local); - return; - } + *agent_had_system = FALSE; - g_assert (secrets); if (agent_dbus_owner) { - _LOGD ("(%s:%u) secrets returned from agent %s", - setting_name, - call_id, - agent_dbus_owner); + if (is_self) { + _LOGD ("(%s:%p) secrets returned from agent %s", + setting_name, + info, + agent_dbus_owner); + } /* If the agent returned any system-owned secrets (initial connect and no * secrets given when the connection was created, or something like that) @@ -827,59 +925,145 @@ agent_secrets_done_cb (NMAgentManager *manager, * save those system-owned secrets. If not, discard them and use the * existing secrets, or fail the connection. */ - for_each_secret (NM_CONNECTION (self), secrets, TRUE, has_system_owned_secrets, &agent_had_system); - if (agent_had_system) { + *agent_had_system = find_secret (connection, secrets, secret_is_system_owned, NULL); + if (*agent_had_system) { if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) { /* No user interaction was allowed when requesting secrets; the * agent is being bad. Remove system-owned secrets. */ - _LOGD ("(%s:%u) interaction forbidden but agent %s returned system secrets", - setting_name, - call_id, - agent_dbus_owner); + if (is_self) { + _LOGD ("(%s:%p) interaction forbidden but agent %s returned system secrets", + setting_name, + info, + agent_dbus_owner); + } - for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); + cmp_flags->required |= NM_SETTING_SECRET_FLAG_AGENT_OWNED; } else if (agent_has_modify == FALSE) { /* Agent didn't successfully authenticate; clear system-owned secrets * from the secrets the agent returned. */ - _LOGD ("(%s:%u) agent failed to authenticate but provided system secrets", - setting_name, - call_id); + if (is_self) { + _LOGD ("(%s:%p) agent failed to authenticate but provided system secrets", + setting_name, + info); + } - for_each_secret (NM_CONNECTION (self), secrets, FALSE, clear_nonagent_secrets, NULL); + cmp_flags->required |= NM_SETTING_SECRET_FLAG_AGENT_OWNED; } } } else { - _LOGD ("(%s:%u) existing secrets returned", - setting_name, - call_id); + if (is_self) { + _LOGD ("(%s:%p) existing secrets returned", + setting_name, + info); + } } - _LOGD ("(%s:%u) secrets request completed", - setting_name, - call_id); - /* If no user interaction was allowed, make sure that no "unsaved" secrets * came back. Unsaved secrets by definition require user interaction. */ - if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) - for_each_secret (NM_CONNECTION (self), secrets, TRUE, clear_unsaved_secrets, NULL); + if (flags == NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE) { + cmp_flags->forbidden |= ( NM_SETTING_SECRET_FLAG_NOT_SAVED + | NM_SETTING_SECRET_FLAG_NOT_REQUIRED); + } +} + +static void +get_secrets_done_cb (NMAgentManager *manager, + NMAgentManagerCallId call_id_a, + const char *agent_dbus_owner, + const char *agent_username, + gboolean agent_has_modify, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags, + GVariant *secrets, + GError *error, + gpointer user_data) +{ + GetSecretsInfo *info = user_data; + NMSettingsConnection *self; + NMSettingsConnectionPrivate *priv; + NMConnection *applied_connection; + gs_free_error GError *local = NULL; + GVariant *dict; + gboolean agent_had_system = FALSE; + ForEachSecretFlags cmp_flags = { NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NONE }; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = info->self; + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self)); + + priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + + g_return_if_fail (g_slist_find (priv->get_secret_requests, info)); + + priv->get_secret_requests = g_slist_remove (priv->get_secret_requests, info); + + if (error) { + _LOGD ("(%s:%p) secrets request error: %s", + setting_name, info, error->message); + + _get_secrets_info_callback (info, NULL, setting_name, error); + goto out; + } + + if ( info->had_applied_connection + && !info->applied_connection) { + g_set_error_literal (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, + "Applied connection deleted since requesting secrets"); + _get_secrets_info_callback (info, NULL, setting_name, local); + goto out; + } + + if ( info->had_applied_connection + && !nm_settings_connection_has_unmodified_applied_connection (self, info->applied_connection, NM_SETTING_COMPARE_FLAG_NONE)) { + g_set_error_literal (&local, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "The connection was modified since activation"); + _get_secrets_info_callback (info, NULL, setting_name, local); + goto out; + } + + if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) { + g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, + "Connection didn't have requested setting '%s'.", + setting_name); + _get_secrets_info_callback (info, NULL, setting_name, local); + goto out; + } + + get_cmp_flags (self, + info, + NM_CONNECTION (self), + agent_dbus_owner, + agent_has_modify, + setting_name, + flags, + secrets, + &agent_had_system, + &cmp_flags); + + _LOGD ("(%s:%p) secrets request completed", + setting_name, + info); + + dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); /* Update the connection with our existing secrets from backing storage */ nm_connection_clear_secrets (NM_CONNECTION (self)); - dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); if (!dict || nm_connection_update_secrets (NM_CONNECTION (self), setting_name, dict, &local)) { - GVariant *secrets_dict; + GVariant *filtered_secrets; /* Update the connection with the agent's secrets; by this point if any * system-owned secrets exist in 'secrets' the agent that provided them * will have been authenticated, so those secrets can replace the existing * system secrets. */ - secrets_dict = nm_utils_connection_hash_to_dict (secrets); - if (nm_connection_update_secrets (NM_CONNECTION (self), setting_name, secrets_dict, &local)) { - /* Now that all secrets are updated, copy and cache new secrets, + filtered_secrets = for_each_secret (NM_CONNECTION (self), secrets, TRUE, validate_secret_flags, &cmp_flags); + if (nm_connection_update_secrets (NM_CONNECTION (self), setting_name, filtered_secrets, &local)) { + /* Now that all secrets are updated, copy and cache new secrets, * then save them to backing storage. */ update_system_secrets_cache (self); @@ -891,41 +1075,91 @@ agent_secrets_done_cb (NMAgentManager *manager, * nothing has changed, since agent-owned secrets don't get saved here. */ if (agent_had_system) { - _LOGD ("(%s:%u) saving new secrets to backing storage", + _LOGD ("(%s:%p) saving new secrets to backing storage", setting_name, - call_id); + info); - nm_settings_connection_commit_changes (self, new_secrets_commit_cb, NULL); + nm_settings_connection_commit_changes (self, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, new_secrets_commit_cb, NULL); } else { - _LOGD ("(%s:%u) new agent secrets processed", + _LOGD ("(%s:%p) new agent secrets processed", setting_name, - call_id); + info); } + } else { - _LOGD ("(%s:%u) failed to update with agent secrets: (%d) %s", + _LOGD ("(%s:%p) failed to update with agent secrets: (%d) %s", setting_name, - call_id, + info, local ? local->code : -1, (local && local->message) ? local->message : "(unknown)"); } - g_variant_unref (secrets_dict); + g_variant_unref (filtered_secrets); } else { - _LOGD ("(%s:%u) failed to update with existing secrets: (%d) %s", + _LOGD ("(%s:%p) failed to update with existing secrets: (%d) %s", setting_name, - call_id, + info, local ? local->code : -1, (local && local->message) ? local->message : "(unknown)"); } - callback (self, call_id, agent_username, setting_name, local, callback_data); + applied_connection = info->applied_connection; + if (applied_connection) { + get_cmp_flags (self, + info, + applied_connection, + agent_dbus_owner, + agent_has_modify, + setting_name, + flags, + secrets, + &agent_had_system, + &cmp_flags); + + nm_connection_clear_secrets (applied_connection); + + if (!dict || nm_connection_update_secrets (applied_connection, setting_name, dict, NULL)) { + GVariant *filtered_secrets; + + filtered_secrets = for_each_secret (applied_connection, secrets, TRUE, validate_secret_flags, &cmp_flags); + nm_connection_update_secrets (applied_connection, setting_name, filtered_secrets, NULL); + g_variant_unref (filtered_secrets); + } + } + + _get_secrets_info_callback (info, agent_username, setting_name, local); g_clear_error (&local); if (dict) g_variant_unref (dict); + +out: + _get_secrets_info_free (info); +} + +static gboolean +get_secrets_idle_cb (GetSecretsInfo *info) +{ + NMSettingsConnectionPrivate *priv; + + g_return_val_if_fail (info && NM_IS_SETTINGS_CONNECTION (info->self), G_SOURCE_REMOVE); + + priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (info->self); + + g_return_val_if_fail (g_slist_find (priv->get_secret_requests, info), G_SOURCE_REMOVE); + + priv->get_secret_requests = g_slist_remove (priv->get_secret_requests, info); + + _get_secrets_info_callback (info, NULL, NULL, info->t.idle.error); + + _get_secrets_info_free (info); + return G_SOURCE_REMOVE; } /** * nm_settings_connection_get_secrets: * @self: the #NMSettingsConnection + * @applied_connection: (allow-none): if provided, only request secrets + * if @self equals to @applied_connection. Also, update the secrets + * in the @applied_connection. * @subject: the #NMAuthSubject originating the request * @setting_name: the setting to return secrets for * @flags: flags to modify the secrets request @@ -937,86 +1171,140 @@ agent_secrets_done_cb (NMAgentManager *manager, * Retrieves secrets from persistent storage and queries any secret agents for * additional secrets. * - * Returns: a call ID which may be used to cancel the ongoing secrets request + * With the returned call-id, the call can be cancelled. It is an error + * to cancel a call more then once or a call that already completed. + * The callback will always be invoked exactly once, also for cancellation + * and disposing of @self. In those latter cases, the callback will be invoked + * synchronously during cancellation/disposing. + * + * Returns: a call ID which may be used to cancel the ongoing secrets request. **/ -guint32 +NMSettingsConnectionCallId nm_settings_connection_get_secrets (NMSettingsConnection *self, + NMConnection *applied_connection, NMAuthSubject *subject, const char *setting_name, NMSecretAgentGetSecretsFlags flags, const char **hints, NMSettingsConnectionSecretsFunc callback, - gpointer callback_data, - GError **error) + gpointer callback_data) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); GVariant *existing_secrets; - GHashTable *existing_secrets_hash; - guint32 call_id = 0; + NMAgentManagerCallId call_id_a; gs_free char *joined_hints = NULL; + GetSecretsInfo *info; + GError *local = NULL; + + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NULL); + g_return_val_if_fail ( !applied_connection + || ( NM_IS_CONNECTION (applied_connection) + && (((NMConnection *) self) != applied_connection)), NULL); + + info = _get_secrets_info_new (self, + applied_connection, + callback, + callback_data); + + priv->get_secret_requests = g_slist_append (priv->get_secret_requests, info); /* Use priv->secrets to work around the fact that nm_connection_clear_secrets() * will clear secrets on this object's settings. */ if (!priv->system_secrets) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d - Internal error; secrets cache invalid.", - __FILE__, __LINE__); - return 0; + g_set_error_literal (&local, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "secrets cache invalid"); + goto schedule_dummy; } /* Make sure the request actually requests something we can return */ if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) { - g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, - "%s.%d - Connection didn't have requested setting '%s'.", - __FILE__, __LINE__, setting_name); - return 0; + g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND, + "Connection didn't have requested setting '%s'.", + setting_name); + goto schedule_dummy; + } + + if ( applied_connection + && !nm_settings_connection_has_unmodified_applied_connection (self, applied_connection, NM_SETTING_COMPARE_FLAG_NONE)) { + g_set_error_literal (&local, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "The connection was modified since activation"); + goto schedule_dummy; } existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS); - existing_secrets_hash = nm_utils_connection_dict_to_hash (existing_secrets); - call_id = nm_agent_manager_get_secrets (priv->agent_mgr, - NM_CONNECTION (self), - subject, - existing_secrets_hash, - setting_name, - flags, - hints, - agent_secrets_done_cb, - self, - callback, - callback_data); - if (existing_secrets_hash) - g_hash_table_unref (existing_secrets_hash); + if (existing_secrets) + g_variant_ref_sink (existing_secrets); + call_id_a = nm_agent_manager_get_secrets (priv->agent_mgr, + nm_connection_get_path (NM_CONNECTION (self)), + NM_CONNECTION (self), + subject, + existing_secrets, + setting_name, + flags, + hints, + get_secrets_done_cb, + info); + g_assert (call_id_a); if (existing_secrets) g_variant_unref (existing_secrets); - _LOGD ("(%s:%u) secrets requested flags 0x%X hints '%s'", + _LOGD ("(%s:%p) secrets requested flags 0x%X hints '%s'", setting_name, - call_id, + call_id_a, flags, (hints && hints[0]) ? (joined_hints = g_strjoinv (",", (char **) hints)) : "(none)"); - return call_id; + if (call_id_a) { + info->type = GET_SECRETS_INFO_TYPE_REQ; + info->t.req.id = call_id_a; + } else { +schedule_dummy: + info->type = GET_SECRETS_INFO_TYPE_IDLE; + g_propagate_error (&info->t.idle.error, local); + info->t.idle.id = g_idle_add ((GSourceFunc) get_secrets_idle_cb, info); + } + return info; } -void -nm_settings_connection_cancel_secrets (NMSettingsConnection *self, - guint32 call_id) +static void +_get_secrets_cancel (NMSettingsConnection *self, + GetSecretsInfo *info, + gboolean is_disposing) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + gs_free_error GError *error = NULL; + + if (!g_slist_find (priv->get_secret_requests, info)) + g_return_if_reached (); + + priv->get_secret_requests = g_slist_remove (priv->get_secret_requests, info); + + if (info->type == GET_SECRETS_INFO_TYPE_REQ) + nm_agent_manager_cancel_secrets (priv->agent_mgr, info->t.req.id); + else + g_source_remove (info->t.idle.id); - _LOGD ("(%u) secrets canceled", - call_id); + nm_utils_error_set_cancelled (&error, is_disposing, "NMSettingsConnection"); - priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id)); - nm_agent_manager_cancel_secrets (priv->agent_mgr, call_id); + _get_secrets_info_callback (info, NULL, NULL, error); + + _get_secrets_info_free (info); +} + +void +nm_settings_connection_cancel_secrets (NMSettingsConnection *self, + NMSettingsConnectionCallId call_id) +{ + _LOGD ("(%p) secrets canceled", call_id); + + _get_secrets_cancel (self, call_id, FALSE); } /**** User authorization **************************************/ typedef void (*AuthCallback) (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer data); @@ -1024,7 +1312,7 @@ typedef void (*AuthCallback) (NMSettingsConnection *self, static void pk_auth_cb (NMAuthChain *chain, GError *chain_error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, gpointer user_data) { NMSettingsConnection *self = NM_SETTINGS_CONNECTION (user_data); @@ -1073,7 +1361,7 @@ pk_auth_cb (NMAuthChain *chain, * Returns: the #NMAuthSubject on success, or %NULL on failure and sets @error */ static NMAuthSubject * -_new_auth_subject (DBusGMethodInvocation *context, GError **error) +_new_auth_subject (GDBusMethodInvocation *context, GError **error) { NMAuthSubject *subject; @@ -1090,7 +1378,7 @@ _new_auth_subject (DBusGMethodInvocation *context, GError **error) static void auth_start (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, const char *check_permission, AuthCallback callback, @@ -1106,7 +1394,6 @@ auth_start (NMSettingsConnection *self, /* Ensure the caller can view this connection */ if (!nm_auth_is_subject_in_acl (NM_CONNECTION (self), - priv->session_monitor, subject, &error_desc)) { error = g_error_new_literal (NM_SETTINGS_ERROR, @@ -1179,16 +1466,15 @@ check_writable (NMConnection *self, GError **error) static void get_settings_auth_cb (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer data) { if (error) - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (context, error); else { GVariant *settings; - GHashTable *settings_hash; NMConnection *dupl_con; NMSettingConnection *s_con; NMSettingWireless *s_wifi; @@ -1226,17 +1512,15 @@ get_settings_auth_cb (NMSettingsConnection *self, */ settings = nm_connection_to_dbus (NM_CONNECTION (dupl_con), NM_CONNECTION_SERIALIZE_NO_SECRETS); g_assert (settings); - settings_hash = nm_utils_connection_dict_to_hash (settings); - dbus_g_method_return (context, settings_hash); - g_hash_table_destroy (settings_hash); - g_variant_unref (settings); + g_dbus_method_invocation_return_value (context, + g_variant_new ("(@a{sa{sv}})", settings)); g_object_unref (dupl_con); } } static void impl_settings_connection_get_settings (NMSettingsConnection *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { NMAuthSubject *subject; GError *error = NULL; @@ -1245,20 +1529,23 @@ impl_settings_connection_get_settings (NMSettingsConnection *self, if (subject) { auth_start (self, context, subject, NULL, get_settings_auth_cb, NULL); g_object_unref (subject); - } else { - dbus_g_method_return_error (context, error); - g_error_free (error); - } + } else + g_dbus_method_invocation_take_error (context, error); } typedef struct { - DBusGMethodInvocation *context; + GDBusMethodInvocation *context; NMAgentManager *agent_mgr; NMAuthSubject *subject; NMConnection *new_settings; gboolean save_to_disk; } UpdateInfo; +typedef struct { + GDBusMethodInvocation *context; + NMAuthSubject *subject; +} CallbackInfo; + static void has_some_secrets_cb (NMSetting *setting, const char *key, @@ -1319,9 +1606,12 @@ update_complete (NMSettingsConnection *self, GError *error) { if (error) - dbus_g_method_return_error (info->context, error); + g_dbus_method_invocation_return_gerror (info->context, error); else - dbus_g_method_return (info->context); + g_dbus_method_invocation_return_value (info->context, NULL); + + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_UPDATE, self, !error, + info->subject, error ? error->message : NULL); g_clear_object (&info->subject); g_clear_object (&info->agent_mgr); @@ -1347,7 +1637,10 @@ con_update_cb (NMSettingsConnection *self, nm_connection_clear_secrets_with_flags (for_agent, secrets_filter_cb, GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED)); - nm_agent_manager_save_secrets (info->agent_mgr, for_agent, info->subject); + nm_agent_manager_save_secrets (info->agent_mgr, + nm_connection_get_path (NM_CONNECTION (self)), + for_agent, + info->subject); g_object_unref (for_agent); } @@ -1356,7 +1649,7 @@ con_update_cb (NMSettingsConnection *self, static void update_auth_cb (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer data) @@ -1424,8 +1717,8 @@ get_update_modify_permission (NMConnection *old, NMConnection *new) static void impl_settings_connection_update_helper (NMSettingsConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, + GVariant *new_settings, gboolean save_to_disk) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); @@ -1447,14 +1740,9 @@ impl_settings_connection_update_helper (NMSettingsConnection *self, /* Check if the settings are valid first */ if (new_settings) { - GVariant *new_settings_dict = nm_utils_connection_hash_to_dict (new_settings); - - tmp = nm_simple_connection_new_from_dbus (new_settings_dict, &error); - g_variant_unref (new_settings_dict); - if (!tmp) { - g_assert (error); + tmp = nm_simple_connection_new_from_dbus (new_settings, &error); + if (!tmp) goto error; - } } subject = _new_auth_subject (context, &error); @@ -1466,7 +1754,6 @@ impl_settings_connection_update_helper (NMSettingsConnection *self, * invisible to yourself. */ if (!nm_auth_is_subject_in_acl (tmp ? tmp : NM_CONNECTION (self), - priv->session_monitor, subject, &error_desc)) { error = g_error_new_literal (NM_SETTINGS_ERROR, @@ -1489,40 +1776,40 @@ impl_settings_connection_update_helper (NMSettingsConnection *self, return; error: + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_UPDATE, self, FALSE, subject, + error->message); + g_clear_object (&tmp); g_clear_object (&subject); - dbus_g_method_return_error (context, error); - g_clear_error (&error); + g_dbus_method_invocation_take_error (context, error); } static void impl_settings_connection_update (NMSettingsConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + GVariant *new_settings) { - g_assert (new_settings); - impl_settings_connection_update_helper (self, new_settings, context, TRUE); + impl_settings_connection_update_helper (self, context, new_settings, TRUE); } static void impl_settings_connection_update_unsaved (NMSettingsConnection *self, - GHashTable *new_settings, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + GVariant *new_settings) { - g_assert (new_settings); - impl_settings_connection_update_helper (self, new_settings, context, FALSE); + impl_settings_connection_update_helper (self, context, new_settings, FALSE); } static void impl_settings_connection_save (NMSettingsConnection *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { /* Do nothing if the connection is already synced with disk */ if (nm_settings_connection_get_unsaved (self)) - impl_settings_connection_update_helper (self, NULL, context, TRUE); + impl_settings_connection_update_helper (self, context, NULL, TRUE); else - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (context, NULL); } static void @@ -1530,27 +1817,39 @@ con_delete_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { - DBusGMethodInvocation *context = user_data; + CallbackInfo *info = user_data; if (error) - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (info->context, error); else - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (info->context, NULL); + + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, + !error, info->subject, error ? error->message : NULL); + g_free (info); } static void delete_auth_cb (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer data) { + CallbackInfo *info; + if (error) { - dbus_g_method_return_error (context, error); + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, subject, + error->message); + g_dbus_method_invocation_return_gerror (context, error); return; } - nm_settings_connection_delete (self, con_delete_cb, context); + info = g_malloc0 (sizeof (*info)); + info->context = context; + info->subject = subject; + + nm_settings_connection_delete (self, con_delete_cb, info); } static const char * @@ -1572,46 +1871,42 @@ get_modify_permission_basic (NMSettingsConnection *self) static void impl_settings_connection_delete (NMSettingsConnection *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { - NMAuthSubject *subject; + NMAuthSubject *subject = NULL; GError *error = NULL; - - if (!check_writable (NM_CONNECTION (self), &error)) { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } + + if (!check_writable (NM_CONNECTION (self), &error)) + goto out_err; subject = _new_auth_subject (context, &error); if (subject) { auth_start (self, context, subject, get_modify_permission_basic (self), delete_auth_cb, NULL); g_object_unref (subject); - } else { - dbus_g_method_return_error (context, error); - g_error_free (error); - } + } else + goto out_err; + + return; +out_err: + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, self, FALSE, subject, error->message); + g_dbus_method_invocation_take_error (context, error); } /**************************************************************/ static void dbus_get_agent_secrets_cb (NMSettingsConnection *self, - guint32 call_id, + NMSettingsConnectionCallId call_id, const char *agent_username, const char *setting_name, GError *error, gpointer user_data) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - DBusGMethodInvocation *context = user_data; + GDBusMethodInvocation *context = user_data; GVariant *dict; - GHashTable *hash; - - priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id)); if (error) - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (context, error); else { /* Return secrets from agent and backing storage to the D-Bus caller; * nm_settings_connection_get_secrets() will have updated itself with @@ -1619,57 +1914,43 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self, * by the time we get here. */ dict = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS); - if (dict) - hash = nm_utils_connection_dict_to_hash (dict); - else - hash = g_hash_table_new (NULL, NULL); - dbus_g_method_return (context, hash); - g_hash_table_destroy (hash); - if (dict) - g_variant_unref (dict); + if (!dict) + dict = g_variant_new_array (G_VARIANT_TYPE ("{sa{sv}}"), NULL, 0); + g_dbus_method_invocation_return_value (context, g_variant_new ("(@a{sa{sv}})", dict)); } } static void -dbus_get_secrets_auth_cb (NMSettingsConnection *self, - DBusGMethodInvocation *context, +dbus_get_secrets_auth_cb (NMSettingsConnection *self, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer user_data) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); char *setting_name = user_data; - guint32 call_id = 0; - GError *local = NULL; if (!error) { - call_id = nm_settings_connection_get_secrets (self, - subject, - setting_name, - NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED - | NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS, - NULL, - dbus_get_agent_secrets_cb, - context, - &local); - if (call_id > 0) { - /* track the request and wait for the callback */ - priv->reqs = g_slist_append (priv->reqs, GUINT_TO_POINTER (call_id)); - } + nm_settings_connection_get_secrets (self, + NULL, + subject, + setting_name, + NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED + | NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS, + NULL, + dbus_get_agent_secrets_cb, + context); } - if (error || local) { - dbus_g_method_return_error (context, error ? error : local); - g_clear_error (&local); - } + if (error) + g_dbus_method_invocation_return_gerror (context, error); g_free (setting_name); } static void impl_settings_connection_get_secrets (NMSettingsConnection *self, - const gchar *setting_name, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + const gchar *setting_name) { NMAuthSubject *subject; GError *error = NULL; @@ -1683,10 +1964,8 @@ impl_settings_connection_get_secrets (NMSettingsConnection *self, dbus_get_secrets_auth_cb, g_strdup (setting_name)); g_object_unref (subject); - } else { - dbus_g_method_return_error (context, error); - g_error_free (error); - } + } else + g_dbus_method_invocation_take_error (context, error); } static void @@ -1694,26 +1973,33 @@ clear_secrets_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { - DBusGMethodInvocation *context = (DBusGMethodInvocation *) user_data; + CallbackInfo *info = user_data; if (error) - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_return_gerror (info->context, error); else - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (info->context, NULL); + + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self, + !error, info->subject, error ? error->message : NULL); + g_free (info); } static void dbus_clear_secrets_auth_cb (NMSettingsConnection *self, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMAuthSubject *subject, GError *error, gpointer user_data) { NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + CallbackInfo *info; - if (error) - dbus_g_method_return_error (context, error); - else { + if (error) { + g_dbus_method_invocation_return_gerror (context, error); + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self, + FALSE, subject, error->message); + } else { /* Clear secrets in connection and caches */ nm_connection_clear_secrets (NM_CONNECTION (self)); if (priv->system_secrets) @@ -1722,15 +2008,21 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self, nm_connection_clear_secrets (priv->agent_secrets); /* Tell agents to remove secrets for this connection */ - nm_agent_manager_delete_secrets (priv->agent_mgr, NM_CONNECTION (self)); + nm_agent_manager_delete_secrets (priv->agent_mgr, + nm_connection_get_path (NM_CONNECTION (self)), + NM_CONNECTION (self)); - nm_settings_connection_commit_changes (self, clear_secrets_cb, context); + info = g_malloc0 (sizeof (*info)); + info->context = context; + info->subject = subject; + + nm_settings_connection_commit_changes (self, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, clear_secrets_cb, info); } } static void impl_settings_connection_clear_secrets (NMSettingsConnection *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { NMAuthSubject *subject; GError *error = NULL; @@ -1745,8 +2037,9 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self, NULL); g_object_unref (subject); } else { - dbus_g_method_return_error (context, error); - g_error_free (error); + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, self, + FALSE, NULL, error->message); + g_dbus_method_invocation_take_error (context, error); } } @@ -1760,14 +2053,7 @@ nm_settings_connection_signal_remove (NMSettingsConnection *self) if (priv->removed) g_return_if_reached (); priv->removed = TRUE; - - /* Emit removed first */ g_signal_emit_by_name (self, NM_SETTINGS_CONNECTION_REMOVED); - - /* And unregistered last to ensure the removed signal goes out before - * we take the connection off the bus. - */ - nm_dbus_manager_unregister_object (nm_dbus_manager_get (), G_OBJECT (self)); } gboolean @@ -1883,7 +2169,7 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *self, g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); + connection_uuid = nm_settings_connection_get_uuid (self); tmp = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp); g_key_file_set_value (timestamps_file, "timestamps", connection_uuid, tmp); g_free (tmp); @@ -1922,7 +2208,7 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self) /* Get timestamp from database file */ timestamps_file = g_key_file_new (); g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL); - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); + connection_uuid = nm_settings_connection_get_uuid (self); tmp_str = g_key_file_get_value (timestamps_file, "timestamps", connection_uuid, &err); if (tmp_str) { timestamp = g_ascii_strtoull (tmp_str, NULL, 10); @@ -2037,7 +2323,7 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *self, g_clear_error (&error); } - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); + connection_uuid = nm_settings_connection_get_uuid (self); g_key_file_set_string_list (seen_bssids_file, "seen-bssids", connection_uuid, list, n); g_free (list); @@ -2076,7 +2362,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self) seen_bssids_file = g_key_file_new (); g_key_file_set_list_separator (seen_bssids_file, ','); if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) { - connection_uuid = nm_connection_get_uuid (NM_CONNECTION (self)); + connection_uuid = nm_settings_connection_get_uuid (self); tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL); } g_key_file_free (seen_bssids_file); @@ -2266,6 +2552,18 @@ nm_settings_connection_get_filename (NMSettingsConnection *self) return priv->filename; } +const char * +nm_settings_connection_get_id (NMSettingsConnection *self) +{ + return nm_connection_get_id (NM_CONNECTION (self)); +} + +const char * +nm_settings_connection_get_uuid (NMSettingsConnection *self) +{ + return nm_connection_get_uuid (NM_CONNECTION (self)); +} + /**************************************************************/ static void @@ -2276,11 +2574,8 @@ nm_settings_connection_init (NMSettingsConnection *self) priv->visible = FALSE; priv->ready = TRUE; - priv->session_monitor = nm_session_monitor_get (); - priv->session_changed_id = g_signal_connect (priv->session_monitor, - NM_SESSION_MONITOR_CHANGED, - G_CALLBACK (session_changed_cb), - self); + priv->session_monitor = g_object_ref (nm_session_monitor_get ()); + priv->session_changed_id = nm_session_monitor_connect (priv->session_monitor, session_changed_cb, self); priv->agent_mgr = g_object_ref (nm_agent_manager_get ()); @@ -2308,15 +2603,21 @@ dispose (GObject *object) { NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); - GSList *iter; _LOGD ("disposing"); - if (priv->updated_idle_id) { - g_source_remove (priv->updated_idle_id); - priv->updated_idle_id = 0; + /* Cancel in-progress secrets requests */ + if (priv->agent_mgr) { + while (priv->get_secret_requests) { + GetSecretsInfo *info = priv->get_secret_requests->data; + + _get_secrets_cancel (self, info, TRUE); + g_return_if_fail (!priv->get_secret_requests || (info != priv->get_secret_requests->data)); + } } + nm_clear_g_source (&priv->updated_idle_id); + /* Disconnect handlers. * changed_cb() has to be disconnected *before* nm_connection_clear_secrets(), * because nm_connection_clear_secrets() emits NM_CONNECTION_CHANGED signal. @@ -2332,19 +2633,14 @@ dispose (GObject *object) g_slist_free_full (priv->pending_auths, (GDestroyNotify) nm_auth_chain_unref); priv->pending_auths = NULL; - /* Cancel in-progress secrets requests */ - for (iter = priv->reqs; iter; iter = g_slist_next (iter)) - nm_agent_manager_cancel_secrets (priv->agent_mgr, GPOINTER_TO_UINT (iter->data)); - g_slist_free (priv->reqs); - priv->reqs = NULL; - g_clear_pointer (&priv->seen_bssids, (GDestroyNotify) g_hash_table_destroy); set_visible (self, FALSE); - if (priv->session_changed_id) { - g_signal_handler_disconnect (priv->session_monitor, priv->session_changed_id); + if (priv->session_monitor) { + nm_session_monitor_disconnect (priv->session_monitor, priv->session_changed_id); priv->session_changed_id = 0; + g_clear_object (&priv->session_monitor); } g_clear_object (&priv->agent_mgr); @@ -2408,9 +2704,12 @@ static void nm_settings_connection_class_init (NMSettingsConnectionClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (class); g_type_class_add_private (class, sizeof (NMSettingsConnectionPrivate)); + exported_object_class->export_path = NM_DBUS_PATH_SETTINGS "/%u"; + /* Virtual methods */ object_class->constructed = constructed; object_class->dispose = dispose; @@ -2490,9 +2789,16 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), - G_TYPE_FROM_CLASS (class), - &dbus_glib_nm_settings_connection_object_info); + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class), + NMDBUS_TYPE_SETTINGS_CONNECTION_SKELETON, + "Update", impl_settings_connection_update, + "UpdateUnsaved", impl_settings_connection_update_unsaved, + "Delete", impl_settings_connection_delete, + "GetSettings", impl_settings_connection_get_settings, + "GetSecrets", impl_settings_connection_get_secrets, + "ClearSecrets", impl_settings_connection_clear_secrets, + "Save", impl_settings_connection_save, + NULL); } static void diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 512112f0..5c12a8ac 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -24,8 +24,9 @@ #include <net/ethernet.h> +#include "nm-exported-object.h" #include <nm-connection.h> -#include "nm-types.h" +#include "nm-default.h" G_BEGIN_DECLS @@ -78,6 +79,14 @@ typedef enum NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1, } NMSettingsConnectionFlags; +typedef enum { /*< skip >*/ + NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE = 0, + NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION = (1LL << 0), + NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED = (1LL << 1), +} NMSettingsConnectionCommitReason; + +struct _NMSettingsConnectionCallId; +typedef struct _NMSettingsConnectionCallId *NMSettingsConnectionCallId; typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass; @@ -90,11 +99,11 @@ typedef void (*NMSettingsConnectionDeleteFunc) (NMSettingsConnection *self, gpointer user_data); struct _NMSettingsConnection { - GObject parent; + NMExportedObject parent; }; struct _NMSettingsConnectionClass { - GObjectClass parent; + NMExportedObjectClass parent; /* virtual methods */ void (*replace_and_commit) (NMSettingsConnection *self, @@ -103,6 +112,7 @@ struct _NMSettingsConnectionClass { gpointer user_data); void (*commit_changes) (NMSettingsConnection *self, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data); @@ -116,7 +126,12 @@ struct _NMSettingsConnectionClass { GType nm_settings_connection_get_type (void); +gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self, + NMConnection *applied_connection, + NMSettingCompareFlags compare_flage); + void nm_settings_connection_commit_changes (NMSettingsConnection *self, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data); @@ -136,23 +151,23 @@ void nm_settings_connection_delete (NMSettingsConnection *self, gpointer user_data); typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self, - guint32 call_id, + NMSettingsConnectionCallId call_id, const char *agent_username, const char *setting_name, GError *error, gpointer user_data); -guint32 nm_settings_connection_get_secrets (NMSettingsConnection *self, - NMAuthSubject *subject, - const char *setting_name, - NMSecretAgentGetSecretsFlags flags, - const char **hints, - NMSettingsConnectionSecretsFunc callback, - gpointer callback_data, - GError **error); +NMSettingsConnectionCallId nm_settings_connection_get_secrets (NMSettingsConnection *self, + NMConnection *applied_connection, + NMAuthSubject *subject, + const char *setting_name, + NMSecretAgentGetSecretsFlags flags, + const char **hints, + NMSettingsConnectionSecretsFunc callback, + gpointer callback_data); void nm_settings_connection_cancel_secrets (NMSettingsConnection *self, - guint32 call_id); + NMSettingsConnectionCallId call_id); gboolean nm_settings_connection_is_visible (NMSettingsConnection *self); @@ -212,6 +227,9 @@ void nm_settings_connection_set_filename (NMSettingsConnection *self, const char *filename); const char *nm_settings_connection_get_filename (NMSettingsConnection *self); +const char *nm_settings_connection_get_id (NMSettingsConnection *connection); +const char *nm_settings_connection_get_uuid (NMSettingsConnection *connection); + G_END_DECLS #endif /* __NETWORKMANAGER_SETTINGS_CONNECTION_H__ */ diff --git a/src/settings/nm-settings-plugin.c b/src/settings/nm-settings-plugin.c new file mode 100644 index 00000000..0bce8957 --- /dev/null +++ b/src/settings/nm-settings-plugin.c @@ -0,0 +1,179 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + */ + +#include "config.h" + +#include "nm-settings-plugin.h" +#include "nm-settings-connection.h" + +G_DEFINE_INTERFACE (NMSettingsPlugin, nm_settings_plugin, G_TYPE_OBJECT) + +static void +nm_settings_plugin_default_init (NMSettingsPluginInterface *g_iface) +{ + GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); + static gboolean initialized = FALSE; + + if (initialized) + return; + + /* Properties */ + g_object_interface_install_property + (g_iface, + g_param_spec_string (NM_SETTINGS_PLUGIN_NAME, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property + (g_iface, + g_param_spec_string (NM_SETTINGS_PLUGIN_INFO, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property + (g_iface, + g_param_spec_uint (NM_SETTINGS_PLUGIN_CAPABILITIES, "", "", + NM_SETTINGS_PLUGIN_CAP_NONE, + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS, + NM_SETTINGS_PLUGIN_CAP_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + /* Signals */ + g_signal_new (NM_SETTINGS_PLUGIN_CONNECTION_ADDED, + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMSettingsPluginInterface, connection_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + NM_TYPE_SETTINGS_CONNECTION); + + g_signal_new (NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED, + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMSettingsPluginInterface, unmanaged_specs_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_signal_new (NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED, + iface_type, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMSettingsPluginInterface, unrecognized_specs_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + initialized = TRUE; +} + +void +nm_settings_plugin_init (NMSettingsPlugin *config) +{ + g_return_if_fail (config != NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->init) + NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->init (config); +} + +GSList * +nm_settings_plugin_get_connections (NMSettingsPlugin *config) +{ + g_return_val_if_fail (config != NULL, NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_connections) + return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_connections (config); + return NULL; +} + +gboolean +nm_settings_plugin_load_connection (NMSettingsPlugin *config, + const char *filename) +{ + g_return_val_if_fail (config != NULL, FALSE); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->load_connection) + return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->load_connection (config, filename); + return FALSE; +} + +void +nm_settings_plugin_reload_connections (NMSettingsPlugin *config) +{ + g_return_if_fail (config != NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->reload_connections) + NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->reload_connections (config); +} + +GSList * +nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *config) +{ + g_return_val_if_fail (config != NULL, NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unmanaged_specs) + return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unmanaged_specs (config); + return NULL; +} + +GSList * +nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *config) +{ + g_return_val_if_fail (config != NULL, NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unrecognized_specs) + return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->get_unrecognized_specs (config); + return NULL; +} + +/** + * nm_settings_plugin_add_connection: + * @config: the #NMSettingsPlugin + * @connection: the source connection to create a plugin-specific + * #NMSettingsConnection from + * @save_to_disk: %TRUE to save the connection to disk immediately, %FALSE to + * not save to disk + * @error: on return, a location to store any errors that may occur + * + * Creates a new #NMSettingsConnection for the given source @connection. If the + * plugin cannot handle the given connection type, it should return %NULL and + * set @error. The plugin owns the returned object and the caller must reference + * the object if it wishes to continue using it. + * + * Returns: the new #NMSettingsConnection or %NULL + */ +NMSettingsConnection * +nm_settings_plugin_add_connection (NMSettingsPlugin *config, + NMConnection *connection, + gboolean save_to_disk, + GError **error) +{ + g_return_val_if_fail (config != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection) + return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection (config, connection, save_to_disk, error); + + return NULL; +} diff --git a/src/settings/nm-settings-plugin.h b/src/settings/nm-settings-plugin.h new file mode 100644 index 00000000..ab88e7c2 --- /dev/null +++ b/src/settings/nm-settings-plugin.h @@ -0,0 +1,161 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager system settings service + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2008 Novell, Inc. + */ + +#ifndef __NETWORKMANAGER_SETTINGS_PLUGIN_H__ +#define __NETWORKMANAGER_SETTINGS_PLUGIN_H__ + + +#include <nm-connection.h> +#include "nm-default.h" + +G_BEGIN_DECLS + +/* Plugin's factory function that returns a GObject that implements + * NMSettingsPlugin. + */ +GObject * nm_settings_plugin_factory (void); + +#define NM_TYPE_SETTINGS_PLUGIN (nm_settings_plugin_get_type ()) +#define NM_SETTINGS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPlugin)) +#define NM_IS_SETTINGS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTINGS_PLUGIN)) +#define NM_SETTINGS_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SETTINGS_PLUGIN, NMSettingsPluginInterface)) + + +#define NM_SETTINGS_PLUGIN_NAME "name" +#define NM_SETTINGS_PLUGIN_INFO "info" +#define NM_SETTINGS_PLUGIN_CAPABILITIES "capabilities" + +#define NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed" +#define NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED "unrecognized-specs-changed" +#define NM_SETTINGS_PLUGIN_CONNECTION_ADDED "connection-added" + +typedef enum { + NM_SETTINGS_PLUGIN_CAP_NONE = 0x00000000, + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS = 0x00000001, + + /* When adding more capabilities, be sure to update the "Capabilities" + * property max value in nm-settings-plugin.c. + */ +} NMSettingsPluginCapabilities; + +typedef enum { + NM_SETTINGS_PLUGIN_PROP_FIRST = 0x1000, + + NM_SETTINGS_PLUGIN_PROP_NAME = NM_SETTINGS_PLUGIN_PROP_FIRST, + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, +} NMSettingsPluginProp; + + +typedef struct _NMSettingsPlugin NMSettingsPlugin; + +typedef struct { + GTypeInterface g_iface; + + /* Called when the plugin is loaded to initialize it */ + void (*init) (NMSettingsPlugin *config); + + /* Returns a GSList of NMSettingsConnection objects that represent + * connections the plugin knows about. The returned list is freed by the + * system settings service. + */ + GSList * (*get_connections) (NMSettingsPlugin *config); + + /* Requests that the plugin load/reload a single connection, if it + * recognizes the filename. Returns success or failure. + */ + gboolean (*load_connection) (NMSettingsPlugin *config, + const char *filename); + + /* Requests that the plugin reload all connection files from disk, + * and emit signals reflecting new, changed, and removed connections. + */ + void (*reload_connections) (NMSettingsPlugin *config); + + /* + * Return a string list of specifications of devices which NetworkManager + * should not manage. Returned list will be freed by the system settings + * service, and each element must be allocated using g_malloc() or its + * variants (g_strdup, g_strdup_printf, etc). + * + * Each string in the list must be in one of the formats recognized by + * nm_device_spec_match_list(). + */ + GSList * (*get_unmanaged_specs) (NMSettingsPlugin *config); + + /* + * Return a string list of specifications of devices for which at least + * one non-NetworkManager-based configuration is defined. Returned list + * will be freed by the system settings service, and each element must be + * allocated using g_malloc() or its variants (g_strdup, g_strdup_printf, + * etc). + * + * Each string in the list must be in one of the formats recognized by + * nm_device_spec_match_list(). + */ + GSList * (*get_unrecognized_specs) (NMSettingsPlugin *config); + + /* + * Initialize the plugin-specific connection and return a new + * NMSettingsConnection subclass that contains the same settings as the + * original connection. The connection should only be saved to backing + * storage if @save_to_disk is TRUE. The returned object is owned by the + * plugin and must be referenced by the owner if necessary. + */ + NMSettingsConnection * (*add_connection) (NMSettingsPlugin *config, + NMConnection *connection, + gboolean save_to_disk, + GError **error); + + /* Signals */ + + /* Emitted when a new connection has been found by the plugin */ + void (*connection_added) (NMSettingsPlugin *config, + NMSettingsConnection *connection); + + /* Emitted when the list of unmanaged device specifications changes */ + void (*unmanaged_specs_changed) (NMSettingsPlugin *config); + + /* Emitted when the list of devices with unrecognized connections changes */ + void (*unrecognized_specs_changed) (NMSettingsPlugin *config); +} NMSettingsPluginInterface; + +GType nm_settings_plugin_get_type (void); + +void nm_settings_plugin_init (NMSettingsPlugin *config); + +GSList *nm_settings_plugin_get_connections (NMSettingsPlugin *config); + +gboolean nm_settings_plugin_load_connection (NMSettingsPlugin *config, + const char *filename); +void nm_settings_plugin_reload_connections (NMSettingsPlugin *config); + +GSList *nm_settings_plugin_get_unmanaged_specs (NMSettingsPlugin *config); +GSList *nm_settings_plugin_get_unrecognized_specs (NMSettingsPlugin *config); + +NMSettingsConnection *nm_settings_plugin_add_connection (NMSettingsPlugin *config, + NMConnection *connection, + gboolean save_to_disk, + GError **error); + +G_END_DECLS + +#endif /* NM_SETTINGS_PLUGIN_H */ diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index f20bc71b..f6f8c374 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -31,10 +31,11 @@ #include <string.h> #include <gmodule.h> #include <pwd.h> -#include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> -#include "gsystem-local-alloc.h" +#if HAVE_SELINUX +#include <selinux/selinux.h> +#endif + #include <nm-dbus-interface.h> #include <nm-connection.h> #include <nm-setting-8021x.h> @@ -58,12 +59,11 @@ #include "nm-core-internal.h" #include "nm-device-ethernet.h" -#include "nm-dbus-glib-types.h" #include "nm-settings.h" #include "nm-settings-connection.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" -#include "nm-dbus-manager.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" +#include "nm-bus-manager.h" #include "nm-auth-utils.h" #include "nm-auth-subject.h" #include "nm-session-monitor.h" @@ -71,7 +71,11 @@ #include "nm-agent-manager.h" #include "nm-connection-provider.h" #include "nm-config.h" +#include "nm-audit-manager.h" #include "NetworkManagerUtils.h" +#include "nm-dispatcher.h" + +#include "nmdbus-settings.h" #define LOG(level, ...) \ G_STMT_START { \ @@ -94,52 +98,39 @@ EXPORT(nm_settings_connection_replace_settings) EXPORT(nm_settings_connection_replace_and_commit) /* END LINKER CRACKROCK */ -#define PLUGIN_MODULE_PATH "plugin-module-path" - -static void claim_connection (NMSettings *self, - NMSettingsConnection *connection); - -static gboolean impl_settings_list_connections (NMSettings *self, - GPtrArray **connections, - GError **error); - -static void impl_settings_get_connection_by_uuid (NMSettings *self, - const char *uuid, - DBusGMethodInvocation *context); +#define HOSTNAMED_SERVICE_NAME "org.freedesktop.hostname1" +#define HOSTNAMED_SERVICE_PATH "/org/freedesktop/hostname1" +#define HOSTNAMED_SERVICE_INTERFACE "org.freedesktop.hostname1" -static void impl_settings_add_connection (NMSettings *self, - GHashTable *settings, - DBusGMethodInvocation *context); +#define HOSTNAME_FILE_DEFAULT "/etc/hostname" +#define HOSTNAME_FILE_SUSE "/etc/HOSTNAME" +#define HOSTNAME_FILE_GENTOO "/etc/conf.d/hostname" +#define IFCFG_DIR SYSCONFDIR "/sysconfig/network" +#define CONF_DHCP IFCFG_DIR "/dhcp" -static void impl_settings_add_connection_unsaved (NMSettings *self, - GHashTable *settings, - DBusGMethodInvocation *context); - -static void impl_settings_load_connections (NMSettings *self, - char **filenames, - DBusGMethodInvocation *context); - -static void impl_settings_reload_connections (NMSettings *self, - DBusGMethodInvocation *context); +#define PLUGIN_MODULE_PATH "plugin-module-path" -static void impl_settings_save_hostname (NMSettings *self, - const char *hostname, - DBusGMethodInvocation *context); +#if defined(HOSTNAME_PERSIST_SUSE) +#define HOSTNAME_FILE HOSTNAME_FILE_SUSE +#elif defined(HOSTNAME_PERSIST_GENTOO) +#define HOSTNAME_FILE HOSTNAME_FILE_GENTOO +#else +#define HOSTNAME_FILE HOSTNAME_FILE_DEFAULT +#endif -#include "nm-settings-glue.h" +static void claim_connection (NMSettings *self, + NMSettingsConnection *connection); -static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data); -static void unrecognized_specs_changed (NMSystemConfigInterface *config, gpointer user_data); +static void unmanaged_specs_changed (NMSettingsPlugin *config, gpointer user_data); +static void unrecognized_specs_changed (NMSettingsPlugin *config, gpointer user_data); -static void connection_provider_init (NMConnectionProvider *cp_class); +static void connection_provider_iface_init (NMConnectionProviderInterface *cp_iface); -G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_init)) +G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION_PROVIDER, connection_provider_iface_init)) typedef struct { - NMDBusManager *dbus_mgr; - NMAgentManager *agent_mgr; NMConfig *config; @@ -153,13 +144,23 @@ typedef struct { GSList *unrecognized_specs; GSList *get_connections_cache; + gboolean started; gboolean startup_complete; + + struct { + char *value; + char *file; + GFileMonitor *monitor; + GFileMonitor *dhcp_monitor; + gulong monitor_id; + gulong dhcp_monitor_id; + GDBusProxy *hostnamed_proxy; + } hostname; } NMSettingsPrivate; #define NM_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTINGS, NMSettingsPrivate)) enum { - PROPERTIES_CHANGED, CONNECTION_ADDED, CONNECTION_UPDATED, CONNECTION_UPDATED_BY_USER, @@ -215,7 +216,7 @@ connection_ready_changed (NMSettingsConnection *conn, } static void -plugin_connection_added (NMSystemConfigInterface *config, +plugin_connection_added (NMSettingsPlugin *config, NMSettingsConnection *connection, gpointer user_data) { @@ -229,11 +230,11 @@ load_connections (NMSettings *self) GSList *iter; for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { - NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data); + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); GSList *plugin_connections; GSList *elt; - plugin_connections = nm_system_config_interface_get_connections (plugin); + plugin_connections = nm_settings_plugin_get_connections (plugin); // FIXME: ensure connections from plugins loaded with a lower priority // get rejected when they conflict with connections from a higher @@ -244,11 +245,11 @@ load_connections (NMSettings *self) g_slist_free (plugin_connections); - g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, + g_signal_connect (plugin, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, G_CALLBACK (plugin_connection_added), self); - g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED, + g_signal_connect (plugin, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED, G_CALLBACK (unmanaged_specs_changed), self); - g_signal_connect (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED, + g_signal_connect (plugin, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED, G_CALLBACK (unrecognized_specs_changed), self); } @@ -277,20 +278,24 @@ nm_settings_for_each_connection (NMSettings *self, for_each_func (self, NM_SETTINGS_CONNECTION (data), user_data); } -static gboolean +static void impl_settings_list_connections (NMSettings *self, - GPtrArray **connections, - GError **error) + GDBusMethodInvocation *context) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); + GPtrArray *connections; GHashTableIter iter; gpointer key; - *connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1); + connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1); g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, &key, NULL)) - g_ptr_array_add (*connections, g_strdup ((const char *) key)); - return TRUE; + g_ptr_array_add (connections, key); + g_ptr_array_add (connections, NULL); + + g_dbus_method_invocation_return_value (context, + g_variant_new ("(^ao)", connections->pdata)); + g_ptr_array_unref (connections); } NMSettingsConnection * @@ -307,7 +312,7 @@ nm_settings_get_connection_by_uuid (NMSettings *self, const char *uuid) g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { - if (g_strcmp0 (uuid, nm_connection_get_uuid (NM_CONNECTION (candidate))) == 0) + if (g_strcmp0 (uuid, nm_settings_connection_get_uuid (candidate)) == 0) return candidate; } @@ -316,8 +321,8 @@ nm_settings_get_connection_by_uuid (NMSettings *self, const char *uuid) static void impl_settings_get_connection_by_uuid (NMSettings *self, - const char *uuid, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + const char *uuid) { NMSettingsConnection *connection = NULL; NMAuthSubject *subject = NULL; @@ -341,7 +346,6 @@ impl_settings_get_connection_by_uuid (NMSettings *self, } if (!nm_auth_is_subject_in_acl (NM_CONNECTION (connection), - nm_session_monitor_get (), subject, &error_desc)) { error = g_error_new_literal (NM_SETTINGS_ERROR, @@ -352,13 +356,14 @@ impl_settings_get_connection_by_uuid (NMSettings *self, } g_clear_object (&subject); - dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection))); + g_dbus_method_invocation_return_value ( + context, + g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection)))); return; error: g_assert (error); - dbus_g_method_return_error (context, error); - g_error_free (error); + g_dbus_method_invocation_take_error (context, error); g_clear_object (&subject); } @@ -424,53 +429,8 @@ nm_settings_get_connection_by_path (NMSettings *self, const char *path) return (NMSettingsConnection *) g_hash_table_lookup (priv->connections, path); } -static char* -uscore_to_wincaps (const char *uscore) -{ - const char *p; - GString *str; - gboolean last_was_uscore; - - last_was_uscore = TRUE; - - str = g_string_new (NULL); - p = uscore; - while (p && *p) { - if (*p == '-' || *p == '_') - last_was_uscore = TRUE; - else { - if (last_was_uscore) { - g_string_append_c (str, g_ascii_toupper (*p)); - last_was_uscore = FALSE; - } else - g_string_append_c (str, *p); - } - ++p; - } - - return g_string_free (str, FALSE); -} - -static void -notify (GObject *object, GParamSpec *pspec) -{ - GValue *value; - GHashTable *hash; - - value = g_slice_new0 (GValue); - hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); - - g_value_init (value, pspec->value_type); - g_object_get_property (object, pspec->name, value); - g_hash_table_insert (hash, uscore_to_wincaps (pspec->name), value); - g_signal_emit (object, signals[PROPERTIES_CHANGED], 0, hash); - g_hash_table_destroy (hash); - g_value_unset (value); - g_slice_free (GValue, value); -} - gboolean -nm_settings_has_connection (NMSettings *self, NMConnection *connection) +nm_settings_has_connection (NMSettings *self, NMSettingsConnection *connection) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); GHashTableIter iter; @@ -492,7 +452,7 @@ nm_settings_get_unmanaged_specs (NMSettings *self) return priv->unmanaged_specs; } -static NMSystemConfigInterface * +static NMSettingsPlugin * get_plugin (NMSettings *self, guint32 capability) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); @@ -500,42 +460,109 @@ get_plugin (NMSettings *self, guint32 capability) g_return_val_if_fail (self != NULL, NULL); - /* Do any of the plugins support setting the hostname? */ + /* Do any of the plugins support the given capability? */ for (iter = priv->plugins; iter; iter = iter->next) { - NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE; + NMSettingsPluginCapabilities caps = NM_SETTINGS_PLUGIN_CAP_NONE; - g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL); + g_object_get (G_OBJECT (iter->data), NM_SETTINGS_PLUGIN_CAPABILITIES, &caps, NULL); if (NM_FLAGS_ALL (caps, capability)) - return NM_SYSTEM_CONFIG_INTERFACE (iter->data); + return NM_SETTINGS_PLUGIN (iter->data); } return NULL; } +#if defined(HOSTNAME_PERSIST_GENTOO) +static gchar * +read_hostname_gentoo (const char *path) +{ + gchar *contents = NULL, *result = NULL, *tmp; + gchar **all_lines = NULL; + guint line_num, i; + + if (!g_file_get_contents (path, &contents, NULL, NULL)) + return NULL; + all_lines = g_strsplit (contents, "\n", 0); + line_num = g_strv_length (all_lines); + for (i = 0; i < line_num; i++) { + g_strstrip (all_lines[i]); + if (all_lines[i][0] == '#' || all_lines[i][0] == '\0') + continue; + if (g_str_has_prefix (all_lines[i], "hostname=")) { + tmp = &all_lines[i][STRLEN ("hostname=")]; + result = g_shell_unquote (tmp, NULL); + break; + } + } + g_strfreev (all_lines); + g_free (contents); + return result; +} +#endif + +#if defined(HOSTNAME_PERSIST_SUSE) +static gboolean +hostname_is_dynamic (void) +{ + GIOChannel *channel; + char *str = NULL; + gboolean dynamic = FALSE; + + channel = g_io_channel_new_file (CONF_DHCP, "r", NULL); + if (!channel) + return dynamic; + + while (g_io_channel_read_line (channel, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF) { + if (str) { + g_strstrip (str); + if (g_str_has_prefix (str, "DHCLIENT_SET_HOSTNAME=")) + dynamic = strcmp (&str[STRLEN ("DHCLIENT_SET_HOSTNAME=")], "\"yes\"") == 0; + g_free (str); + } + } + + g_io_channel_shutdown (channel, FALSE, NULL); + g_io_channel_unref (channel); + + return dynamic; +} +#endif + /* Returns an allocated string which the caller owns and must eventually free */ char * nm_settings_get_hostname (NMSettings *self) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); - GSList *iter; char *hostname = NULL; - /* Hostname returned is the hostname returned from the first plugin - * that provides one. - */ - for (iter = priv->plugins; iter; iter = iter->next) { - NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE; - - g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL); - if (caps & NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME) { - g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, &hostname, NULL); - if (hostname && strlen (hostname)) - return hostname; - g_free (hostname); - } + if (!priv->started) + return NULL; + + if (priv->hostname.hostnamed_proxy) { + hostname = g_strdup (priv->hostname.value); + goto out; } - return NULL; +#if defined(HOSTNAME_PERSIST_GENTOO) + hostname = read_hostname_gentoo (priv->hostname.file); +#else + +#if defined(HOSTNAME_PERSIST_SUSE) + if (priv->hostname.dhcp_monitor_id && hostname_is_dynamic ()) + return NULL; +#endif + if (g_file_get_contents (priv->hostname.file, &hostname, NULL, NULL)) + g_strchomp (hostname); + +#endif /* HOSTNAME_PERSIST_GENTOO */ + +out: + if (hostname && !hostname[0]) { + g_free (hostname); + hostname = NULL; + } + + return hostname; } static gboolean @@ -552,7 +579,7 @@ find_spec (GSList *spec_list, const char *spec) static void update_specs (NMSettings *self, GSList **specs_ptr, - GSList * (*get_specs_func) (NMSystemConfigInterface *)) + GSList * (*get_specs_func) (NMSettingsPlugin *)) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); GSList *iter; @@ -563,7 +590,7 @@ update_specs (NMSettings *self, GSList **specs_ptr, for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { GSList *specs, *specs_iter; - specs = get_specs_func (NM_SYSTEM_CONFIG_INTERFACE (iter->data)); + specs = get_specs_func (NM_SETTINGS_PLUGIN (iter->data)); for (specs_iter = specs; specs_iter; specs_iter = specs_iter->next) { if (!find_spec (*specs_ptr, (const char *) specs_iter->data)) { *specs_ptr = g_slist_prepend (*specs_ptr, specs_iter->data); @@ -576,58 +603,52 @@ update_specs (NMSettings *self, GSList **specs_ptr, } static void -unmanaged_specs_changed (NMSystemConfigInterface *config, +unmanaged_specs_changed (NMSettingsPlugin *config, gpointer user_data) { NMSettings *self = NM_SETTINGS (user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); update_specs (self, &priv->unmanaged_specs, - nm_system_config_interface_get_unmanaged_specs); + nm_settings_plugin_get_unmanaged_specs); g_object_notify (G_OBJECT (self), NM_SETTINGS_UNMANAGED_SPECS); } static void -unrecognized_specs_changed (NMSystemConfigInterface *config, +unrecognized_specs_changed (NMSettingsPlugin *config, gpointer user_data) { NMSettings *self = NM_SETTINGS (user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); update_specs (self, &priv->unrecognized_specs, - nm_system_config_interface_get_unrecognized_specs); -} - -static void -hostname_changed (NMSystemConfigInterface *config, - GParamSpec *pspec, - gpointer user_data) -{ - g_object_notify (G_OBJECT (user_data), NM_SETTINGS_HOSTNAME); + nm_settings_plugin_get_unrecognized_specs); } -static void -add_plugin (NMSettings *self, NMSystemConfigInterface *plugin) +static gboolean +add_plugin (NMSettings *self, NMSettingsPlugin *plugin) { NMSettingsPrivate *priv; char *pname = NULL; char *pinfo = NULL; const char *path; - g_return_if_fail (NM_IS_SETTINGS (self)); - g_return_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin)); + g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_PLUGIN (plugin), FALSE); priv = NM_SETTINGS_GET_PRIVATE (self); - priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin)); - - g_signal_connect (plugin, "notify::hostname", G_CALLBACK (hostname_changed), self); + if (g_slist_find (priv->plugins, plugin)) { + /* don't add duplicates. */ + return FALSE; + } - nm_system_config_interface_init (plugin, NULL); + priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin)); + nm_settings_plugin_init (plugin); g_object_get (G_OBJECT (plugin), - NM_SYSTEM_CONFIG_INTERFACE_NAME, &pname, - NM_SYSTEM_CONFIG_INTERFACE_INFO, &pinfo, + NM_SETTINGS_PLUGIN_NAME, &pname, + NM_SETTINGS_PLUGIN_INFO, &pinfo, NULL); path = g_object_get_data (G_OBJECT (plugin), PLUGIN_MODULE_PATH); @@ -636,6 +657,8 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin) NM_PRINT_FMT_QUOTED (path, " (", path, ")", "")); g_free (pname); g_free (pinfo); + + return TRUE; } static GObject * @@ -647,11 +670,11 @@ find_plugin (GSList *list, const char *pname) g_return_val_if_fail (pname != NULL, NULL); for (iter = list; iter && !obj; iter = g_slist_next (iter)) { - NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data); + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); char *list_pname = NULL; g_object_get (G_OBJECT (plugin), - NM_SYSTEM_CONFIG_INTERFACE_NAME, + NM_SETTINGS_PLUGIN_NAME, &list_pname, NULL); if (list_pname && !strcmp (pname, list_pname)) @@ -666,11 +689,12 @@ find_plugin (GSList *list, const char *pname) static void add_keyfile_plugin (NMSettings *self) { - GObject *keyfile_plugin; + gs_unref_object GObject *keyfile_plugin = NULL; keyfile_plugin = nm_settings_keyfile_plugin_new (); g_assert (keyfile_plugin); - add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (keyfile_plugin)); + if (!add_plugin (self, NM_SETTINGS_PLUGIN (keyfile_plugin))) + g_return_if_reached (); } static gboolean @@ -680,26 +704,34 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) const char **iter; gboolean keyfile_added = FALSE; gboolean success = TRUE; + gboolean add_ibft = FALSE; + gboolean has_no_ibft; + gssize idx_no_ibft, idx_ibft; + + idx_ibft = _nm_utils_strv_find_first ((char **) plugins, -1, "ibft"); + idx_no_ibft = _nm_utils_strv_find_first ((char **) plugins, -1, "no-ibft"); + has_no_ibft = idx_no_ibft >= 0 && idx_no_ibft > idx_ibft; +#if WITH_SETTINGS_PLUGIN_IBFT + add_ibft = idx_no_ibft < 0 && idx_ibft < 0; +#endif for (iter = plugins; iter && *iter; iter++) { - GModule *plugin; - gs_free char *full_name = NULL; - gs_free char *path = NULL; - const char *pname; + const char *pname = *iter; GObject *obj; - GObject * (*factory_func) (void); - struct stat st; - int errsv; - - pname = *iter; if (!*pname || strchr (pname, '/')) { LOG (LOGL_WARN, "ignore invalid plugin \"%s\"", pname); continue; } - obj = find_plugin (list, pname); - if (obj) + if (!strcmp (pname, "ifcfg-suse")) { + LOG (LOGL_WARN, "skipping deprecated plugin ifcfg-suse"); + continue; + } + + if (!strcmp (pname, "no-ibft")) + continue; + if (has_no_ibft && !strcmp (pname, "ibft")) continue; /* keyfile plugin is built-in now */ @@ -711,61 +743,92 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) continue; } - full_name = g_strdup_printf ("nm-settings-plugin-%s", pname); - path = g_module_build_path (NMPLUGINDIR, full_name); - - if (stat (path, &st) != 0) { - errsv = errno; - LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv)); - continue; - } - if (!S_ISREG (st.st_mode)) { - LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': not a file", pname, path); - continue; - } - if (st.st_uid != 0) { - LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': file must be owned by root", pname, path); - continue; - } - if (st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) { - LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': invalid file permissions", pname, path); + if (_nm_utils_strv_find_first ((char **) plugins, + iter - plugins, + pname) >= 0) { + /* the plugin is already mentioned in the list previously. + * Don't load a duplicate. */ continue; } - plugin = g_module_open (path, G_MODULE_BIND_LOCAL); - if (!plugin) { - LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", - pname, path, g_module_error ()); + if (find_plugin (list, pname)) continue; - } - /* errors after this point are fatal, because we loaded the shared library already. */ +load_plugin: + { + GModule *plugin; + gs_free char *full_name = NULL; + gs_free char *path = NULL; + GObject * (*factory_func) (void); + struct stat st; + int errsv; + + full_name = g_strdup_printf ("nm-settings-plugin-%s", pname); + path = g_module_build_path (NMPLUGINDIR, full_name); + + if (stat (path, &st) != 0) { + errsv = errno; + LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv)); + goto next; + } + if (!S_ISREG (st.st_mode)) { + LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': not a file", pname, path); + goto next; + } + if (st.st_uid != 0) { + LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': file must be owned by root", pname, path); + goto next; + } + if (st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) { + LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': invalid file permissions", pname, path); + goto next; + } - if (!g_module_symbol (plugin, "nm_system_config_factory", (gpointer) (&factory_func))) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Could not find plugin '%s' factory function.", - pname); - success = FALSE; - g_module_close (plugin); - break; - } + plugin = g_module_open (path, G_MODULE_BIND_LOCAL); + if (!plugin) { + LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", + pname, path, g_module_error ()); + goto next; + } - obj = (*factory_func) (); - if (!obj || !NM_IS_SYSTEM_CONFIG_INTERFACE (obj)) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "Plugin '%s' returned invalid system config object.", - pname); - success = FALSE; - g_module_close (plugin); - break; - } + /* errors after this point are fatal, because we loaded the shared library already. */ - g_module_make_resident (plugin); - g_object_weak_ref (obj, (GWeakNotify) g_module_close, plugin); - g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free); - path = NULL; - add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (obj)); - list = g_slist_append (list, obj); + if (!g_module_symbol (plugin, "nm_settings_plugin_factory", (gpointer) (&factory_func))) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Could not find plugin '%s' factory function.", + pname); + success = FALSE; + g_module_close (plugin); + break; + } + + obj = (*factory_func) (); + if (!obj || !NM_IS_SETTINGS_PLUGIN (obj)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "Plugin '%s' returned invalid system config object.", + pname); + success = FALSE; + g_module_close (plugin); + break; + } + + g_module_make_resident (plugin); + g_object_weak_ref (obj, (GWeakNotify) g_module_close, plugin); + g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free); + path = NULL; + if (add_plugin (self, NM_SETTINGS_PLUGIN (obj))) + list = g_slist_append (list, obj); + else + g_object_unref (obj); + } +next: + if (add_ibft && !strcmp (pname, "ifcfg-rh")) { + /* The plugin ibft is not explicitly mentioned but we just enabled "ifcfg-rh". + * Enable "ibft" by default after "ifcfg-rh". */ + pname = "ibft"; + add_ibft = FALSE; + goto load_plugin; + } } /* If keyfile plugin was not among configured plugins, add it as the last one */ @@ -819,7 +882,6 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data) if (!g_hash_table_lookup (priv->connections, cpath)) g_return_if_reached (); - g_object_ref (connection); /* Disconnect signal handlers, as plugins might still keep references @@ -832,6 +894,7 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data) g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_updated_by_user), self); g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_visibility_changed), self); g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_ready_changed), self); + g_object_unref (self); /* Forget about the connection internally */ g_hash_table_remove (priv->connections, (gpointer) cpath); @@ -842,6 +905,8 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data) /* Re-emit for listeners like NMPolicy */ g_signal_emit_by_name (self, NM_CP_SIGNAL_CONNECTION_REMOVED, connection); g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTIONS); + if (nm_exported_object_is_exported (NM_EXPORTED_OBJECT (connection))) + nm_exported_object_unexport (NM_EXPORTED_OBJECT (connection)); check_startup_complete (self); @@ -904,11 +969,10 @@ static void claim_connection (NMSettings *self, NMSettingsConnection *connection) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); - static guint32 ec_counter = 0; GError *error = NULL; GHashTableIter iter; gpointer data; - char *path; + const char *path; NMSettingsConnection *existing; g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); @@ -928,7 +992,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection) return; } - existing = nm_settings_get_connection_by_uuid (self, nm_connection_get_uuid (NM_CONNECTION (connection))); + existing = nm_settings_get_connection_by_uuid (self, nm_settings_connection_get_uuid (connection)); if (existing) { /* Cannot add duplicate connections per UUID. Just return without action and * log a warning. @@ -941,7 +1005,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection) * error out. That should not happen unless the admin misconfigured the system * to create conflicting connections. */ nm_log_warn (LOGD_SETTINGS, "plugin provided duplicate connection with UUID %s", - nm_connection_get_uuid (NM_CONNECTION (connection))); + nm_settings_connection_get_uuid (connection)); return; } @@ -957,6 +1021,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection) /* Evil openconnect migration hack */ openconnect_migrate_hack (NM_CONNECTION (connection)); + g_object_ref (self); g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, G_CALLBACK (connection_removed), self); g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED, @@ -974,10 +1039,8 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection) /* Export the connection over D-Bus */ g_warn_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL); - path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++); + path = nm_exported_object_export (NM_EXPORTED_OBJECT (connection)); nm_connection_set_path (NM_CONNECTION (connection), path); - nm_dbus_manager_register_object (priv->dbus_mgr, path, G_OBJECT (connection)); - g_free (path); g_hash_table_insert (priv->connections, (gpointer) nm_connection_get_path (NM_CONNECTION (connection)), @@ -1047,10 +1110,10 @@ nm_settings_add_connection (NMSettings *self, * contain the same data as the connection it already knows about */ for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { - NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data); + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); GError *add_error = NULL; - added = nm_system_config_interface_add_connection (plugin, connection, save_to_disk, &add_error); + added = nm_settings_plugin_add_connection (plugin, connection, save_to_disk, &add_error); if (added) { claim_connection (self, added); return added; @@ -1112,21 +1175,24 @@ send_agent_owned_secrets (NMSettings *self, nm_connection_clear_secrets_with_flags (for_agent, secrets_filter_cb, GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED)); - nm_agent_manager_save_secrets (priv->agent_mgr, for_agent, subject); + nm_agent_manager_save_secrets (priv->agent_mgr, + nm_connection_get_path (NM_CONNECTION (connection)), + for_agent, + subject); g_object_unref (for_agent); } static void pk_add_cb (NMAuthChain *chain, GError *chain_error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, gpointer user_data) { NMSettings *self = NM_SETTINGS (user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMAuthCallResult result; GError *error = NULL; - NMConnection *connection; + NMConnection *connection = NULL; NMSettingsConnection *added = NULL; NMSettingsAddCallback callback; gpointer callback_data; @@ -1163,10 +1229,10 @@ pk_add_cb (NMAuthChain *chain, callback_data = nm_auth_chain_get_data (chain, "callback-data"); subject = nm_auth_chain_get_data (chain, "subject"); - callback (self, added, error, context, callback_data); + callback (self, added, error, context, subject, callback_data); /* Send agent-owned secrets to the agents */ - if (!error && added) + if (!error && added && nm_settings_has_connection (self, added)) send_agent_owned_secrets (self, added, subject); g_clear_error (&error); @@ -1207,11 +1273,11 @@ is_adhoc_wpa (NMConnection *connection) void nm_settings_add_connection_dbus (NMSettings *self, - NMConnection *connection, - gboolean save_to_disk, - DBusGMethodInvocation *context, - NMSettingsAddCallback callback, - gpointer user_data) + NMConnection *connection, + gboolean save_to_disk, + GDBusMethodInvocation *context, + NMSettingsAddCallback callback, + gpointer user_data) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMSettingConnection *s_con; @@ -1246,7 +1312,7 @@ nm_settings_add_connection_dbus (NMSettings *self, } /* Do any of the plugins support adding? */ - if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) { + if (!get_plugin (self, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS)) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, "None of the registered plugins support add."); @@ -1265,7 +1331,6 @@ nm_settings_add_connection_dbus (NMSettings *self, * or that the permissions is empty (ie, visible by everyone). */ if (!nm_auth_is_subject_in_acl (connection, - nm_session_monitor_get (), subject, &error_desc)) { error = g_error_new_literal (NM_SETTINGS_ERROR, @@ -1306,7 +1371,7 @@ nm_settings_add_connection_dbus (NMSettings *self, done: if (error) - callback (self, NULL, error, context, user_data); + callback (self, NULL, error, context, subject, user_data); g_clear_error (&error); g_clear_object (&subject); @@ -1316,29 +1381,37 @@ static void impl_settings_add_connection_add_cb (NMSettings *self, NMSettingsConnection *connection, GError *error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, + NMAuthSubject *subject, gpointer user_data) { - if (error) - dbus_g_method_return_error (context, error); - else - dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection))); + if (error) { + g_dbus_method_invocation_return_gerror (context, error); + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, NULL, FALSE, subject, error->message); + } else { + g_dbus_method_invocation_return_value ( + context, + g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection)))); + nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, connection, TRUE, + subject, NULL); + } } static void impl_settings_add_connection_helper (NMSettings *self, - GHashTable *settings, - gboolean save_to_disk, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + GVariant *settings, + gboolean save_to_disk) { NMConnection *connection; - GVariant *dict; GError *error = NULL; - dict = nm_utils_connection_hash_to_dict (settings); - connection = nm_simple_connection_new_from_dbus (dict, &error); - g_variant_unref (dict); + connection = nm_simple_connection_new_from_dbus (settings, &error); + if (connection) { + if (!nm_connection_verify_secrets (connection, &error)) + goto failure; + nm_settings_add_connection_dbus (self, connection, save_to_disk, @@ -1346,50 +1419,49 @@ impl_settings_add_connection_helper (NMSettings *self, impl_settings_add_connection_add_cb, NULL); g_object_unref (connection); - } else { - g_assert (error); - dbus_g_method_return_error (context, error); - g_error_free (error); + return; } + +failure: + g_assert (error); + g_dbus_method_invocation_take_error (context, error); } static void impl_settings_add_connection (NMSettings *self, - GHashTable *settings, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + GVariant *settings) { - impl_settings_add_connection_helper (self, settings, TRUE, context); + impl_settings_add_connection_helper (self, context, settings, TRUE); } static void impl_settings_add_connection_unsaved (NMSettings *self, - GHashTable *settings, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + GVariant *settings) { - impl_settings_add_connection_helper (self, settings, FALSE, context); + impl_settings_add_connection_helper (self, context, settings, FALSE); } static gboolean -ensure_root (NMDBusManager *dbus_mgr, - DBusGMethodInvocation *context) +ensure_root (NMBusManager *dbus_mgr, + GDBusMethodInvocation *context) { gulong caller_uid; GError *error = NULL; - if (!nm_dbus_manager_get_caller_info (dbus_mgr, context, NULL, &caller_uid, NULL)) { + if (!nm_bus_manager_get_caller_info (dbus_mgr, context, NULL, &caller_uid, NULL)) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_PERMISSION_DENIED, "Unable to determine request UID."); - dbus_g_method_return_error (context, error); - g_error_free (error); + g_dbus_method_invocation_take_error (context, error); return FALSE; } if (caller_uid != 0) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_PERMISSION_DENIED, "Permission denied"); - dbus_g_method_return_error (context, error); - g_error_free (error); + g_dbus_method_invocation_take_error (context, error); return FALSE; } @@ -1398,24 +1470,24 @@ ensure_root (NMDBusManager *dbus_mgr, static void impl_settings_load_connections (NMSettings *self, - char **filenames, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + char **filenames) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); GPtrArray *failures; GSList *iter; int i; - if (!ensure_root (priv->dbus_mgr, context)) + if (!ensure_root (nm_bus_manager_get (), context)) return; failures = g_ptr_array_new (); for (i = 0; filenames[i]; i++) { for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { - NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data); + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); - if (nm_system_config_interface_load_connection (plugin, filenames[i])) + if (nm_settings_plugin_load_connection (plugin, filenames[i])) break; } @@ -1427,40 +1499,110 @@ impl_settings_load_connections (NMSettings *self, } g_ptr_array_add (failures, NULL); - dbus_g_method_return (context, failures->len == 1, failures->pdata); + g_dbus_method_invocation_return_value ( + context, + g_variant_new ("(b^as)", + failures->len == 1, + failures->pdata)); g_ptr_array_unref (failures); } static void impl_settings_reload_connections (NMSettings *self, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); GSList *iter; - if (!ensure_root (priv->dbus_mgr, context)) + if (!ensure_root (nm_bus_manager_get (), context)) return; for (iter = priv->plugins; iter; iter = g_slist_next (iter)) { - NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data); + NMSettingsPlugin *plugin = NM_SETTINGS_PLUGIN (iter->data); - nm_system_config_interface_reload_connections (plugin); + nm_settings_plugin_reload_connections (plugin); } - dbus_g_method_return (context, TRUE); + g_dbus_method_invocation_return_value (context, g_variant_new ("(b)", TRUE)); +} + +static gboolean +write_hostname (NMSettingsPrivate *priv, const char *hostname) +{ + char *hostname_eol; + gboolean ret; + gs_free_error GError *error = NULL; + const char *file = priv->hostname.file; + gs_unref_variant GVariant *var = NULL; +#if HAVE_SELINUX + security_context_t se_ctx_prev = NULL, se_ctx = NULL; + struct stat file_stat = { .st_mode = 0 }; + mode_t st_mode = 0; +#endif + + if (priv->hostname.hostnamed_proxy) { + var = g_dbus_proxy_call_sync (priv->hostname.hostnamed_proxy, + "SetStaticHostname", + g_variant_new ("(sb)", hostname, FALSE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (error) + nm_log_warn (LOGD_SETTINGS, "Could not set hostname: %s", error->message); + + return !error; + } + +#if HAVE_SELINUX + /* Get default context for hostname file and set it for fscreate */ + if (stat (file, &file_stat) == 0) + st_mode = file_stat.st_mode; + matchpathcon (file, st_mode, &se_ctx); + matchpathcon_fini (); + getfscreatecon (&se_ctx_prev); + setfscreatecon (se_ctx); +#endif + +#if defined (HOSTNAME_PERSIST_GENTOO) + hostname_eol = g_strdup_printf ("#Generated by NetworkManager\n" + "hostname=\"%s\"\n", hostname); +#else + hostname_eol = g_strdup_printf ("%s\n", hostname); +#endif + + /* FIXME: g_file_set_contents() writes first to a temporary file + * and renames it atomically. We should hack g_file_set_contents() + * to set the SELINUX labels before renaming the file. */ + ret = g_file_set_contents (file, hostname_eol, -1, &error); + +#if HAVE_SELINUX + /* Restore previous context and cleanup */ + setfscreatecon (se_ctx_prev); + freecon (se_ctx); + freecon (se_ctx_prev); +#endif + + g_free (hostname_eol); + + if (!ret) { + nm_log_warn (LOGD_SETTINGS, "Could not save hostname to %s: %s", file, error->message); + return FALSE; + } + + return TRUE; } static void pk_hostname_cb (NMAuthChain *chain, GError *chain_error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, gpointer user_data) { NMSettings *self = NM_SETTINGS (user_data); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMAuthCallResult result; GError *error = NULL; - GSList *iter; const char *hostname; g_assert (context); @@ -1480,30 +1622,20 @@ pk_hostname_cb (NMAuthChain *chain, NM_SETTINGS_ERROR_PERMISSION_DENIED, "Insufficient privileges."); } else { - /* Set the hostname in all plugins */ hostname = nm_auth_chain_get_data (chain, "hostname"); - for (iter = priv->plugins; iter; iter = iter->next) { - NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE; - /* error will be cleared if any plugin supports saving the hostname */ + if (!write_hostname (priv, hostname)) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Saving the hostname failed."); - - g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, &caps, NULL); - if (caps & NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME) { - g_object_set (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, hostname, NULL); - g_clear_error (&error); - } } } if (error) - dbus_g_method_return_error (context, error); + g_dbus_method_invocation_take_error (context, error); else - dbus_g_method_return (context); + g_dbus_method_invocation_return_value (context, NULL); - g_clear_error (&error); nm_auth_chain_unref (chain); } @@ -1536,8 +1668,8 @@ validate_hostname (const char *hostname) static void impl_settings_save_hostname (NMSettings *self, - const char *hostname, - DBusGMethodInvocation *context) + GDBusMethodInvocation *context, + const char *hostname) { NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); NMAuthChain *chain; @@ -1551,14 +1683,6 @@ impl_settings_save_hostname (NMSettings *self, goto done; } - /* Do any of the plugins support setting the hostname? */ - if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME)) { - error = g_error_new_literal (NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_NOT_SUPPORTED, - "None of the registered plugins support setting the hostname."); - goto done; - } - chain = nm_auth_chain_new_context (context, pk_hostname_cb, self); if (!chain) { error = g_error_new_literal (NM_SETTINGS_ERROR, @@ -1573,8 +1697,39 @@ impl_settings_save_hostname (NMSettings *self, done: if (error) - dbus_g_method_return_error (context, error); - g_clear_error (&error); + g_dbus_method_invocation_take_error (context, error); +} + +static void +hostname_maybe_changed (NMSettings *settings) +{ + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (settings); + char *new_hostname; + + new_hostname = nm_settings_get_hostname (settings); + + if ( (new_hostname && !priv->hostname.value) + || (!new_hostname && priv->hostname.value) + || (priv->hostname.value && new_hostname && strcmp (priv->hostname.value, new_hostname))) { + + nm_log_info (LOGD_SETTINGS, "hostname changed from %s%s%s to %s%s%s", + NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"), + NM_PRINT_FMT_QUOTED (new_hostname, "\"", new_hostname, "\"", "(none)")); + g_free (priv->hostname.value); + priv->hostname.value = new_hostname; + g_object_notify (G_OBJECT (settings), NM_SETTINGS_HOSTNAME); + } else + g_free (new_hostname); +} + +static void +hostname_file_changed_cb (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + gpointer user_data) +{ + hostname_maybe_changed (user_data); } static gboolean @@ -1699,13 +1854,20 @@ default_wired_clear_tag (NMSettings *self, nm_config_set_no_auto_default_for_device (NM_SETTINGS_GET_PRIVATE (self)->config, device); } -void -nm_settings_device_added (NMSettings *self, NMDevice *device) +static void +device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self) { NMConnection *connection; NMSettingsConnection *added; GError *error = NULL; + if (!nm_device_is_real (device)) + return; + + g_signal_handlers_disconnect_by_func (device, + G_CALLBACK (device_realized), + self); + /* If the device isn't managed or it already has a default wired connection, * ignore it. */ @@ -1740,7 +1902,19 @@ nm_settings_device_added (NMSettings *self, NMDevice *device) nm_log_info (LOGD_SETTINGS, "(%s): created default wired connection '%s'", nm_device_get_iface (device), - nm_connection_get_id (NM_CONNECTION (added))); + nm_settings_connection_get_id (added)); +} + +void +nm_settings_device_added (NMSettings *self, NMDevice *device) +{ + if (nm_device_is_real (device)) + device_realized (device, NULL, self); + else { + g_signal_connect_after (device, "notify::" NM_DEVICE_REAL, + G_CALLBACK (device_realized), + self); + } } void @@ -1748,6 +1922,10 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device, gboolean quittin { NMSettingsConnection *connection; + g_signal_handlers_disconnect_by_func (device, + G_CALLBACK (device_realized), + self); + connection = g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG); if (connection) { default_wired_clear_tag (self, device, connection, FALSE); @@ -1875,8 +2053,75 @@ nm_settings_get_startup_complete (NMSettings *self) /***************************************************************/ +static void +hostnamed_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + char **invalidated_properties, + gpointer user_data) +{ + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (user_data); + GVariant *v_hostname; + const char *hostname; + + v_hostname = g_dbus_proxy_get_cached_property (priv->hostname.hostnamed_proxy, + "StaticHostname"); + if (!v_hostname) + return; + + hostname = g_variant_get_string (v_hostname, NULL); + + if (g_strcmp0 (priv->hostname.value, hostname) != 0) { + nm_log_info (LOGD_SETTINGS, "hostname changed from %s%s%s to %s%s%s", + NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"), + NM_PRINT_FMT_QUOTED (hostname, "\"", hostname, "\"", "(none)")); + g_free (priv->hostname.value); + priv->hostname.value = g_strdup (hostname); + g_object_notify (G_OBJECT (user_data), NM_SETTINGS_HOSTNAME); + nm_dispatcher_call (DISPATCHER_ACTION_HOSTNAME, NULL, NULL, NULL, NULL, NULL, NULL); + } + + g_variant_unref (v_hostname); +} + +static void +setup_hostname_file_monitors (NMSettings *self) +{ + NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); + GFileMonitor *monitor; + GFile *file; + + priv->hostname.file = HOSTNAME_FILE; + priv->hostname.value = nm_settings_get_hostname (self); + + /* monitor changes to hostname file */ + file = g_file_new_for_path (priv->hostname.file); + monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + if (monitor) { + priv->hostname.monitor_id = g_signal_connect (monitor, "changed", + G_CALLBACK (hostname_file_changed_cb), + self); + priv->hostname.monitor = monitor; + } + +#if defined (HOSTNAME_PERSIST_SUSE) + /* monitor changes to dhcp file to know whether the hostname is valid */ + file = g_file_new_for_path (CONF_DHCP); + monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); + g_object_unref (file); + if (monitor) { + priv->hostname.dhcp_monitor_id = g_signal_connect (monitor, "changed", + G_CALLBACK (hostname_file_changed_cb), + self); + priv->hostname.dhcp_monitor = monitor; + } +#endif + + hostname_maybe_changed (self); +} + NMSettings * -nm_settings_new (GError **error) +nm_settings_new (void) { NMSettings *self; NMSettingsPrivate *priv; @@ -1886,28 +2131,67 @@ nm_settings_new (GError **error) priv = NM_SETTINGS_GET_PRIVATE (self); priv->config = nm_config_get (); - priv->dbus_mgr = nm_dbus_manager_get (); + + nm_exported_object_export (NM_EXPORTED_OBJECT (self)); + return self; +} + +gboolean +nm_settings_start (NMSettings *self, GError **error) +{ + NMSettingsPrivate *priv; + GDBusProxy *proxy; + GVariant *variant; + GError *local_error = NULL; + + priv = NM_SETTINGS_GET_PRIVATE (self); /* Load the plugins; fail if a plugin is not found. */ if (!load_plugins (self, nm_config_get_plugins (priv->config), error)) { g_object_unref (self); - return NULL; + return FALSE; } load_connections (self); check_startup_complete (self); - nm_dbus_manager_register_object (priv->dbus_mgr, NM_DBUS_PATH_SETTINGS, self); - return self; + proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, 0, NULL, + HOSTNAMED_SERVICE_NAME, HOSTNAMED_SERVICE_PATH, + HOSTNAMED_SERVICE_INTERFACE, NULL, &local_error); + if (proxy) { + variant = g_dbus_proxy_get_cached_property (proxy, "StaticHostname"); + if (variant) { + nm_log_info (LOGD_SETTINGS, "hostname: using hostnamed"); + priv->hostname.hostnamed_proxy = proxy; + g_signal_connect (proxy, "g-properties-changed", + G_CALLBACK (hostnamed_properties_changed), self); + hostnamed_properties_changed (proxy, NULL, NULL, self); + g_variant_unref (variant); + } else { + nm_log_info (LOGD_SETTINGS, "hostname: couldn't get property from hostnamed"); + g_object_unref (proxy); + } + } else { + nm_log_info (LOGD_SETTINGS, "hostname: hostnamed not used as proxy creation failed with: %s", + local_error->message); + g_clear_error (&local_error); + } + + if (!priv->hostname.hostnamed_proxy) + setup_hostname_file_monitors (self); + + priv->started = TRUE; + g_object_notify (G_OBJECT (self), NM_SETTINGS_HOSTNAME); + return TRUE; } static void -connection_provider_init (NMConnectionProvider *cp_class) +connection_provider_iface_init (NMConnectionProviderInterface *cp_iface) { - cp_class->get_best_connections = get_best_connections; - cp_class->get_connections = get_connections; - cp_class->add_connection = _nm_connection_provider_add_connection; - cp_class->get_connection_by_uuid = cp_get_connection_by_uuid; + cp_iface->get_best_connections = get_best_connections; + cp_iface->get_connections = get_connections; + cp_iface->add_connection = _nm_connection_provider_add_connection; + cp_iface->get_connection_by_uuid = cp_get_connection_by_uuid; } static void @@ -1936,10 +2220,34 @@ dispose (GObject *object) g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref); priv->auths = NULL; - priv->dbus_mgr = NULL; - g_object_unref (priv->agent_mgr); + if (priv->hostname.hostnamed_proxy) { + g_signal_handlers_disconnect_by_func (priv->hostname.hostnamed_proxy, + G_CALLBACK (hostnamed_properties_changed), + self); + g_clear_object (&priv->hostname.hostnamed_proxy); + } + + if (priv->hostname.monitor) { + if (priv->hostname.monitor_id) + g_signal_handler_disconnect (priv->hostname.monitor, priv->hostname.monitor_id); + + g_file_monitor_cancel (priv->hostname.monitor); + g_clear_object (&priv->hostname.monitor); + } + + if (priv->hostname.dhcp_monitor) { + if (priv->hostname.dhcp_monitor_id) + g_signal_handler_disconnect (priv->hostname.dhcp_monitor, + priv->hostname.dhcp_monitor_id); + + g_file_monitor_cancel (priv->hostname.dhcp_monitor); + g_clear_object (&priv->hostname.dhcp_monitor); + } + + g_clear_pointer (&priv->hostname.value, g_free); + G_OBJECT_CLASS (nm_settings_parent_class)->dispose (object); } @@ -1962,22 +2270,23 @@ finalize (GObject *object) static void get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) + GValue *value, GParamSpec *pspec) { NMSettings *self = NM_SETTINGS (object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); const GSList *specs, *iter; - GSList *copy = NULL; GHashTableIter citer; GPtrArray *array; const char *path; switch (prop_id) { case PROP_UNMANAGED_SPECS: + array = g_ptr_array_new (); specs = nm_settings_get_unmanaged_specs (self); for (iter = specs; iter; iter = g_slist_next (iter)) - copy = g_slist_append (copy, g_strdup (iter->data)); - g_value_take_boxed (value, copy); + g_ptr_array_add (array, g_strdup (iter->data)); + g_ptr_array_add (array, NULL); + g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE)); break; case PROP_HOSTNAME: g_value_take_string (value, nm_settings_get_hostname (self)); @@ -1987,14 +2296,15 @@ get_property (GObject *object, guint prop_id, g_value_set_static_string (value, ""); break; case PROP_CAN_MODIFY: - g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)); + g_value_set_boolean (value, !!get_plugin (self, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS)); break; case PROP_CONNECTIONS: - array = g_ptr_array_sized_new (g_hash_table_size (priv->connections)); + array = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1); g_hash_table_iter_init (&citer, priv->connections); while (g_hash_table_iter_next (&citer, (gpointer) &path, NULL)) g_ptr_array_add (array, g_strdup (path)); - g_value_take_boxed (value, array); + g_ptr_array_add (array, NULL); + g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE)); break; case PROP_STARTUP_COMPLETE: g_value_set_boolean (value, nm_settings_get_startup_complete (self)); @@ -2009,11 +2319,13 @@ static void nm_settings_class_init (NMSettingsClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - + NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (class); + g_type_class_add_private (class, sizeof (NMSettingsPrivate)); + exported_object_class->export_path = NM_DBUS_PATH_SETTINGS; + /* virtual methods */ - object_class->notify = notify; object_class->get_property = get_property; object_class->dispose = dispose; object_class->finalize = finalize; @@ -2023,7 +2335,7 @@ nm_settings_class_init (NMSettingsClass *class) g_object_class_install_property (object_class, PROP_UNMANAGED_SPECS, g_param_spec_boxed (NM_SETTINGS_UNMANAGED_SPECS, "", "", - DBUS_TYPE_G_LIST_OF_STRING, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -2044,19 +2356,11 @@ nm_settings_class_init (NMSettingsClass *class) g_object_class_install_property (object_class, PROP_CONNECTIONS, g_param_spec_boxed (NM_SETTINGS_CONNECTIONS, "", "", - DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, + G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /* signals */ - signals[PROPERTIES_CHANGED] = - g_signal_new ("properties-changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSettingsClass, properties_changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT); signals[CONNECTION_ADDED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_ADDED, G_OBJECT_CLASS_TYPE (object_class), @@ -2064,7 +2368,7 @@ nm_settings_class_init (NMSettingsClass *class) G_STRUCT_OFFSET (NMSettingsClass, connection_added), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); signals[CONNECTION_UPDATED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, @@ -2073,7 +2377,7 @@ nm_settings_class_init (NMSettingsClass *class) G_STRUCT_OFFSET (NMSettingsClass, connection_updated), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); signals[CONNECTION_UPDATED_BY_USER] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER, @@ -2082,7 +2386,7 @@ nm_settings_class_init (NMSettingsClass *class) 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); signals[CONNECTION_REMOVED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_REMOVED, @@ -2091,7 +2395,7 @@ nm_settings_class_init (NMSettingsClass *class) G_STRUCT_OFFSET (NMSettingsClass, connection_removed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); signals[CONNECTION_VISIBILITY_CHANGED] = g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_VISIBILITY_CHANGED, @@ -2100,7 +2404,7 @@ nm_settings_class_init (NMSettingsClass *class) G_STRUCT_OFFSET (NMSettingsClass, connection_visibility_changed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); signals[AGENT_REGISTERED] = g_signal_new (NM_SETTINGS_SIGNAL_AGENT_REGISTERED, @@ -2109,7 +2413,7 @@ nm_settings_class_init (NMSettingsClass *class) G_STRUCT_OFFSET (NMSettingsClass, agent_registered), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); + G_TYPE_NONE, 1, NM_TYPE_SECRET_AGENT); signals[NEW_CONNECTION] = @@ -2117,16 +2421,17 @@ nm_settings_class_init (NMSettingsClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); - - dbus_g_error_domain_register (NM_SETTINGS_ERROR, - NM_DBUS_INTERFACE_SETTINGS, - NM_TYPE_SETTINGS_ERROR); - dbus_g_error_domain_register (NM_CONNECTION_ERROR, - NM_DBUS_INTERFACE_SETTINGS_CONNECTION, - NM_TYPE_CONNECTION_ERROR); - - dbus_g_object_type_install_info (NM_TYPE_SETTINGS, &dbus_glib_nm_settings_object_info); - + G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION); + + nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class), + NMDBUS_TYPE_SETTINGS_SKELETON, + "ListConnections", impl_settings_list_connections, + "GetConnectionByUuid", impl_settings_get_connection_by_uuid, + "AddConnection", impl_settings_add_connection, + "AddConnectionUnsaved", impl_settings_add_connection_unsaved, + "LoadConnections", impl_settings_load_connections, + "ReloadConnections", impl_settings_reload_connections, + "SaveHostname", impl_settings_save_hostname, + NULL); } diff --git a/src/settings/nm-settings.h b/src/settings/nm-settings.h index d196efe6..923b164b 100644 --- a/src/settings/nm-settings.h +++ b/src/settings/nm-settings.h @@ -28,7 +28,7 @@ #include <nm-connection.h> -#include "nm-types.h" +#include "nm-exported-object.h" #define NM_TYPE_SETTINGS (nm_settings_get_type ()) #define NM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTINGS, NMSettings)) @@ -51,11 +51,11 @@ #define NM_SETTINGS_SIGNAL_AGENT_REGISTERED "agent-registered" struct _NMSettings { - GObject parent_instance; + NMExportedObject parent_instance; }; typedef struct { - GObjectClass parent_class; + NMExportedObjectClass parent_class; /* Signals */ void (*properties_changed) (NMSettings *self, GHashTable *properties); @@ -73,7 +73,8 @@ typedef struct { GType nm_settings_get_type (void); -NMSettings *nm_settings_new (GError **error); +NMSettings *nm_settings_new (void); +gboolean nm_settings_start (NMSettings *self, GError **error); typedef void (*NMSettingsForEachFunc) (NMSettings *settings, NMSettingsConnection *connection, @@ -86,13 +87,14 @@ void nm_settings_for_each_connection (NMSettings *settings, typedef void (*NMSettingsAddCallback) (NMSettings *settings, NMSettingsConnection *connection, GError *error, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, + NMAuthSubject *subject, gpointer user_data); void nm_settings_add_connection_dbus (NMSettings *self, NMConnection *connection, gboolean save_to_disk, - DBusGMethodInvocation *context, + GDBusMethodInvocation *context, NMSettingsAddCallback callback, gpointer user_data); @@ -111,7 +113,7 @@ NMSettingsConnection *nm_settings_get_connection_by_path (NMSettings *settings, NMSettingsConnection *nm_settings_get_connection_by_uuid (NMSettings *settings, const char *uuid); -gboolean nm_settings_has_connection (NMSettings *self, NMConnection *connection); +gboolean nm_settings_has_connection (NMSettings *self, NMSettingsConnection *connection); const GSList *nm_settings_get_unmanaged_specs (NMSettings *self); diff --git a/src/settings/nm-system-config-interface.c b/src/settings/nm-system-config-interface.c deleted file mode 100644 index 637c301e..00000000 --- a/src/settings/nm-system-config-interface.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2011 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#include "config.h" - -#include "nm-system-config-interface.h" -#include "nm-settings-connection.h" - -static void -interface_init (gpointer g_iface) -{ - GType iface_type = G_TYPE_FROM_INTERFACE (g_iface); - static gboolean initialized = FALSE; - - if (initialized) - return; - - /* Properties */ - g_object_interface_install_property - (g_iface, - g_param_spec_string (NM_SYSTEM_CONFIG_INTERFACE_NAME, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property - (g_iface, - g_param_spec_string (NM_SYSTEM_CONFIG_INTERFACE_INFO, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property - (g_iface, - g_param_spec_uint (NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES, "", "", - NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE, - ( NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS - | NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME), - NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property - (g_iface, - g_param_spec_string (NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - - /* Signals */ - g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSystemConfigInterface, connection_added), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - NM_TYPE_SETTINGS_CONNECTION); - - g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSystemConfigInterface, unmanaged_specs_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - g_signal_new (NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED, - iface_type, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (NMSystemConfigInterface, unrecognized_specs_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - initialized = TRUE; -} - - -GType -nm_system_config_interface_get_type (void) -{ - static GType system_config_interface_type = 0; - - if (!system_config_interface_type) { - const GTypeInfo system_config_interface_info = { - sizeof (NMSystemConfigInterface), /* class_size */ - interface_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - - system_config_interface_type = g_type_register_static (G_TYPE_INTERFACE, - "NMSystemConfigInterface", - &system_config_interface_info, - 0); - - g_type_interface_add_prerequisite (system_config_interface_type, G_TYPE_OBJECT); - } - - return system_config_interface_type; -} - -void -nm_system_config_interface_init (NMSystemConfigInterface *config, - gpointer unused) -{ - g_return_if_fail (config != NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->init) - NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->init (config); -} - -GSList * -nm_system_config_interface_get_connections (NMSystemConfigInterface *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_connections) - return NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_connections (config); - return NULL; -} - -gboolean -nm_system_config_interface_load_connection (NMSystemConfigInterface *config, - const char *filename) -{ - g_return_val_if_fail (config != NULL, FALSE); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->load_connection) - return NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->load_connection (config, filename); - return FALSE; -} - -void -nm_system_config_interface_reload_connections (NMSystemConfigInterface *config) -{ - g_return_if_fail (config != NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->reload_connections) - NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->reload_connections (config); -} - -GSList * -nm_system_config_interface_get_unmanaged_specs (NMSystemConfigInterface *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_unmanaged_specs) - return NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_unmanaged_specs (config); - return NULL; -} - -GSList * -nm_system_config_interface_get_unrecognized_specs (NMSystemConfigInterface *config) -{ - g_return_val_if_fail (config != NULL, NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_unrecognized_specs) - return NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->get_unrecognized_specs (config); - return NULL; -} - -/** - * nm_system_config_interface_add_connection: - * @config: the #NMSystemConfigInterface - * @connection: the source connection to create a plugin-specific - * #NMSettingsConnection from - * @save_to_disk: %TRUE to save the connection to disk immediately, %FALSE to - * not save to disk - * @error: on return, a location to store any errors that may occur - * - * Creates a new #NMSettingsConnection for the given source @connection. If the - * plugin cannot handle the given connection type, it should return %NULL and - * set @error. The plugin owns the returned object and the caller must reference - * the object if it wishes to continue using it. - * - * Returns: the new #NMSettingsConnection or %NULL - */ -NMSettingsConnection * -nm_system_config_interface_add_connection (NMSystemConfigInterface *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error) -{ - g_return_val_if_fail (config != NULL, NULL); - g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); - - if (NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection) - return NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE (config)->add_connection (config, connection, save_to_disk, error); - - return NULL; -} diff --git a/src/settings/nm-system-config-interface.h b/src/settings/nm-system-config-interface.h deleted file mode 100644 index 144aadbf..00000000 --- a/src/settings/nm-system-config-interface.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2007 - 2011 Red Hat, Inc. - * Copyright (C) 2008 Novell, Inc. - */ - -#ifndef __NETWORKMANAGER_SYSTEM_CONFIG_INTERFACE_H__ -#define __NETWORKMANAGER_SYSTEM_CONFIG_INTERFACE_H__ - -#include <glib.h> -#include <glib-object.h> -#include <nm-connection.h> -#include "nm-types.h" - -G_BEGIN_DECLS - -/* Plugin's factory function that returns a GObject that implements - * NMSystemConfigInterface. - */ -GObject * nm_system_config_factory (void); - -#define NM_TYPE_SYSTEM_CONFIG_INTERFACE (nm_system_config_interface_get_type ()) -#define NM_SYSTEM_CONFIG_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE, NMSystemConfigInterface)) -#define NM_IS_SYSTEM_CONFIG_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE)) -#define NM_SYSTEM_CONFIG_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NM_TYPE_SYSTEM_CONFIG_INTERFACE, NMSystemConfigInterface)) - - -#define NM_SYSTEM_CONFIG_INTERFACE_NAME "name" -#define NM_SYSTEM_CONFIG_INTERFACE_INFO "info" -#define NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES "capabilities" -#define NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME "hostname" - -#define NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED "unmanaged-specs-changed" -#define NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED "unrecognized-specs-changed" -#define NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED "connection-added" - -typedef enum { - NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE = 0x00000000, - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS = 0x00000001, - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME = 0x00000002 - - /* When adding more capabilities, be sure to update the "Capabilities" - * property max value in nm-system-config-interface.c. - */ -} NMSystemConfigInterfaceCapabilities; - -typedef enum { - NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST = 0x1000, - - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME = NM_SYSTEM_CONFIG_INTERFACE_PROP_FIRST, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, -} NMSystemConfigInterfaceProp; - - -typedef struct _NMSystemConfigInterface NMSystemConfigInterface; - -struct _NMSystemConfigInterface { - GTypeInterface g_iface; - - /* Called when the plugin is loaded to initialize it */ - void (*init) (NMSystemConfigInterface *config); - - /* Returns a GSList of NMSettingsConnection objects that represent - * connections the plugin knows about. The returned list is freed by the - * system settings service. - */ - GSList * (*get_connections) (NMSystemConfigInterface *config); - - /* Requests that the plugin load/reload a single connection, if it - * recognizes the filename. Returns success or failure. - */ - gboolean (*load_connection) (NMSystemConfigInterface *config, - const char *filename); - - /* Requests that the plugin reload all connection files from disk, - * and emit signals reflecting new, changed, and removed connections. - */ - void (*reload_connections) (NMSystemConfigInterface *config); - - /* - * Return a string list of specifications of devices which NetworkManager - * should not manage. Returned list will be freed by the system settings - * service, and each element must be allocated using g_malloc() or its - * variants (g_strdup, g_strdup_printf, etc). - * - * Each string in the list must be in one of the formats recognized by - * nm_device_spec_match_list(). - */ - GSList * (*get_unmanaged_specs) (NMSystemConfigInterface *config); - - /* - * Return a string list of specifications of devices for which at least - * one non-NetworkManager-based configuration is defined. Returned list - * will be freed by the system settings service, and each element must be - * allocated using g_malloc() or its variants (g_strdup, g_strdup_printf, - * etc). - * - * Each string in the list must be in one of the formats recognized by - * nm_device_spec_match_list(). - */ - GSList * (*get_unrecognized_specs) (NMSystemConfigInterface *config); - - /* - * Initialize the plugin-specific connection and return a new - * NMSettingsConnection subclass that contains the same settings as the - * original connection. The connection should only be saved to backing - * storage if @save_to_disk is TRUE. The returned object is owned by the - * plugin and must be referenced by the owner if necessary. - */ - NMSettingsConnection * (*add_connection) (NMSystemConfigInterface *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error); - - /* Signals */ - - /* Emitted when a new connection has been found by the plugin */ - void (*connection_added) (NMSystemConfigInterface *config, - NMSettingsConnection *connection); - - /* Emitted when the list of unmanaged device specifications changes */ - void (*unmanaged_specs_changed) (NMSystemConfigInterface *config); - - /* Emitted when the list of devices with unrecognized connections changes */ - void (*unrecognized_specs_changed) (NMSystemConfigInterface *config); -}; - -GType nm_system_config_interface_get_type (void); - -void nm_system_config_interface_init (NMSystemConfigInterface *config, - gpointer unused); - -GSList *nm_system_config_interface_get_connections (NMSystemConfigInterface *config); - -gboolean nm_system_config_interface_load_connection (NMSystemConfigInterface *config, - const char *filename); -void nm_system_config_interface_reload_connections (NMSystemConfigInterface *config); - -GSList *nm_system_config_interface_get_unmanaged_specs (NMSystemConfigInterface *config); -GSList *nm_system_config_interface_get_unrecognized_specs (NMSystemConfigInterface *config); - -NMSettingsConnection *nm_system_config_interface_add_connection (NMSystemConfigInterface *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error); - -G_END_DECLS - -#endif /* NM_SYSTEM_CONFIG_INTERFACE_H */ diff --git a/src/settings/plugins/Makefile.am b/src/settings/plugins/Makefile.am index 568da7f6..278d455d 100644 --- a/src/settings/plugins/Makefile.am +++ b/src/settings/plugins/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=keyfile example +SUBDIRS=keyfile @GNOME_CODE_COVERAGE_RULES@ @@ -10,10 +10,6 @@ if CONFIG_PLUGIN_IFCFG_RH SUBDIRS+=ifcfg-rh endif -if CONFIG_PLUGIN_IFCFG_SUSE -SUBDIRS+=ifcfg-suse -endif - if CONFIG_PLUGIN_IFUPDOWN SUBDIRS+=ifupdown endif diff --git a/src/settings/plugins/Makefile.in b/src/settings/plugins/Makefile.in index c706214b..643e0da7 100644 --- a/src/settings/plugins/Makefile.in +++ b/src/settings/plugins/Makefile.in @@ -89,9 +89,8 @@ build_triplet = @build@ host_triplet = @host@ @CONFIG_PLUGIN_IBFT_TRUE@am__append_1 = ibft @CONFIG_PLUGIN_IFCFG_RH_TRUE@am__append_2 = ifcfg-rh -@CONFIG_PLUGIN_IFCFG_SUSE_TRUE@am__append_3 = ifcfg-suse -@CONFIG_PLUGIN_IFUPDOWN_TRUE@am__append_4 = ifupdown -@CONFIG_PLUGIN_IFNET_TRUE@am__append_5 = ifnet +@CONFIG_PLUGIN_IFUPDOWN_TRUE@am__append_3 = ifupdown +@CONFIG_PLUGIN_IFNET_TRUE@am__append_4 = ifnet subdir = src/settings/plugins ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ @@ -168,8 +167,8 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = keyfile example ibft ifcfg-rh ifcfg-suse ifupdown ifnet -am__DIST_COMMON = $(srcdir)/Makefile.in +DIST_SUBDIRS = keyfile ibft ifcfg-rh ifupdown ifnet +am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -211,7 +210,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -223,8 +221,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -234,6 +230,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -288,16 +285,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -334,6 +328,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -362,7 +358,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -377,6 +372,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -437,6 +434,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -444,6 +442,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -459,8 +458,8 @@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ -SUBDIRS = keyfile example $(am__append_1) $(am__append_2) \ - $(am__append_3) $(am__append_4) $(am__append_5) +SUBDIRS = keyfile $(am__append_1) $(am__append_2) $(am__append_3) \ + $(am__append_4) all: all-recursive .SUFFIXES: diff --git a/src/settings/plugins/README b/src/settings/plugins/README new file mode 100644 index 00000000..307d0bb1 --- /dev/null +++ b/src/settings/plugins/README @@ -0,0 +1,33 @@ +Plugins generally have three components: + +1) plugin object: manages the individual "connections", which are + just objects wrapped around on-disk config data. The plugin handles requests + to add new connections via the NM D-Bus API, and also watches config + directories for changes to configuration data. Plugins implement the + NMSettingsPlugin interface. See plugin.c. + +2) "connections": subclasses of NMSettingsConnection. They handle updates to + configuration data, deletion, etc. See NMKeyfileConnection. + +3) reader/writer code: typically a separate static library that gets linked + into the main plugin shared object, so they can be unit tested separately + from the plugin. This code should read config data from disk and create + an NMConnection from it, and be capable of taking an NMConnection and writing + out appropriate configuration data to disk. + +NM will first call the "factory" function that every module must provide, which +is nm_settings_plugin_factory(). That function creates and returns a singleton +instance of the plugin's main object, which implements NMSettingsPlugin. +That interface is implemented via the object definition in G_DEFINE_TYPE_EXTENDED +in plugin.c, which registers the interface setup function +settings_plugin_interface_init(), which when called actually sets up the vtables +for the functions defined by NMSettingsPluginInterface. Thus there are two +entry points into the plugin: nm_settings_plugin_factory() and +the NMSettingsPluginInterface methods. + +The plugin also emits various signals (defined by NMSettingsPluginInterface) +which NetworkManager listens for. These include notifications of new +connections if they were created via changes to the on-disk files. The +"connection" objects can also emit signals (defined by the NMSettingsConnection +and NMConnection superclasses) when the connections' backing storage gets +changed or deleted. diff --git a/src/settings/plugins/example/Makefile.am b/src/settings/plugins/example/Makefile.am deleted file mode 100644 index 7ce8eaea..00000000 --- a/src/settings/plugins/example/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - -# 'noinst' here because this is an example plugin we don't want to install -noinst_LTLIBRARIES = libnm-settings-plugin-example.la - -# The actual plugins typically pull reader.c and writer.c out into -# their own static library so that unit tests can use them without -# having to build the entire plugin. But since this is a simple -# plugin we don't do that yet. - -libnm_settings_plugin_example_la_SOURCES = \ - nm-example-connection.c \ - nm-example-connection.h \ - plugin.c \ - plugin.h \ - common.h \ - reader.c \ - writer.c - -libnm_settings_plugin_example_la_LDFLAGS = -module -avoid-version - diff --git a/src/settings/plugins/example/Makefile.in b/src/settings/plugins/example/Makefile.in deleted file mode 100644 index 5f16d186..00000000 --- a/src/settings/plugins/example/Makefile.in +++ /dev/null @@ -1,779 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/example -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gettext.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LTLIBRARIES = $(noinst_LTLIBRARIES) -libnm_settings_plugin_example_la_LIBADD = -am_libnm_settings_plugin_example_la_OBJECTS = \ - nm-example-connection.lo plugin.lo reader.lo writer.lo -libnm_settings_plugin_example_la_OBJECTS = \ - $(am_libnm_settings_plugin_example_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_example_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_example_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_settings_plugin_example_la_SOURCES) -DIST_SOURCES = $(libnm_settings_plugin_example_la_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp README -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-example"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - -DNMCONFDIR=\"$(nmconfdir)\" - - -# 'noinst' here because this is an example plugin we don't want to install -noinst_LTLIBRARIES = libnm-settings-plugin-example.la - -# The actual plugins typically pull reader.c and writer.c out into -# their own static library so that unit tests can use them without -# having to build the entire plugin. But since this is a simple -# plugin we don't do that yet. -libnm_settings_plugin_example_la_SOURCES = \ - nm-example-connection.c \ - nm-example-connection.h \ - plugin.c \ - plugin.h \ - common.h \ - reader.c \ - writer.c - -libnm_settings_plugin_example_la_LDFLAGS = -module -avoid-version -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/example/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/example/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-settings-plugin-example.la: $(libnm_settings_plugin_example_la_OBJECTS) $(libnm_settings_plugin_example_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_example_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_example_la_LINK) $(libnm_settings_plugin_example_la_OBJECTS) $(libnm_settings_plugin_example_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-example-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/example/README b/src/settings/plugins/example/README deleted file mode 100644 index 224814d1..00000000 --- a/src/settings/plugins/example/README +++ /dev/null @@ -1,35 +0,0 @@ -Plugins generally have three components: - -1) plugin object: manages the individual "connections", which are - just objects wrapped around on-disk config data. The plugin handles requests - to add new connections via the NM D-Bus API, and also watches config - directories for changes to configuration data. It also handles reading and - writing the persistent hostname, if the plugin supports hostnames. Plugins - implement the NMSystemConfigInterface interface. See plugin.c. - -2) "connections": subclasses of NMSettingsConnection. They handle updates to - configuration data, deletion, etc. See NMExampleConnection.c. - -3) reader/writer code: typically a separate static library that gets linked - into the main plugin shared object, so they can be unit tested separately - from the plugin. This code should read config data from disk and create - an NMConnection from it, and be capable of taking an NMConnection and writing - out appropriate configuration data to disk. - -NM will first call the "factory" function that every module must provide, which -is nm_system_config_factory(). That function creates and returns a singleton -instance of the plugin's main object, which implements NMSystemConfigInterface. -That interface is implemented via the object definition in G_DEFINE_TYPE_EXTENDED -in plugin.c, which registers the interface setup function -system_config_interface_init(), which when called actually sets up the vtables -for the functions defined by NMSystemConfigInterface. Thus there are two -entry points into the plugin: nm_system_config_factory() and -the NMSystemConfigInterface methods. - -The plugin also emits various signals (defined by NMSystemConfigInterface) -which NetworkManager listens for. These include persistent hostname changes -(if something modified the file in which the persistent hostname is stored) -and notifications of new connections if they were created via changes to -the on-disk files. The "connection" objects can also emit signals -(defined by the NMSettingsConnection and NMConnection superclasses) when the -connections' backing storage gets changed or deleted. diff --git a/src/settings/plugins/example/common.h b/src/settings/plugins/example/common.h deleted file mode 100644 index cf209fe0..00000000 --- a/src/settings/plugins/example/common.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2012 Red Hat, Inc. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#include <glib.h> - -#include <nm-connection.h> - -/* General info about the plugin that the code may want to use for logging - * purposes. - */ -#define EXAMPLE_PLUGIN_NAME "example" -#define EXAMPLE_PLUGIN_INFO "(c) 2012 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - -#define EXAMPLE_DIR NMCONFDIR "/example-plugin" - -/* Prototypes for the reader/writer functions */ -NMConnection *connection_from_file (const char *filename, GError **error); - -gboolean write_connection (NMConnection *connection, - const char *existing_path, - char **out_path, - GError **error); - -#endif /* __COMMON_H__ */ - diff --git a/src/settings/plugins/example/nm-example-connection.c b/src/settings/plugins/example/nm-example-connection.c deleted file mode 100644 index e1259611..00000000 --- a/src/settings/plugins/example/nm-example-connection.c +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <string.h> -#include <glib/gstdio.h> -#include <nm-dbus-interface.h> -#include <nm-setting-connection.h> -#include <nm-utils.h> - -#include "nm-system-config-interface.h" -#include "nm-dbus-glib-types.h" -#include "nm-example-connection.h" -#include "common.h" - -/* GObject boilerplate; this object is a subclass of NMSettingsConnection - * which is specified by the NM_TYPE_SETTINGS_CONNECTION bit here. That - * in turn is a subclass of NMConnection, so it ends up that NMExampleConnection - * is a subclass of NMConnection too. - */ -G_DEFINE_TYPE (NMExampleConnection, nm_example_connection, NM_TYPE_SETTINGS_CONNECTION) - -#define NM_EXAMPLE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionPrivate)) - -/* Object private instance data */ -typedef struct { - char *path; -} NMExampleConnectionPrivate; - - -/* Creates a new object which encapsulates an on-disk connection and any - * plugin-specific operations or data. - */ -NMExampleConnection * -nm_example_connection_new (const char *full_path, - NMConnection *source, - GError **error) -{ - GObject *object; - NMExampleConnectionPrivate *priv; - NMConnection *tmp; - const char *uuid; - - g_return_val_if_fail (full_path != NULL, NULL); - - /* If we're given a connection already, prefer that instead of re-reading */ - if (source) - tmp = g_object_ref (source); - else { - /* Read the data offdisk and translate it into a simple NMConnection object */ - tmp = connection_from_file (full_path, error); - if (!tmp) - return NULL; - } - - /* Actually create the new NMExampleConnection object */ - object = (GObject *) g_object_new (NM_TYPE_EXAMPLE_CONNECTION, NULL); - priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (object); - priv->path = g_strdup (full_path); - - /* Update our settings with what was read from the file or what got passed - * in as a source NMConnection. - */ - if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), - tmp, - TRUE, - NULL, - error)) { - g_object_unref (object); - object = NULL; - goto out; - } - - /* Make sure we have a UUID; just a sanity check */ - uuid = nm_connection_get_uuid (NM_CONNECTION (object)); - if (!uuid) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Connection in file %s had no UUID", full_path); - g_object_unref (object); - object = NULL; - } - -out: - g_object_unref (tmp); - return (NMExampleConnection *) object; -} - -const char * -nm_example_connection_get_path (NMExampleConnection *self) -{ - g_return_val_if_fail (NM_IS_EXAMPLE_CONNECTION (self), NULL); - - /* Simple accessor that returns the file path from our private instance data */ - return NM_EXAMPLE_CONNECTION_GET_PRIVATE (self)->path; -} - -static void -commit_changes (NMSettingsConnection *connection, - NMSettingsConnectionCommitFunc callback, - gpointer user_data) -{ - NMExampleConnectionPrivate *priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (connection); - char *path = NULL; - GError *error = NULL; - - /* Write the new connection data out to disk. This function passes - * back the path of the file it wrote out so that we know what that - * path is if the connection is a completely new one. - */ - if (!write_connection (NM_CONNECTION (connection), priv->path, &path, &error)) { - callback (connection, error, user_data); - g_clear_error (&error); - return; - } - - /* Update the filename if it changed */ - if (path) { - g_free (priv->path); - priv->path = path; - } - - /* Chain up to parent for generic commit stuff */ - NM_SETTINGS_CONNECTION_CLASS (nm_example_connection_parent_class)->commit_changes (connection, - callback, - user_data); -} - -static void -do_delete (NMSettingsConnection *connection, - NMSettingsConnectionDeleteFunc callback, - gpointer user_data) -{ - NMExampleConnectionPrivate *priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (connection); - - g_unlink (priv->path); - - /* Chain up to parent for generic deletion stuff */ - NM_SETTINGS_CONNECTION_CLASS (nm_example_connection_parent_class)->delete (connection, - callback, - user_data); -} - -/**************************************************************/ - -static void -nm_example_connection_init (NMExampleConnection *connection) -{ -} - -static void -finalize (GObject *object) -{ - g_free (NM_EXAMPLE_CONNECTION_GET_PRIVATE (object)->path); - - G_OBJECT_CLASS (nm_example_connection_parent_class)->finalize (object); -} - -static void -nm_example_connection_class_init (NMExampleConnectionClass *keyfile_connection_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (keyfile_connection_class); - NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class); - - /* Tells GObject to allocate and zero our instance data pointer */ - g_type_class_add_private (keyfile_connection_class, sizeof (NMExampleConnectionPrivate)); - - /* Overrides of various superclass methods */ - object_class->finalize = finalize; - settings_class->commit_changes = commit_changes; - settings_class->delete = do_delete; -} diff --git a/src/settings/plugins/example/nm-example-connection.h b/src/settings/plugins/example/nm-example-connection.h deleted file mode 100644 index ddbd7ac2..00000000 --- a/src/settings/plugins/example/nm-example-connection.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#ifndef __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ -#define __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ - -#include <nm-settings-connection.h> - -G_BEGIN_DECLS - -/* GObject boilerplate */ -#define NM_TYPE_EXAMPLE_CONNECTION (nm_example_connection_get_type ()) -#define NM_EXAMPLE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnection)) -#define NM_EXAMPLE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionClass)) -#define NM_IS_EXAMPLE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_EXAMPLE_CONNECTION)) -#define NM_IS_EXAMPLE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_EXAMPLE_CONNECTION)) -#define NM_EXAMPLE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_EXAMPLE_CONNECTION, NMExampleConnectionClass)) - -typedef struct { - NMSettingsConnection parent; -} NMExampleConnection; - -typedef struct { - NMSettingsConnectionClass parent; -} NMExampleConnectionClass; - -GType nm_example_connection_get_type (void); - -/* Actual API that plugin.c will call */ -NMExampleConnection *nm_example_connection_new (const char *filename, - NMConnection *source, - GError **error); - -const char *nm_example_connection_get_path (NMExampleConnection *self); - -G_END_DECLS - -#endif /* __NETWORKMANAGER_EXAMPLE_CONNECTION_H__ */ diff --git a/src/settings/plugins/example/plugin.c b/src/settings/plugins/example/plugin.c deleted file mode 100644 index 0bcb38fc..00000000 --- a/src/settings/plugins/example/plugin.c +++ /dev/null @@ -1,858 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - keyfile plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <sys/stat.h> -#include <unistd.h> -#include <sys/types.h> -#include <string.h> - -#include <gmodule.h> -#include <glib.h> -#include <glib/gstdio.h> -#include <gio/gio.h> - -#include <nm-connection.h> -#include <nm-setting.h> -#include <nm-setting-connection.h> -#include <nm-utils.h> -#include <nm-config.h> -#include <nm-logging.h> - -#include "plugin.h" -#include "nm-system-config-interface.h" -#include "common.h" -#include "nm-example-connection.h" - -static char *plugin_get_hostname (SCPluginExample *plugin); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); - -/* GObject object definition. This actually defines the object and tells - * GObject about the interfaces this object provides. Here we provide - * the "system config interface" which is the API that NetworkManager uses - * to communicate with this plugin. - * - * Interface and super/sub-class access with GObject works via casting and - * GObject magically figures out what needs to be called. So, given: - * - * SCPluginExample *plugin = <new plugin>; - * - * you can call GObject methods since SCPluginExample inherits from GObject - * via the G_TYPE_OBJECT argument of G_DEFINE_TYPE_EXTENDED below: - * - * g_object_set_data (G_OBJECT (plugin), ...); - * - * and since SCPluginExample implements NMSystemConfigInterface via the - * G_IMPLEMENT_INTERFACE bit below, we can also call any methods of - * NMSystemConfigInterface (defined in NM sources in nm-system-config-interface.c): - * - * connections = nm_system_config_interface_get_connections (NM_SYSTEM_CONFIG_INTERFACE (plugin)); - * - * For the call to nm_system_config_interface_get_connections() that eventually - * ends up in the get_connections() method in this file because the - * system_config_interface_init() function sets up the vtable for this objects - * implementation of NMSystemConfigInterface. - */ -G_DEFINE_TYPE_EXTENDED (SCPluginExample, sc_plugin_example, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) - -/* Quick define to access the object's private data pointer; this pointer - * points to the object's instance data. - */ -#define SC_PLUGIN_EXAMPLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExamplePrivate)) - -/* Instance data. When the object is created, a new structure of this type - * will be created and zeroed for this instance of the object to use. This - * is actually done by g_type_class_add_private() when called from the object's - * class init function. - */ -typedef struct { - /* This hash holds each connection known to this plugin */ - GHashTable *connections; - - /* A watch for changes on the directory that holds the configuration files - * so the plugin can respond to configuration changes on-the-fly and - * tell NM that the connection data has changed. Typically the plugin - * needs to monitor the directory itself (to watch for completely new files) - * while the individual connections watch their individual config files. - */ - GFileMonitor *monitor; - guint monitor_id; - - /* Tracks changes to the global NM config file, just in case our - * plugin has some specific options (like unmanaged devices) that - * might be changed at runtime. - */ - const char *conf_file; - GFileMonitor *conf_file_monitor; - guint conf_file_monitor_id; - - /* Persistent hostname if the plugin supports hostnames. Normally used - * for distro plugins; ie Red Hat uses /etc/sysconfig/hostname while - * Debian uses /etc/hostname. Plugins can abstract the storage location - * and just tell NM what the persisten hostname is and when its backing - * file has changed. NM handles actually setting the hostname. - */ - char *hostname; -} SCPluginExamplePrivate; - -static NMSettingsConnection * -_internal_new_connection (SCPluginExample *self, - const char *full_path, - NMConnection *source, - GError **error) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - NMExampleConnection *connection; - - g_return_val_if_fail (full_path != NULL, NULL); - - /* 'source' will usually be NULL if we're going to read the connection - * off disk. But if the new connection is coming from NetworkManager - * (ie, from a D-Bus AddConnection request) then we'll have 'source' too. - * This function expects the connection to already be written to disk - * so that the NMExampleConnection object can re-read it and intialize - * state in the same manner as when getting a change notification from - * the config directory. That simplifies things somewhat. - */ - - connection = nm_example_connection_new (full_path, source, error); - if (connection) { - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (connection)), - connection); - } - - return (NMSettingsConnection *) connection; -} - -/* Read each file in our config directory and try to create a new - * NMExamplePlugin for it. - */ -static void -read_connections (NMSystemConfigInterface *config) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - GDir *dir; - GError *error = NULL; - const char *item; - - dir = g_dir_open (EXAMPLE_DIR, 0, &error); - if (!dir) { - nm_log_warn (LOGD_SETTINGS, "Cannot read directory '%s': (%d) %s", - EXAMPLE_DIR, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); - g_clear_error (&error); - return; - } - - while ((item = g_dir_read_name (dir))) { - NMSettingsConnection *connection; - char *full_path; - - /* XXX: Check file extension and ignore "~", ".tmp", ".bak", etc */ - - full_path = g_build_filename (EXAMPLE_DIR, item, NULL); - nm_log_info (LOGD_SETTINGS, "parsing %s ... ", item); - - connection = _internal_new_connection (self, full_path, NULL, &error); - if (connection) { - nm_log_info (LOGD_SETTINGS, " read connection '%s'", - nm_connection_get_id (NM_CONNECTION (connection))); - } else { - nm_log_info (LOGD_SETTINGS, " error: %s", - (error && error->message) ? error->message : "(unknown)"); - } - g_clear_error (&error); - g_free (full_path); - } - g_dir_close (dir); -} - -static void -update_connection_settings_commit_cb (NMSettingsConnection *orig, GError *error, gpointer user_data) -{ - /* If there was an error updating the connection's internal stuff, then - * we can't do anything except log it and remove the connection. This might - * happen due to invalid data, but as the data would already have been - * verified before it ever got to this plugin, we shouldn't ever get - * an error here. - */ - if (error) { - nm_log_warn (LOGD_SETTINGS, "%s: connection invalid: %s", - __func__, error->message); - g_clear_error (&error); - - nm_settings_connection_signal_remove (orig); - } -} - -static void -update_connection_settings (NMExampleConnection *orig, - NMExampleConnection *new) -{ - /* This just replaces the orig's internal settings with those from new */ - nm_settings_connection_replace_and_commit (NM_SETTINGS_CONNECTION (orig), - NM_CONNECTION (new), - update_connection_settings_commit_cb, NULL); -} - -/* Monitoring */ - -static void -remove_connection (SCPluginExample *self, - NMExampleConnection *connection, - const char *name) -{ - g_return_if_fail (connection != NULL); - g_return_if_fail (name != NULL); - - /* Removing from the hash table should drop the last reference, but since - * we need the object to stay alive across the signal emission to NM, - * we grab a temporary reference. - */ - g_object_ref (connection); - g_hash_table_remove (SC_PLUGIN_EXAMPLE_GET_PRIVATE (self)->connections, name); - - /* Tell NM the connection is gone */ - nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); - - /* Remove the temporary reference; connection will now be destroyed */ - g_object_unref (connection); -} - -/* Look through all connections we know about and return one with a given UUID */ -static NMExampleConnection * -find_by_uuid (SCPluginExample *self, const char *uuid) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - GHashTableIter iter; - gpointer data = NULL; - - g_return_val_if_fail (uuid != NULL, NULL); - - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, &data)) { - NMConnection *candidate = NM_CONNECTION (data); - - if (strcmp (uuid, nm_connection_get_uuid (candidate)) == 0) - return NM_EXAMPLE_CONNECTION (candidate); - } - return NULL; -} - - -static void -dir_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - NMSystemConfigInterface *config = NM_SYSTEM_CONFIG_INTERFACE (user_data); - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - char *full_path; - NMExampleConnection *connection; - GError *error = NULL; - - full_path = g_file_get_path (file); - /* XXX: Check here if you need to ignore this file, ie by checking for - * extensions like "~" and ".bak" or ".tmp". If so just return; - */ - - /* Check if we know about this connection already */ - connection = g_hash_table_lookup (priv->connections, full_path); - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - if (connection) { - nm_log_info (LOGD_SETTINGS, "removed %s.", full_path); - remove_connection (SC_PLUGIN_EXAMPLE (config), connection, full_path); - } - break; - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - if (connection) { - /* Update of an existing connection. Here we re-read the file and - * compare it against the existing connection to check if anything - * actually changed. - */ - NMExampleConnection *tmp; - - tmp = nm_example_connection_new (full_path, NULL, &error); - if (tmp) { - if (!nm_connection_compare (NM_CONNECTION (connection), - NM_CONNECTION (tmp), - NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | - NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { - /* Connection changed; update our internal connection object */ - nm_log_info (LOGD_SETTINGS, "updating %s", full_path); - update_connection_settings (connection, tmp); - } - g_object_unref (tmp); - } else { - /* There was an error parsing the updated connection; it may - * no longer be valid and thus we've got to delete it. If it - * becomes valid again later we'll get another change - * notification, we'll re-read it, and we'll treat it as new. - */ - nm_log_info (LOGD_SETTINGS, " error: %s", - (error && error->message) ? error->message : "(unknown)"); - remove_connection (SC_PLUGIN_EXAMPLE (config), connection, full_path); - } - g_clear_error (&error); - } else { - nm_log_info (LOGD_SETTINGS, "updating %s", full_path); - - /* We don't know about the connection yet, so the change represents - * a completely new connection. - */ - connection = nm_example_connection_new (full_path, NULL, &error); - if (connection) { - NMExampleConnection *found = NULL; - - /* Connection renames will show up as different files but with - * the same UUID. Try to find the original connection. - * A connection rename is treated just like an update except - * there's a bit more housekeeping with the hash table. - */ - found = find_by_uuid (self, nm_connection_get_uuid (NM_CONNECTION (connection))); - if (found) { - const char *old_path = nm_example_connection_get_path (connection); - - /* Removing from the hash table should drop the last reference, - * but of course we want to keep the connection around. - */ - g_object_ref (found); - g_hash_table_remove (priv->connections, old_path); - - /* Updating settings should update the NMExampleConnection's - * filename property too. - */ - update_connection_settings (found, connection); - - /* Re-insert the connection back into the hash with the new filename */ - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (found)), - found); - - /* Get rid of the temporary connection */ - g_object_unref (connection); - } else { - /* Completely new connection, not a rename. */ - g_hash_table_insert (priv->connections, - g_strdup (nm_example_connection_get_path (connection)), - connection); - /* Tell NM we found a new connection */ - g_signal_emit_by_name (config, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection); - } - } else { - nm_log_info (LOGD_SETTINGS, " error: %s", (error && error->message) ? error->message : "(unknown)"); - g_clear_error (&error); - } - } - break; - default: - break; - } - - g_free (full_path); -} - -static void -conf_file_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer data) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (data); - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (self); - char *tmp; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - /* Unmanaged devices option may have changed; just emit the changed - * signal for unmanaged specs and when NM calls back in to get the - * updated specs we'll re-read the config file then. - */ - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); - - /* Hostname may also have changed; read it and if it did actually - * change, notify NM. - */ - tmp = plugin_get_hostname (self); - if (g_strcmp0 (tmp, priv->hostname) != 0) { - g_free (priv->hostname); - priv->hostname = tmp; - tmp = NULL; - g_object_notify (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } - g_free (tmp); - break; - default: - break; - } -} - -/* This function starts the inotify monitors that watch the plugin's config - * file directory for new connections and changes to existing connections - * (if not disabled by NetworkManager.conf), and for changes to the plugin's - * non-connection config files. - */ -static void -setup_monitoring (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GFileMonitor *monitor; - GFile *file; - - /* Initialize connection hash here; we use the connection hash as the - * "are we initialized yet" variable. - */ - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - - if (nm_config_get_monitor_connection_files (nm_config_get ())) { - /* Set up the watch for our config directory */ - file = g_file_new_for_path (EXAMPLE_DIR); - monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (monitor) { - /* This registers the dir_changed() function to be called whenever - * the GFileMonitor object notices a change in the directory. - */ - priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), config); - priv->monitor = monitor; - } - } - - /* Set up a watch on our configuration file, basically just for watching - * whether the user has changed the unmanaged devices option or the - * persistent hostname. - */ - if (priv->conf_file) { - file = g_file_new_for_path (priv->conf_file); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->conf_file_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (conf_file_changed), config); - priv->conf_file_monitor = monitor; - } - } -} - -/*******************************************************************/ - -/* Return to NM the full list of connections this plugin owns */ -static GSList * -get_connections (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GHashTableIter iter; - NMSettingsConnection *connection; - GSList *list = NULL; - - if (!priv->connections) { - /* If we haven't read connections in yet, do so now */ - setup_monitoring (config); - read_connections (config); - } - - /* Add each connection from our internal hash table to a list returned - * to NetworkManager. - */ - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) - list = g_slist_prepend (list, connection); - return list; -} - -/* Called by NetworkManager when a user adds a new connection via D-Bus. - * The plugin should convert the data in 'connection' to its on-disk format - * write it out to disk, and return an object that's a subclass of - * NMSettingsConnection. Typically plugins will subclass NMSettingsConnection - * and use that class to handle any plugin-specific stuff like monitoring - * the on-disk config files for changes, and/or parsing the file-format and - * converting back and forth from that to NMConnection. - */ -static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, - NMConnection *connection, - gboolean save_to_disk, - GError **error) -{ - SCPluginExample *self = SC_PLUGIN_EXAMPLE (config); - NMSettingsConnection *added = NULL; - char *path = NULL; - - /* Write it out first, then add the connection to our internal list; that - * way we don't trigger the new NMSettingsConnection subclass' file watch - * functions needlessly. - */ - if (save_to_disk && !write_connection (connection, NULL, &path, error)) - return NULL; - - added = _internal_new_connection (self, path, connection, error); - g_free (path); - return added; -} - -/* This function returns a list of "unmanaged device specs" which represent - * a list of devices that NetworkManager should not manage. Each unmanaged - * spec item has a specific format starting with a "tag" and followed by - * tag-specific data. The only currently specified items are "mac:" followed - * by the MAC address of the interface NM should not manage, or "interface-name:" - * followed by the name of the interface NM should not manage. This function - * reads the list of unmanaged devices from wherever the plugin wants to - * store them and returns that list to NetworkManager. - */ -static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (config); - GKeyFile *key_file; - GSList *specs = NULL; - GError *error = NULL; - char *str, **ids; - int i; - - if (!priv->conf_file) - return NULL; - - key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - goto out; - } - - - str = g_key_file_get_value (key_file, "keyfile", "unmanaged-devices", NULL); - if (!str) - goto out; - - ids = g_strsplit (str, ";", -1); - for (i = 0; ids[i] != NULL; i++) { - /* Verify unmanaged specification and add it to the list */ - if (!strncmp (ids[i], "mac:", 4) && nm_utils_hwaddr_valid (ids[i] + 4, -1)) { - specs = g_slist_append (specs, ids[i]); - } else if (!strncmp (ids[i], "interface-name:", 15) && nm_utils_iface_valid_name (ids[i] + 15)) { - specs = g_slist_append (specs, ids[i]); - } else { - nm_log_warn (LOGD_SETTINGS, "Error in file '%s': invalid unmanaged-devices entry: '%s'", priv->conf_file, ids[i]); - g_free (ids[i]); - } - } - - g_free (ids); /* Yes, g_free, not g_strfreev because we need the strings in the list */ - g_free (str); - -out: - g_key_file_free (key_file); - return specs; -} - - -static char * -plugin_get_hostname (SCPluginExample *plugin) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (plugin); - GKeyFile *key_file; - char *hostname = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - /* Read the persistent hostname out of backing storage, which happens - * to be the NM config file. Other plugins (like distro-specific ones) - * should read it from the distro-specific location like /etc/hostname. - */ - key_file = g_key_file_new (); - if (g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) - hostname = g_key_file_get_value (key_file, "keyfile", "hostname", NULL); - else { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - } - - g_key_file_free (key_file); - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginExample *plugin, const char *hostname) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (plugin); - GKeyFile *key_file; - GError *error = NULL; - gboolean success = FALSE; - char *data; - gsize len; - - if (!priv->conf_file) { - nm_log_warn (LOGD_SETTINGS, "Error saving hostname: no config file"); - return FALSE; - } - - /* This just saves the hostname to the NM config file in a section - * private to this plugin. - */ - key_file = g_key_file_new (); - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &error)) { - nm_log_warn (LOGD_SETTINGS, "Error parsing file '%s': %s", priv->conf_file, error->message); - g_error_free (error); - goto out; - } - - g_key_file_set_string (key_file, "example", "hostname", hostname); - - data = g_key_file_to_data (key_file, &len, &error); - if (data) { - /* Save updated file to disk */ - g_file_set_contents (priv->conf_file, data, len, &error); - g_free (data); - - /* Update internal copy of hostname */ - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - success = TRUE; - } - - if (error) { - nm_log_warn (LOGD_SETTINGS, "Error saving hostname: %s", error->message); - g_error_free (error); - } - -out: - g_key_file_free (key_file); - return success; -} - -/* GObject */ - -static void -sc_plugin_example_init (SCPluginExample *plugin) -{ - /* Here we'd do any instance-specific initialization like setting - * members of SCPluginExamplePrivate to default values. But we - * don't have anything to do here since most initialization is done - * when NM calls the various entry points. - */ -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: - g_value_set_string (value, EXAMPLE_PLUGIN_NAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: - g_value_set_string (value, EXAMPLE_PLUGIN_INFO); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - /* Return capabilities to NM; this plugin supports changing connections - * as well as being capable of saving the hostname to persistent storage. - * If the plugin can't write out updated configuration, then obviously - * it shouldn't advertise that capability. If it can't save hostnames - * to persistent storage, it shouldn't advertise that capability either. - */ - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - /* Return the hostname we've read from persistent storage */ - g_value_set_string (value, SC_PLUGIN_EXAMPLE_GET_PRIVATE (object)->hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - const char *hostname; - - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - /* We'll get here when the user has changed the hostname via NM's - * D-Bus interface and we're requested to save this hostname to - * persistent storage. - */ - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_EXAMPLE (object), hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -dispose (GObject *object) -{ - SCPluginExamplePrivate *priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (object); - - /* GObject has a two-stage object destruction process: dispose and finalize. - * In dispose the object should free any references it might have on other - * objects to break circular refs, then it's finally cleaned up by finalize. - * We don't bother to implement a finalize, so we just make sure that we - * clean everything up (including clearing pointers) in dispose so that - * if GObject decides to revive this object post-dispose (yes, legal) - * we don't crash on dangling pointers. - */ - - if (priv->monitor) { - if (priv->monitor_id) { - g_signal_handler_disconnect (priv->monitor, priv->monitor_id); - priv->monitor_id = 0; - } - - g_file_monitor_cancel (priv->monitor); - g_object_unref (priv->monitor); - priv->monitor = NULL; - } - - if (priv->conf_file_monitor) { - if (priv->conf_file_monitor_id) { - g_signal_handler_disconnect (priv->conf_file_monitor, priv->conf_file_monitor_id); - priv->conf_file_monitor_id = 0; - } - - g_file_monitor_cancel (priv->conf_file_monitor); - g_object_unref (priv->conf_file_monitor); - priv->conf_file_monitor = NULL; - } - - if (priv->connections) { - /* Destroying the connections hash unrefs each connection in it - * due to the GHashTable value_destroy_func that we passed into - * g_hash_table_new_full(). - */ - g_hash_table_destroy (priv->connections); - priv->connections = NULL; - } - - g_free (priv->hostname); - priv->hostname = NULL; - - /* Chain up to the superclass */ - G_OBJECT_CLASS (sc_plugin_example_parent_class)->dispose (object); -} - -/* This function gets called to set up any method and property overrides - * of superclasses, and also (if we actually had any) to set up any - * custom properties and signals this object might have. This is called before - * the object is actually instantiated; it just sets up the generic class - * stuff, not anything related to a specific object instance. - */ -static void -sc_plugin_example_class_init (SCPluginExampleClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - /* This actually creates and zeros the object's instance data struct */ - g_type_class_add_private (req_class, sizeof (SCPluginExamplePrivate)); - - /* Override GObject base class methods with our custom implementations */ - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - /* Override various GObject properties that we need to change. Here we - * just tell GObject that we will be handling the get/set operations for - * these specific properties. They are actually defined by the - * NMSystemConfigInterface interface in nm-system-config-interface.c. - * What happens here is that we tell GObject that for a given property - * name (ie NM_SYSTEM_CONFIG_INTERFACE_NAME) we'll be using the enum value - * NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME locally in get_property() and - * set_property(). - */ - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -system_config_interface_init (NMSystemConfigInterface *sci_intf) -{ - /* Interface implementation for NMSystemConfigInterface. This sets - * up the GInterface vtable that lets GObject know what functions to - * call for each method of the NMSystemConfigInterface interface. - */ - sci_intf->get_connections = get_connections; - sci_intf->add_connection = add_connection; - sci_intf->get_unmanaged_specs = get_unmanaged_specs; -} - -/*******************************************************************/ - -/* Factory function: this is the first entry point for NetworkManager, which - * gets called during NM startup to create the instance of this plugin - * that NetworkManager will actually use. Since every plugin is a singleton - * we just return a singleton instance. This function should never be called - * twice. - */ -G_MODULE_EXPORT GObject * -nm_system_config_factory (void) -{ - static SCPluginExample *singleton = NULL; - SCPluginExamplePrivate *priv; - - if (!singleton) { - /* Instantiate our plugin */ - singleton = SC_PLUGIN_EXAMPLE (g_object_new (SC_TYPE_PLUGIN_EXAMPLE, NULL)); - priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (singleton); - - /* Cache the config file path */ - priv->conf_file = nm_config_data_get_config_main_file (nm_config_get_data (nm_config_get ())); - } else { - /* This function should never be called twice */ - g_assert_not_reached (); - } - - return G_OBJECT (singleton); -} - diff --git a/src/settings/plugins/example/plugin.h b/src/settings/plugins/example/plugin.h deleted file mode 100644 index f10ee1c4..00000000 --- a/src/settings/plugins/example/plugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - example plugin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#include <glib-object.h> - -/* GObject boilerplate: you usually only need to rename 'example' here to - * your plugin's name. These functions get used when casting pointers - * to your plugin's object type. - */ -#define SC_TYPE_PLUGIN_EXAMPLE (sc_plugin_example_get_type ()) -#define SC_PLUGIN_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExample)) -#define SC_PLUGIN_EXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExampleClass)) -#define SC_IS_PLUGIN_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_EXAMPLE)) -#define SC_IS_PLUGIN_EXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_EXAMPLE)) -#define SC_PLUGIN_EXAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_EXAMPLE, SCPluginExampleClass)) - -typedef struct { - /* GObject instance structure for the plugin; we don't do anything special - * here so this object's instance is exactly the same as its parent. - */ - GObject parent; -} SCPluginExample; - -typedef struct { - /* GObject class structure; we don't do anything special here - * so this object's class is exactly the same as its parent. Typically - * if the plugin implemented custom signals their prototypes would go - * here, but most plugins don't need to do this. - */ - GObjectClass parent; -} SCPluginExampleClass; - -GType sc_plugin_example_get_type (void); - -#endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/example/reader.c b/src/settings/plugins/example/reader.c deleted file mode 100644 index ee45440a..00000000 --- a/src/settings/plugins/example/reader.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <glib.h> - -#include <nm-connection.h> -#include <nm-dbus-interface.h> - -#include "common.h" - -NMConnection * -connection_from_file (const char *filename, GError **error) -{ - /* This function should, given a file path, read that file and convert its - * data into an NMConnection. There are two approaches to this. First, - * if the plugin data format is similar to the NMConnection internal - * format, you can get away with calling nm_connection_for_each_setting_value() - * to iterate through every possible setting's keys and read that value - * from the plugin's format. If the plugin's format is siginificantly - * different then you may have to build up the connection manually by - * determining the type of connection from the on-disk data, creating - * each setting object, adding the values, then adding that setting to - * the NMConnection. - */ - - return NULL; -} - diff --git a/src/settings/plugins/example/writer.c b/src/settings/plugins/example/writer.c deleted file mode 100644 index 41e5c498..00000000 --- a/src/settings/plugins/example/writer.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Copyright (C) 2012 Red Hat, Inc. - */ - -#include "config.h" - -#include <glib.h> - -#include <nm-connection.h> - -#include "common.h" - -gboolean -write_connection (NMConnection *connection, - const char *existing_path, - char **out_path, - GError **error) -{ - /* This function should take the NMConnection and convert it to the format - * which this plugin uses on-disk and then write out that data. It returns - * the file path of the file that represents this connection data so that - * the plugin can track it for change notification and updates. If - * 'existing_path' is given we can assume that this is an update of an - * existing connection and not a completely new one. - */ - - /* There are two approaches to converting the data. The first more manual - * approach consists of grabbing each setting value from the NMConnection - * and converting it into the appropriate value for the plugin's data - * format. This is usually taken by distro plugins because their format - * is significantly different than NetworkManager's internal format. - * The second uses nm_connection_for_each_setting_value() to iterate - * through each value of each setting in the NMConnection, convert it to - * the required format, and write it out, but this requires that the - * plugin format more closely follow the NetworkManager internal format. - */ - - return FALSE; -} - diff --git a/src/settings/plugins/ibft/Makefile.am b/src/settings/plugins/ibft/Makefile.am index 6bc9d05d..a994808d 100644 --- a/src/settings/plugins/ibft/Makefile.am +++ b/src/settings/plugins/ibft/Makefile.am @@ -14,14 +14,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSBINDIR=\"$(sbindir)\" diff --git a/src/settings/plugins/ibft/Makefile.in b/src/settings/plugins/ibft/Makefile.in index 1f5b8eb4..024442b1 100644 --- a/src/settings/plugins/ibft/Makefile.in +++ b/src/settings/plugins/ibft/Makefile.in @@ -277,7 +277,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -289,8 +288,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -300,6 +297,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -354,16 +352,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -400,6 +395,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -428,7 +425,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -443,6 +439,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -503,6 +501,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -510,6 +509,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -536,14 +536,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSBINDIR=\"$(sbindir)\" diff --git a/src/settings/plugins/ibft/plugin.c b/src/settings/plugins/ibft/plugin.c index 632c4df1..555725d1 100644 --- a/src/settings/plugins/ibft/plugin.c +++ b/src/settings/plugins/ibft/plugin.c @@ -25,39 +25,38 @@ #include <errno.h> #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <gio/gio.h> #include <nm-setting-connection.h> -#include "nm-dbus-glib-types.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-default.h" +#include "nm-settings-plugin.h" #include "NetworkManagerUtils.h" #include "plugin.h" #include "reader.h" #include "nm-ibft-connection.h" -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginIbft, sc_plugin_ibft, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginIbft, settings_plugin_ibft, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_IBFT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IBFT, SCPluginIbftPrivate)) +#define SETTINGS_PLUGIN_IBFT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftPrivate)) typedef struct { GHashTable *connections; /* uuid::connection */ gboolean initialized; -} SCPluginIbftPrivate; +} SettingsPluginIbftPrivate; + +static SettingsPluginIbft *settings_plugin_ibft_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIbft, settings_plugin_ibft_get, SETTINGS_TYPE_PLUGIN_IBFT); static void -read_connections (SCPluginIbft *self) +read_connections (SettingsPluginIbft *self) { - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); GSList *blocks = NULL, *iter; GError *error = NULL; NMIbftConnection *connection; @@ -86,10 +85,10 @@ read_connections (SCPluginIbft *self) } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIbft *self = SC_PLUGIN_IBFT (config); - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (config); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); GSList *list = NULL; GHashTableIter iter; NMIbftConnection *connection; @@ -107,14 +106,14 @@ get_connections (NMSystemConfigInterface *config) } static void -init (NMSystemConfigInterface *config) +init (NMSettingsPlugin *config) { } static void -sc_plugin_ibft_init (SCPluginIbft *self) +settings_plugin_ibft_init (SettingsPluginIbft *self) { - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } @@ -122,15 +121,15 @@ sc_plugin_ibft_init (SCPluginIbft *self) static void dispose (GObject *object) { - SCPluginIbft *self = SC_PLUGIN_IBFT (object); - SCPluginIbftPrivate *priv = SC_PLUGIN_IBFT_GET_PRIVATE (self); + SettingsPluginIbft *self = SETTINGS_PLUGIN_IBFT (object); + SettingsPluginIbftPrivate *priv = SETTINGS_PLUGIN_IBFT_GET_PRIVATE (self); if (priv->connections) { g_hash_table_destroy (priv->connections); priv->connections = NULL; } - G_OBJECT_CLASS (sc_plugin_ibft_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ibft_parent_class)->dispose (object); } static void @@ -138,14 +137,14 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, "iBFT"); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, "(c) 2014 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE); + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -161,50 +160,39 @@ set_property (GObject *object, guint prop_id, } static void -sc_plugin_ibft_class_init (SCPluginIbftClass *req_class) +settings_plugin_ibft_class_init (SettingsPluginIbftClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIbftPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIbftPrivate)); object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->init = init; } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIbft *singleton = NULL; - - if (!singleton) - singleton = SC_PLUGIN_IBFT (g_object_new (SC_TYPE_PLUGIN_IBFT, NULL)); - else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ibft_get ()); } diff --git a/src/settings/plugins/ibft/plugin.h b/src/settings/plugins/ibft/plugin.h index 2c811359..3fc58c7f 100644 --- a/src/settings/plugins/ibft/plugin.h +++ b/src/settings/plugins/ibft/plugin.h @@ -21,27 +21,27 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_IBFT (sc_plugin_ibft_get_type ()) -#define SC_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IBFT, SCPluginIbft)) -#define SC_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IBFT, SCPluginIbftClass)) -#define SC_IS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IBFT)) -#define SC_IS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IBFT)) -#define SC_PLUGIN_IBFT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IBFT, SCPluginIbftClass)) +#define SETTINGS_TYPE_PLUGIN_IBFT (settings_plugin_ibft_get_type ()) +#define SETTINGS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbft)) +#define SETTINGS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass)) +#define SETTINGS_IS_PLUGIN_IBFT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IBFT)) +#define SETTINGS_IS_PLUGIN_IBFT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IBFT)) +#define SETTINGS_PLUGIN_IBFT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IBFT, SettingsPluginIbftClass)) -typedef struct _SCPluginIbft SCPluginIbft; -typedef struct _SCPluginIbftClass SCPluginIbftClass; +typedef struct _SettingsPluginIbft SettingsPluginIbft; +typedef struct _SettingsPluginIbftClass SettingsPluginIbftClass; -struct _SCPluginIbft { +struct _SettingsPluginIbft { GObject parent; }; -struct _SCPluginIbftClass { +struct _SettingsPluginIbftClass { GObjectClass parent; }; -GType sc_plugin_ibft_get_type (void); +GType settings_plugin_ibft_get_type (void); #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c index 9bc63462..195c2641 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -31,13 +31,10 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <glib.h> -#include <glib/gi18n.h> - +#include "nm-default.h" #include "nm-core-internal.h" #include "nm-platform.h" #include "NetworkManagerUtils.h" -#include "nm-logging.h" #include "reader.h" diff --git a/src/settings/plugins/ibft/reader.h b/src/settings/plugins/ibft/reader.h index 0b2f22b6..42969ae0 100644 --- a/src/settings/plugins/ibft/reader.h +++ b/src/settings/plugins/ibft/reader.h @@ -21,9 +21,10 @@ #ifndef __READER_H__ #define __READER_H__ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + gboolean read_ibft_blocks (const char *iscsiadm_path, GSList **out_blocks, GError **error); diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am index 9901119e..29881e85 100644 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ b/src/settings/plugins/ibft/tests/Makefile.am @@ -5,8 +5,8 @@ if ENABLE_TESTS AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ @@ -14,14 +14,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_IBFT_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" AM_LDFLAGS = \ $(GLIB_LIBS) \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) noinst_PROGRAMS = test-ibft diff --git a/src/settings/plugins/ibft/tests/Makefile.in b/src/settings/plugins/ibft/tests/Makefile.in index 30bd78df..7ac2bdc1 100644 --- a/src/settings/plugins/ibft/tests/Makefile.in +++ b/src/settings/plugins/ibft/tests/Makefile.in @@ -405,7 +405,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -417,8 +416,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -428,6 +425,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -482,16 +480,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -528,6 +523,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -556,7 +553,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -571,6 +567,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -631,6 +629,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -638,6 +637,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -656,8 +656,8 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ @@ -665,14 +665,13 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_IBFT_DIR=\"$(abs_srcdir)\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" @ENABLE_TESTS_TRUE@AM_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) @ENABLE_TESTS_TRUE@test_ibft_SOURCES = \ diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index 980a9cee..c7aef050 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -33,7 +33,7 @@ #include "NetworkManagerUtils.h" #include "reader.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-test-utils.h" diff --git a/src/settings/plugins/ifcfg-rh/Makefile.am b/src/settings/plugins/ifcfg-rh/Makefile.am index 08ffa0ec..ab96a328 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/Makefile.am @@ -2,15 +2,31 @@ SUBDIRS = . tests @GNOME_CODE_COVERAGE_RULES@ -nm-ifcfg-rh-glue.h: nm-ifcfg-rh.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ifcfg_rh --mode=glib-server --output=$@ $< +# See note about gdbus-codegen in introspection/Makefile.am -BUILT_SOURCES = \ - nm-ifcfg-rh-glue.h +noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la + +nodist_libnmdbus_ifcfg_rh_la_SOURCES = \ + nmdbus-ifcfg-rh.c \ + nmdbus-ifcfg-rh.h + +libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) + +nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml + $(AM_V_GEN) gdbus-codegen \ + --generate-c-code $(basename $@) \ + --c-namespace NMDBus \ + --interface-prefix com.redhat \ + $< + +nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h + @true + +BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la -noinst_LTLIBRARIES = libifcfg-rh-io.la +noinst_LTLIBRARIES += libifcfg-rh-io.la libifcfg_rh_io_la_SOURCES = \ shvar.c \ @@ -27,14 +43,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -47,7 +62,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf diff --git a/src/settings/plugins/ifcfg-rh/Makefile.in b/src/settings/plugins/ifcfg-rh/Makefile.in index eaa456bb..3fc3495a 100644 --- a/src/settings/plugins/ifcfg-rh/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/Makefile.in @@ -148,7 +148,8 @@ AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = libifcfg-rh-io.la +libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES = libifcfg-rh-io.la \ + libnmdbus-ifcfg-rh.la am_libnm_settings_plugin_ifcfg_rh_la_OBJECTS = plugin.lo \ nm-ifcfg-connection.lo libnm_settings_plugin_ifcfg_rh_la_OBJECTS = \ @@ -157,6 +158,11 @@ libnm_settings_plugin_ifcfg_rh_la_LINK = $(LIBTOOL) $(AM_V_lt) \ --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libnm_settings_plugin_ifcfg_rh_la_LDFLAGS) $(LDFLAGS) -o $@ +libnmdbus_ifcfg_rh_la_LIBADD = +nodist_libnmdbus_ifcfg_rh_la_OBJECTS = \ + libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo +libnmdbus_ifcfg_rh_la_OBJECTS = \ + $(nodist_libnmdbus_ifcfg_rh_la_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -192,7 +198,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libifcfg_rh_io_la_SOURCES) \ - $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) + $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) \ + $(nodist_libnmdbus_ifcfg_rh_la_SOURCES) DIST_SOURCES = $(libifcfg_rh_io_la_SOURCES) \ $(libnm_settings_plugin_ifcfg_rh_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ @@ -280,7 +287,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -292,8 +298,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -303,6 +307,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -357,16 +362,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -403,6 +405,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -431,7 +435,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -446,6 +449,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -506,6 +511,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -513,6 +519,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -529,11 +536,16 @@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ SUBDIRS = . tests -BUILT_SOURCES = \ - nm-ifcfg-rh-glue.h +# See note about gdbus-codegen in introspection/Makefile.am +noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la libifcfg-rh-io.la +nodist_libnmdbus_ifcfg_rh_la_SOURCES = \ + nmdbus-ifcfg-rh.c \ + nmdbus-ifcfg-rh.h + +libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS)) +BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la -noinst_LTLIBRARIES = libifcfg-rh-io.la libifcfg_rh_io_la_SOURCES = \ shvar.c \ shvar.h \ @@ -549,14 +561,13 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(NSS_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ @@ -569,7 +580,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \ nm-ifcfg-connection.h libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la +libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = nm-ifcfg-rh.conf EXTRA_DIST = \ @@ -664,12 +675,16 @@ libifcfg-rh-io.la: $(libifcfg_rh_io_la_OBJECTS) $(libifcfg_rh_io_la_DEPENDENCIES libnm-settings-plugin-ifcfg-rh.la: $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifcfg_rh_la_DEPENDENCIES) $(AM_V_CCLD)$(libnm_settings_plugin_ifcfg_rh_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifcfg_rh_la_OBJECTS) $(libnm_settings_plugin_ifcfg_rh_la_LIBADD) $(LIBS) +libnmdbus-ifcfg-rh.la: $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_DEPENDENCIES) $(EXTRA_libnmdbus_ifcfg_rh_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libnmdbus_ifcfg_rh_la_OBJECTS) $(libnmdbus_ifcfg_rh_la_LIBADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nm-ifcfg-connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Plo@am__quote@ @@ -698,6 +713,13 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< +libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo: nmdbus-ifcfg-rh.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo -MD -MP -MF $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Tpo $(DEPDIR)/libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='nmdbus-ifcfg-rh.c' object='libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnmdbus_ifcfg_rh_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnmdbus_ifcfg_rh_la-nmdbus-ifcfg-rh.lo `test -f 'nmdbus-ifcfg-rh.c' || echo '$(srcdir)/'`nmdbus-ifcfg-rh.c + mostlyclean-libtool: -rm -f *.lo @@ -1017,8 +1039,15 @@ uninstall-am: uninstall-dbusserviceDATA uninstall-pkglibLTLIBRARIES @GNOME_CODE_COVERAGE_RULES@ -nm-ifcfg-rh-glue.h: nm-ifcfg-rh.xml - $(AM_V_GEN) dbus-binding-tool --prefix=nm_ifcfg_rh --mode=glib-server --output=$@ $< +nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml + $(AM_V_GEN) gdbus-codegen \ + --generate-c-code $(basename $@) \ + --c-namespace NMDBus \ + --interface-prefix com.redhat \ + $< + +nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h + @true # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/settings/plugins/ifcfg-rh/common.h b/src/settings/plugins/ifcfg-rh/common.h index 0ec355ee..5d6ebe6d 100644 --- a/src/settings/plugins/ifcfg-rh/common.h +++ b/src/settings/plugins/ifcfg-rh/common.h @@ -21,7 +21,7 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include <glib.h> +#include "nm-default.h" #define IFCFG_TAG "ifcfg-" #define KEYS_TAG "keys-" diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index 9499d8ce..336d9d66 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -33,8 +33,9 @@ #include <nm-setting-pppoe.h> #include <nm-setting-wireless-security.h> #include <nm-setting-8021x.h> -#include <nm-platform.h> -#include <nm-logging.h> +#include "nm-platform.h" + +#include "nm-default.h" #include "common.h" #include "nm-config.h" @@ -107,7 +108,7 @@ devtimeout_ready (gpointer user_data) static void link_changed (NMPlatform *platform, NMPObjectType *obj_type, int ifindex, const NMPlatformLink *link, - NMPlatformSignalChangeType change_type, NMPlatformReason reason, + NMPlatformSignalChangeType change_type, NMConnection *self) { NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self); @@ -143,7 +144,7 @@ devtimeout_expired (gpointer user_data) nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout", nm_connection_get_id (NM_CONNECTION (self))); - g_signal_handler_disconnect (nm_platform_get (), priv->devtimeout_link_changed_handler); + g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler); priv->devtimeout_link_changed_handler = 0; priv->devtimeout_timeout_id = 0; @@ -187,7 +188,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self))); priv->devtimeout_link_changed_handler = - g_signal_connect (nm_platform_get (), NM_PLATFORM_SIGNAL_LINK_CHANGED, + g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (link_changed), self); priv->devtimeout_timeout_id = g_timeout_add_seconds (devtimeout, devtimeout_expired, self); } @@ -276,10 +277,7 @@ path_watch_stop (NMIfcfgConnection *self) ih = _get_inotify_helper (priv); - if (priv->ih_event_id) { - g_signal_handler_disconnect (ih, priv->ih_event_id); - priv->ih_event_id = 0; - } + nm_clear_g_signal_handler (ih, &priv->ih_event_id); if (priv->file_wd >= 0) { nm_inotify_helper_remove_watch (ih, priv->file_wd); @@ -380,6 +378,7 @@ replace_and_commit (NMSettingsConnection *connection, static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -407,7 +406,7 @@ commit_changes (NMSettingsConnection *connection, /* Don't bother writing anything out if in-memory and on-disk data are the same */ if (same) { /* But chain up to parent to handle success - emits updated signal */ - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data); + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); return; } } @@ -430,7 +429,7 @@ commit_changes (NMSettingsConnection *connection, if (success) { /* Chain up to parent to handle success */ - NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, callback, user_data); + NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); } else { /* Otherwise immediate error */ callback (connection, error, user_data); @@ -514,15 +513,8 @@ dispose (GObject *object) path_watch_stop (NM_IFCFG_CONNECTION (object)); - if (priv->devtimeout_link_changed_handler) { - g_signal_handler_disconnect (nm_platform_get (), - priv->devtimeout_link_changed_handler); - priv->devtimeout_link_changed_handler = 0; - } - if (priv->devtimeout_timeout_id) { - g_source_remove (priv->devtimeout_timeout_id); - priv->devtimeout_timeout_id = 0; - } + nm_clear_g_signal_handler (NM_PLATFORM_GET, &priv->devtimeout_link_changed_handler); + nm_clear_g_source (&priv->devtimeout_timeout_id); g_clear_object (&priv->inotify_helper); diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf index cade31dd..8fefaf18 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.conf @@ -7,7 +7,6 @@ <allow send_destination="com.redhat.ifcfgrh1"/> </policy> <policy at_console="true"> - <deny own="com.redhat.ifcfgrh1"/> <allow send_destination="com.redhat.ifcfgrh1"/> </policy> <policy context="default"> diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml index 52793452..1f308dd4 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-rh.xml @@ -10,7 +10,6 @@ <tp:docstring> Given an ifcfg file, return various internal information about it. </tp:docstring> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ifcfgrh_get_ifcfg_details"/> <arg name="ifcfg" type="s" direction="in"> <tp:docstring> The full path to an ifcfg file. diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index 526cdafe..5afc46d6 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -30,39 +30,28 @@ #include <sys/stat.h> #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <gio/gio.h> - -#include <dbus/dbus.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> - -#if HAVE_SELINUX -#include <selinux/selinux.h> -#endif #include "nm-setting-connection.h" +#include "nm-default.h" #include "common.h" -#include "nm-dbus-glib-types.h" #include "plugin.h" -#include "nm-system-config-interface.h" +#include "nm-settings-plugin.h" #include "nm-config.h" -#include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-ifcfg-connection.h" -#include "nm-inotify-helper.h" #include "shvar.h" #include "reader.h" #include "writer.h" #include "utils.h" -#include "gsystem-local-alloc.h" +#include "nm-dbus-compat.h" +#include "nm-exported-object.h" -#define DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" -#define DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" +#include "nmdbus-ifcfg-rh.h" +#define IFCFGRH1_DBUS_SERVICE_NAME "com.redhat.ifcfgrh1" +#define IFCFGRH1_DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1" #define _NMLOG_DOMAIN LOGD_SETTINGS #define _NMLOG(level, ...) \ @@ -76,15 +65,7 @@ #define ERR_GET_MSG(err) (((err) && (err)->message) ? (err)->message : "(unknown)") -static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, - const char *in_ifcfg, - const char **out_uuid, - const char **out_path, - GError **error); - -#include "nm-ifcfg-rh-glue.h" - -static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin, +static NMIfcfgConnection *update_connection (SettingsPluginIfcfg *plugin, NMConnection *source, const char *full_path, NMIfcfgConnection *connection, @@ -92,37 +73,40 @@ static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin, GHashTable *protected_connections, GError **error); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfcfg, settings_plugin_ifcfg, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgPrivate)) +#define SETTINGS_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgPrivate)) typedef struct { - GHashTable *connections; /* uuid::connection */ + NMConfig *config; + + struct { + GDBusConnection *connection; + GDBusInterfaceSkeleton *interface; + GCancellable *cancellable; + gulong signal_id; + } dbus; + GHashTable *connections; /* uuid::connection */ gboolean initialized; - gulong ih_event_id; - int sc_network_wd; - GFileMonitor *hostname_monitor; - guint hostname_monitor_id; - char *hostname; GFileMonitor *ifcfg_monitor; - guint ifcfg_monitor_id; - - DBusGConnection *bus; -} SCPluginIfcfgPrivate; + gulong ifcfg_monitor_id; +} SettingsPluginIfcfgPrivate; +static SettingsPluginIfcfg *settings_plugin_ifcfg_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETTINGS_TYPE_PLUGIN_IFCFG); static void connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) { - SCPluginIfcfg *self = SC_PLUGIN_IFCFG (user_data); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (user_data); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); const char *path; path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)); @@ -142,14 +126,14 @@ connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } static void -remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection) +remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); gboolean unmanaged, unrecognized; g_return_if_fail (self != NULL); @@ -168,15 +152,15 @@ remove_connection (SCPluginIfcfg *self, NMIfcfgConnection *connection) /* Emit changes _after_ removing the connection */ if (unmanaged) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); if (unrecognized) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); } static NMIfcfgConnection * -find_by_path (SCPluginIfcfg *self, const char *path) +find_by_path (SettingsPluginIfcfg *self, const char *path) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); GHashTableIter iter; NMSettingsConnection *candidate = NULL; @@ -191,7 +175,7 @@ find_by_path (SCPluginIfcfg *self, const char *path) } static NMIfcfgConnection * -update_connection (SCPluginIfcfg *self, +update_connection (SettingsPluginIfcfg *self, NMConnection *source, const char *full_path, NMIfcfgConnection *connection, @@ -199,7 +183,7 @@ update_connection (SCPluginIfcfg *self, GHashTable *protected_connections, GError **error) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); NMIfcfgConnection *connection_new; NMIfcfgConnection *connection_by_uuid; GError *local = NULL; @@ -346,18 +330,18 @@ update_connection (SCPluginIfcfg *self, if (old_unmanaged /* && !new_unmanaged */) { _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" and its device because NM_CONTROLLED was true.", NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); } else if (old_unrecognized /* && !new_unrecognized */) { _LOGI ("Managing connection "NM_IFCFG_CONNECTION_LOG_FMT" because it is now a recognized type.", NM_IFCFG_CONNECTION_LOG_ARG (connection_new)); - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_by_uuid); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_by_uuid); } } if (unmanaged_changed) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); if (unrecognized_changed) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); } nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (connection_by_uuid), full_path); g_object_unref (connection_new); @@ -401,11 +385,11 @@ update_connection (SCPluginIfcfg *self, /* Only raise the signal if we were called without source, i.e. if we read the connection from file. * Otherwise, we were called by add_connection() which does not expect the signal. */ if (nm_ifcfg_connection_get_unmanaged_spec (connection_new)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); else if (nm_ifcfg_connection_get_unrecognized_spec (connection_new)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNRECOGNIZED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNRECOGNIZED_SPECS_CHANGED); else - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); } return connection_new; } @@ -418,7 +402,7 @@ ifcfg_dir_changed (GFileMonitor *monitor, GFileMonitorEvent event_type, gpointer user_data) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (user_data); char *path, *ifcfg_path; NMIfcfgConnection *connection; @@ -447,9 +431,9 @@ ifcfg_dir_changed (GFileMonitor *monitor, } static void -setup_ifcfg_monitoring (SCPluginIfcfg *plugin) +setup_ifcfg_monitoring (SettingsPluginIfcfg *plugin) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GFile *file; GFileMonitor *monitor; @@ -502,9 +486,9 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) } static void -read_connections (SCPluginIfcfg *plugin) +read_connections (SettingsPluginIfcfg *plugin) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GDir *dir; GError *err = NULL; const char *item; @@ -574,10 +558,10 @@ read_connections (SCPluginIfcfg *plugin) } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); GSList *list = NULL; GHashTableIter iter; NMIfcfgConnection *connection; @@ -600,10 +584,10 @@ get_connections (NMSystemConfigInterface *config) } static gboolean -load_connection (NMSystemConfigInterface *config, +load_connection (NMSettingsPlugin *config, const char *filename) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); NMIfcfgConnection *connection; int dir_len = strlen (IFCFG_DIR); char *ifcfg_path; @@ -629,18 +613,18 @@ load_connection (NMSystemConfigInterface *config, } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *plugin = SETTINGS_PLUGIN_IFCFG (config); read_connections (plugin); } static GSList * -get_unhandled_specs (NMSystemConfigInterface *config, +get_unhandled_specs (NMSettingsPlugin *config, const char *property) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (config); GSList *list = NULL, *list_iter; GHashTableIter iter; gpointer connection; @@ -668,24 +652,24 @@ get_unhandled_specs (NMSystemConfigInterface *config, } static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) +get_unmanaged_specs (NMSettingsPlugin *config) { return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNMANAGED_SPEC); } static GSList * -get_unrecognized_specs (NMSystemConfigInterface *config) +get_unrecognized_specs (NMSettingsPlugin *config) { return get_unhandled_specs (config, NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC); } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *connection, gboolean save_to_disk, GError **error) { - SCPluginIfcfg *self = SC_PLUGIN_IFCFG (config); + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (config); gs_free char *path = NULL; /* Ensure we reject attempts to add the connection long before we're @@ -701,312 +685,316 @@ add_connection (NMSystemConfigInterface *config, return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); } -#define SC_NETWORK_FILE "/etc/sysconfig/network" -#define HOSTNAME_FILE "/etc/hostname" - -static char * -plugin_get_hostname (SCPluginIfcfg *plugin) +static void +impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin, + GDBusMethodInvocation *context, + const char *in_ifcfg) { - shvarFile *network; - char *hostname; - gboolean ignore_localhost; + NMIfcfgConnection *connection; + NMSettingConnection *s_con; + const char *uuid; + const char *path; + gs_free char *ifcfg_path = NULL; - if (g_file_get_contents (HOSTNAME_FILE, &hostname, NULL, NULL)) { - g_strchomp (hostname); - return hostname; + if (!g_path_is_absolute (in_ifcfg)) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ifcfg path '%s' is not absolute", in_ifcfg); + return; } - network = svOpenFile (SC_NETWORK_FILE, NULL); - if (!network) { - _LOGW ("Could not get hostname: failed to read " SC_NETWORK_FILE); - return NULL; + ifcfg_path = utils_detect_ifcfg_path (in_ifcfg, TRUE); + if (!ifcfg_path) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ifcfg path '%s' is not an ifcfg base file", in_ifcfg); + return; } - hostname = svGetValue (network, "HOSTNAME", FALSE); - ignore_localhost = svTrueValue (network, "NM_IGNORE_HOSTNAME_LOCALHOST", FALSE); - if (ignore_localhost) { - /* Ignore a default hostname ('localhost[6]' or 'localhost[6].localdomain[6]') - * to preserve 'network' service behavior. - */ - if (hostname && !nm_utils_is_specific_hostname (hostname)) { - g_free (hostname); - hostname = NULL; - } + connection = find_by_path (plugin, ifcfg_path); + if ( !connection + || nm_ifcfg_connection_get_unmanaged_spec (connection) + || nm_ifcfg_connection_get_unrecognized_spec (connection)) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "ifcfg file '%s' unknown", in_ifcfg); + return; } - svCloseFile (network); - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - shvarFile *network; - char *hostname_eol; - gboolean ret; -#if HAVE_SELINUX - security_context_t se_ctx_prev = NULL, se_ctx = NULL; - struct stat file_stat = { .st_mode = 0 }; - mode_t st_mode = 0; - - /* Get default context for HOSTNAME_FILE and set it for fscreate */ - if (stat (HOSTNAME_FILE, &file_stat) == 0) - st_mode = file_stat.st_mode; - matchpathcon (HOSTNAME_FILE, st_mode, &se_ctx); - matchpathcon_fini (); - getfscreatecon (&se_ctx_prev); - setfscreatecon (se_ctx); -#endif - - hostname_eol = g_strdup_printf ("%s\n", hostname); - ret = g_file_set_contents (HOSTNAME_FILE, hostname_eol, -1, NULL); - -#if HAVE_SELINUX - /* Restore previous context and cleanup */ - setfscreatecon (se_ctx_prev); - freecon (se_ctx); - freecon (se_ctx_prev); -#endif - - if (!ret) { - _LOGW ("Could not save hostname: failed to create/open " HOSTNAME_FILE); - g_free (hostname_eol); - return FALSE; + s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); + if (!s_con) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_FAILED, + "unable to retrieve the connection setting"); + return; } - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - g_free (hostname_eol); + uuid = nm_setting_connection_get_uuid (s_con); + if (!uuid) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_FAILED, + "unable to get the UUID"); + return; + } - /* Remove "HOSTNAME" from SC_NETWORK_FILE, if present */ - network = svOpenFile (SC_NETWORK_FILE, NULL); - if (network) { - svSetValue (network, "HOSTNAME", NULL, FALSE); - svWriteFile (network, 0644, NULL); - svCloseFile (network); + path = nm_connection_get_path (NM_CONNECTION (connection)); + if (!path) { + g_dbus_method_invocation_return_error (context, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_FAILED, + "unable to get the connection D-Bus path"); + return; } - return TRUE; + g_dbus_method_invocation_return_value (context, + g_variant_new ("(so)", uuid, path)); } -static void -hostname_maybe_changed (SCPluginIfcfg *plugin) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - char *new_hostname; - - new_hostname = plugin_get_hostname (plugin); - if ( (new_hostname && !priv->hostname) - || (!new_hostname && priv->hostname) - || (priv->hostname && new_hostname && strcmp (priv->hostname, new_hostname))) { - g_free (priv->hostname); - priv->hostname = new_hostname; - g_object_notify (G_OBJECT (plugin), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } else - g_free (new_hostname); -} +/*****************************************************************************/ static void -sc_network_changed_cb (NMInotifyHelper *ih, - struct inotify_event *evt, - const char *path, - gpointer user_data) +_dbus_clear (SettingsPluginIfcfg *self) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - if (evt->wd != priv->sc_network_wd) - return; + nm_clear_g_signal_handler (priv->dbus.connection, &priv->dbus.signal_id); + + nm_clear_g_cancellable (&priv->dbus.cancellable); + + if (priv->dbus.interface) { + g_dbus_interface_skeleton_unexport (priv->dbus.interface); + nm_exported_object_skeleton_release (priv->dbus.interface); + priv->dbus.interface = NULL; + } - hostname_maybe_changed (plugin); + g_clear_object (&priv->dbus.connection); } static void -hostname_changed_cb (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) +_dbus_connection_closed (GDBusConnection *connection, + gboolean remote_peer_vanished, + GError *error, + gpointer user_data) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); + _LOGW ("dbus: %s bus closed", IFCFGRH1_DBUS_SERVICE_NAME); + _dbus_clear (SETTINGS_PLUGIN_IFCFG (user_data)); - hostname_maybe_changed (plugin); + /* Retry or recover? */ } -static gboolean -impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin, - const char *in_ifcfg, - const char **out_uuid, - const char **out_path, - GError **error) +static void +_dbus_request_name_done (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { - NMIfcfgConnection *connection; - NMSettingConnection *s_con; - const char *uuid; - const char *path; + GDBusConnection *connection = G_DBUS_CONNECTION (source_object); + SettingsPluginIfcfg *self; + SettingsPluginIfcfgPrivate *priv; + gs_free_error GError *error = NULL; + gs_unref_variant GVariant *ret = NULL; + guint32 result; + + ret = g_dbus_connection_call_finish (connection, res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; - if (!g_path_is_absolute (in_ifcfg)) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg path '%s' is not absolute", in_ifcfg); - return FALSE; - } + self = SETTINGS_PLUGIN_IFCFG (user_data); + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - connection = find_by_path (plugin, in_ifcfg); - if ( !connection - || nm_ifcfg_connection_get_unmanaged_spec (connection) - || nm_ifcfg_connection_get_unrecognized_spec (connection)) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "ifcfg file '%s' unknown", in_ifcfg); - return FALSE; - } + g_clear_object (&priv->dbus.cancellable); - s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection)); - if (!s_con) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to retrieve the connection setting"); - return FALSE; + if (!ret) { + _LOGW ("dbus: couldn't acquire D-Bus service: %s", error->message); + _dbus_clear (self); + return; } - uuid = nm_setting_connection_get_uuid (s_con); - if (!uuid) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to get the UUID"); - return FALSE; - } - - path = nm_connection_get_path (NM_CONNECTION (connection)); - if (!path) { - g_set_error (error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_FAILED, - "unable to get the connection D-Bus path"); - return FALSE; + g_variant_get (ret, "(u)", &result); + + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + _LOGW ("dbus: couldn't acquire ifcfgrh1 D-Bus service (already taken)"); + _dbus_clear (self); + return; } - *out_uuid = g_strdup (uuid); - *out_path = g_strdup (path); + { + GType skeleton_type = NMDBUS_TYPE_IFCFGRH1_SKELETON; + gs_free char *method_name_get_ifcfg_details = NULL; + NMExportedObjectDBusMethodImpl methods[] = { + { + .method_name = (method_name_get_ifcfg_details = nm_exported_object_skeletonify_method_name ("GetIfcfgDetails")), + .impl = G_CALLBACK (impl_ifcfgrh_get_ifcfg_details), + }, + }; + + priv->dbus.interface = nm_exported_object_skeleton_create (skeleton_type, + g_type_class_peek (SETTINGS_TYPE_PLUGIN_IFCFG), + methods, + G_N_ELEMENTS (methods), + (GObject *) self); + + if (!g_dbus_interface_skeleton_export (priv->dbus.interface, + priv->dbus.connection, + IFCFGRH1_DBUS_OBJECT_PATH, + &error)) { + nm_exported_object_skeleton_release (priv->dbus.interface); + priv->dbus.interface = NULL; + _LOGW ("dbus: failed exporting interface: %s", error->message); + _dbus_clear (self); + return; + } + } - return TRUE; + _LOGD ("dbus: aquired D-Bus service %s and exported %s object", + IFCFGRH1_DBUS_SERVICE_NAME, + IFCFGRH1_DBUS_OBJECT_PATH); } static void -init (NMSystemConfigInterface *config) +_dbus_create_done (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { + SettingsPluginIfcfg *self; + SettingsPluginIfcfgPrivate *priv; + gs_free_error GError *error = NULL; + GDBusConnection *connection; + + connection = g_dbus_connection_new_for_address_finish (res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = SETTINGS_PLUGIN_IFCFG (user_data); + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + + g_clear_object (&priv->dbus.cancellable); + + if (!connection) { + _LOGW ("dbus: couldn't initialize system bus: %s", error->message); + return; + } + + priv->dbus.connection = connection; + priv->dbus.cancellable = g_cancellable_new (); + + priv->dbus.signal_id = g_signal_connect (priv->dbus.connection, + "closed", + G_CALLBACK (_dbus_connection_closed), + self); + + g_dbus_connection_call (priv->dbus.connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "RequestName", + g_variant_new ("(su)", + IFCFGRH1_DBUS_SERVICE_NAME, + DBUS_NAME_FLAG_DO_NOT_QUEUE), + G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->dbus.cancellable, + _dbus_request_name_done, + self); } static void -sc_plugin_ifcfg_init (SCPluginIfcfg *plugin) +_dbus_setup (SettingsPluginIfcfg *self) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - NMInotifyHelper *ih; - GError *error = NULL; - gboolean success = FALSE; - GFile *file; - GFileMonitor *monitor; - - priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + gs_free char *address = NULL; + gs_free_error GError *error = NULL; - /* We watch SC_NETWORK_FILE via NMInotifyHelper (which doesn't track file creation but - * *does* track modifications made via other hard links), since we expect it to always - * exist. But we watch HOSTNAME_FILE via GFileMonitor (which has the opposite - * semantics), since /etc/hostname might not exist, but is unlikely to have hard - * links. bgo 532815 is the bug for being able to just use GFileMonitor for both. - */ - - ih = nm_inotify_helper_get (); - priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (sc_network_changed_cb), plugin); - priv->sc_network_wd = nm_inotify_helper_add_watch (ih, SC_NETWORK_FILE); + g_return_if_fail (!priv->dbus.connection); - file = g_file_new_for_path (HOSTNAME_FILE); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - if (monitor) { - priv->hostname_monitor_id = - g_signal_connect (monitor, "changed", G_CALLBACK (hostname_changed_cb), plugin); - priv->hostname_monitor = monitor; + address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, &error); + if (address == NULL) { + _LOGW ("dbus: failed getting address for system bus: %s", error->message); + return; } - priv->hostname = plugin_get_hostname (plugin); + priv->dbus.cancellable = g_cancellable_new (); - priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); - if (!priv->bus) { - _LOGW ("Couldn't connect to D-Bus: %s", error->message); - g_clear_error (&error); - } else { - DBusConnection *tmp; - DBusGProxy *proxy; - int result; - - tmp = dbus_g_connection_get_connection (priv->bus); - dbus_connection_set_exit_on_disconnect (tmp, FALSE); - - proxy = dbus_g_proxy_new_for_name (priv->bus, - "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus"); - - if (!dbus_g_proxy_call (proxy, "RequestName", &error, - G_TYPE_STRING, DBUS_SERVICE_NAME, - G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE, - G_TYPE_INVALID, - G_TYPE_UINT, &result, - G_TYPE_INVALID)) { - _LOGW ("Couldn't acquire D-Bus service: %s", error->message); - g_clear_error (&error); - } else if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - _LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)"); - } else - success = TRUE; - } + g_dbus_connection_new_for_address (address, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT + | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, + NULL, + priv->dbus.cancellable, + _dbus_create_done, + self); +} - if (!success) { - if (priv->bus) { - dbus_g_connection_unref (priv->bus); - priv->bus = NULL; - } +static void +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + SettingsPluginIfcfg *self) +{ + /* If the dbus connection for some reason is borked the D-Bus service + * won't be offered. + * + * On SIGHUP and SIGUSR1 try to re-connect to D-Bus. So in the unlikely + * event that the D-Bus conneciton is broken, that allows for recovery + * without need for restarting NetworkManager. */ + if ( NM_FLAGS_HAS (changes, NM_CONFIG_CHANGE_SIGHUP) + || NM_FLAGS_HAS (changes, NM_CONFIG_CHANGE_SIGUSR1)) { + if (!SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self)->dbus.connection) + _dbus_setup (self); } } +/*****************************************************************************/ + static void -dispose (GObject *object) +init (NMSettingsPlugin *config) { - SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object); - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - NMInotifyHelper *ih; +} - if (priv->bus) { - dbus_g_connection_unref (priv->bus); - priv->bus = NULL; - } +static void +settings_plugin_ifcfg_init (SettingsPluginIfcfg *plugin) +{ + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (plugin); + + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); +} - if (priv->ih_event_id) { - ih = nm_inotify_helper_get (); +static void +constructed (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - g_signal_handler_disconnect (ih, priv->ih_event_id); - priv->ih_event_id = 0; + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->constructed (object); - if (priv->sc_network_wd >= 0) - nm_inotify_helper_remove_watch (ih, priv->sc_network_wd); - } + priv->config = nm_config_get (); + g_object_add_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); + g_signal_connect (priv->config, + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + self); - if (priv->hostname_monitor) { - if (priv->hostname_monitor_id) - g_signal_handler_disconnect (priv->hostname_monitor, priv->hostname_monitor_id); + _dbus_setup (self); +} + +static void +dispose (GObject *object) +{ + SettingsPluginIfcfg *self = SETTINGS_PLUGIN_IFCFG (object); + SettingsPluginIfcfgPrivate *priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); - g_file_monitor_cancel (priv->hostname_monitor); - g_object_unref (priv->hostname_monitor); + if (priv->config) { + g_object_remove_weak_pointer ((GObject *) priv->config, (gpointer *) &priv->config); + g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, self); + priv->config = NULL; } - g_free (priv->hostname); + _dbus_clear (self); if (priv->connections) { g_hash_table_destroy (priv->connections); @@ -1021,27 +1009,22 @@ dispose (GObject *object) g_object_unref (priv->ifcfg_monitor); } - G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifcfg_parent_class)->dispose (object); } static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFCFG_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFCFG_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, priv->hostname); + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1053,15 +1036,7 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - const char *hostname; - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_IFCFG (object), hostname); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1069,65 +1044,45 @@ set_property (GObject *object, guint prop_id, } static void -sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class) +settings_plugin_ifcfg_class_init (SettingsPluginIfcfgClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIfcfgPrivate)); + object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - - dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (req_class), - &dbus_glib_nm_ifcfg_rh_object_info); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->add_connection = add_connection; - system_config_interface_class->load_connection = load_connection; - system_config_interface_class->reload_connections = reload_connections; - system_config_interface_class->get_unmanaged_specs = get_unmanaged_specs; - system_config_interface_class->get_unrecognized_specs = get_unrecognized_specs; - system_config_interface_class->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->add_connection = add_connection; + plugin_iface->load_connection = load_connection; + plugin_iface->reload_connections = reload_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->get_unrecognized_specs = get_unrecognized_specs; + plugin_iface->init = init; } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfcfg *singleton = NULL; - SCPluginIfcfgPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton); - if (priv->bus) - dbus_g_connection_register_g_object (priv->bus, - DBUS_OBJECT_PATH, - G_OBJECT (singleton)); - _LOGD ("Acquired D-Bus service %s", DBUS_SERVICE_NAME); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifcfg_get ()); } diff --git a/src/settings/plugins/ifcfg-rh/plugin.h b/src/settings/plugins/ifcfg-rh/plugin.h index d37decfd..eba734cf 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.h +++ b/src/settings/plugins/ifcfg-rh/plugin.h @@ -24,27 +24,27 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-exported-object.h" -#define SC_TYPE_PLUGIN_IFCFG (sc_plugin_ifcfg_get_type ()) -#define SC_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfg)) -#define SC_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) -#define SC_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFCFG)) -#define SC_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFCFG)) -#define SC_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) +#define SETTINGS_TYPE_PLUGIN_IFCFG (settings_plugin_ifcfg_get_type ()) +#define SETTINGS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfg)) +#define SETTINGS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) +#define SETTINGS_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFCFG)) +#define SETTINGS_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFCFG)) +#define SETTINGS_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFCFG, SettingsPluginIfcfgClass)) -typedef struct _SCPluginIfcfg SCPluginIfcfg; -typedef struct _SCPluginIfcfgClass SCPluginIfcfgClass; +typedef struct _SettingsPluginIfcfg SettingsPluginIfcfg; +typedef struct _SettingsPluginIfcfgClass SettingsPluginIfcfgClass; -struct _SCPluginIfcfg { +struct _SettingsPluginIfcfg { GObject parent; }; -struct _SCPluginIfcfgClass { +struct _SettingsPluginIfcfgClass { GObjectClass parent; }; -GType sc_plugin_ifcfg_get_type (void); +GType settings_plugin_ifcfg_get_type (void); #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 271b7bb1..bcb726aa 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright 2008 - 2014 Red Hat, Inc. + * Copyright 2008 - 2015 Red Hat, Inc. */ #include "config.h" @@ -31,8 +31,6 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <glib.h> -#include <glib/gi18n.h> #include <nm-connection.h> #include <nm-dbus-interface.h> #include <nm-setting-connection.h> @@ -49,13 +47,12 @@ #include <nm-setting-bridge-port.h> #include <nm-setting-dcb.h> #include <nm-setting-generic.h> +#include "nm-default.h" #include "nm-core-internal.h" #include <nm-utils.h> #include "nm-platform.h" #include "NetworkManagerUtils.h" -#include "nm-logging.h" -#include "gsystem-local-alloc.h" #include "common.h" #include "shvar.h" @@ -131,6 +128,7 @@ make_connection_setting (const char *file, const char *prefix) { NMSettingConnection *s_con; + NMSettingConnectionLldp lldp; const char *ifcfg_name = NULL; char *new_id, *uuid = NULL, *zone = NULL, *value; @@ -168,17 +166,25 @@ make_connection_setting (const char *file, g_free (value); } + value = svGetValue (ifcfg, "LLDP", FALSE); + if (!g_strcmp0 (value, "rx")) + lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX; + else + lldp = svParseBoolean (value, NM_SETTING_CONNECTION_LLDP_DEFAULT); + g_free (value); + /* Missing ONBOOT is treated as "ONBOOT=true" by the old network service */ g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, - svTrueValue (ifcfg, "ONBOOT", TRUE), + svGetValueBoolean (ifcfg, "ONBOOT", TRUE), NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, (gint) svGetValueInt64 (ifcfg, "AUTOCONNECT_PRIORITY", 10, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, - svTrueValue (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), + svGetValueBoolean (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), + NM_SETTING_CONNECTION_LLDP, lldp, NULL); value = svGetValue (ifcfg, "USERS", FALSE); @@ -250,7 +256,7 @@ make_connection_setting (const char *file, g_free (value); } - switch (svTrueValue (ifcfg, "CONNECTION_METERED", -1)) { + switch (svGetValueBoolean (ifcfg, "CONNECTION_METERED", -1)) { case TRUE: g_object_set (s_con, NM_SETTING_CONNECTION_METERED, NM_METERED_YES, NULL); break; @@ -274,8 +280,7 @@ read_ip4_address (shvarFile *ifcfg, g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (tag != NULL, FALSE); g_return_val_if_fail (out_addr != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); *out_addr = NULL; @@ -363,8 +368,7 @@ read_full_ip4_address (shvarFile *ifcfg, g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (out_address != NULL, FALSE); g_return_val_if_fail (*out_address == NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); ip_tag = get_numbered_tag ("IPADDR", which); prefix_tag = get_numbered_tag ("PREFIX", which); @@ -462,8 +466,7 @@ read_one_ip4_route (shvarFile *ifcfg, g_return_val_if_fail (ifcfg != NULL, FALSE); g_return_val_if_fail (out_route != NULL, FALSE); g_return_val_if_fail (*out_route == NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); ip_tag = g_strdup_printf ("ADDRESS%u", which); netmask_tag = g_strdup_printf ("NETMASK%u", which); @@ -559,8 +562,7 @@ read_route_file_legacy (const char *filename, NMSettingIPConfig *s_ip4, GError * g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (s_ip4 != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Read the route file */ if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { @@ -678,6 +680,32 @@ error: return success; } +static void +parse_dns_options (NMSettingIPConfig *ip_config, char *value) +{ + char **options = NULL; + + g_return_if_fail (ip_config); + + if (!value) + return; + + if (!nm_setting_ip_config_has_dns_options (ip_config)) + nm_setting_ip_config_clear_dns_options (ip_config, TRUE); + + options = g_strsplit (value, " ", 0); + if (options) { + char **item; + for (item = options; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_option (ip_config, *item)) + PARSE_WARNING ("can't add DNS option '%s'", *item); + } + } + g_strfreev (options); + } +} + static gboolean parse_full_ip6_address (shvarFile *ifcfg, const char *addr_str, @@ -693,8 +721,7 @@ parse_full_ip6_address (shvarFile *ifcfg, g_return_val_if_fail (addr_str != NULL, FALSE); g_return_val_if_fail (out_address != NULL, FALSE); g_return_val_if_fail (*out_address == NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Split the address and prefix */ list = g_strsplit_set (addr_str, "/", 2); @@ -758,8 +785,7 @@ read_route6_file (const char *filename, NMSettingIPConfig *s_ip6, GError **error g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (s_ip6 != NULL, FALSE); - if (error) - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (!error || !*error, FALSE); /* Read the route file */ if (!g_file_get_contents (filename, &contents, &len, NULL) || !len) { @@ -892,6 +918,7 @@ make_ip4_setting (shvarFile *ifcfg, char *value = NULL; char *route_path = NULL; char *method; + char *dns_options = NULL; gs_free char *gateway = NULL; gint32 i; shvarFile *network_ifcfg; @@ -905,7 +932,7 @@ make_ip4_setting (shvarFile *ifcfg, * specified is DEFROUTE=yes which means that this connection can be used * as a default route */ - never_default = !svTrueValue (ifcfg, "DEFROUTE", TRUE); + never_default = !svGetValueBoolean (ifcfg, "DEFROUTE", TRUE); /* Then check if GATEWAYDEV; it's global and overrides DEFROUTE */ network_ifcfg = svOpenFile (network_file, NULL); @@ -915,6 +942,7 @@ make_ip4_setting (shvarFile *ifcfg, /* Get the connection ifcfg device name and the global gateway device */ value = svGetValue (ifcfg, "DEVICE", FALSE); gatewaydev = svGetValue (network_ifcfg, "GATEWAYDEV", FALSE); + dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); /* If there was a global gateway device specified, then only connections * for that device can be the default connection. @@ -979,10 +1007,10 @@ make_ip4_setting (shvarFile *ifcfg, g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "PEERROUTES", TRUE), NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV4_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV4_FAILURE_FATAL", FALSE), NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV4_ROUTE_METRIC", 10, -1, G_MAXUINT32, -1), NULL); @@ -993,13 +1021,22 @@ make_ip4_setting (shvarFile *ifcfg, /* Handle DHCP settings */ if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) { value = svGetValue (ifcfg, "DHCP_HOSTNAME", FALSE); - if (value && strlen (value)) + if (value && *value) g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, value, NULL); g_free (value); + value = svGetValue (ifcfg, "DHCP_FQDN", FALSE); + if (value && *value) { + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NULL, + NM_SETTING_IP4_CONFIG_DHCP_FQDN, value, + NULL); + } + g_free (value); + g_object_set (s_ip4, - NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, - svTrueValue (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE), + NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXUINT32, 0), NULL); value = svGetValue (ifcfg, "DHCP_CLIENT_ID", FALSE); @@ -1101,6 +1138,14 @@ make_ip4_setting (shvarFile *ifcfg, g_free (value); } + /* DNS options */ + value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); + parse_dns_options (s_ip4, value); + parse_dns_options (s_ip4, dns_options); + g_free (value); + g_free (dns_options); + dns_options = NULL; + /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); @@ -1157,6 +1202,7 @@ make_ip4_setting (shvarFile *ifcfg, return NM_SETTING (s_ip4); done: + g_free (dns_options); g_free (route_path); g_object_unref (s_ip4); return NULL; @@ -1271,6 +1317,7 @@ make_ip6_setting (shvarFile *ifcfg, char *value = NULL; char *str_value; char *route6_path = NULL; + char *dns_options = NULL; gboolean ipv6init, ipv6forwarding, ipv6_autoconf, dhcp6 = FALSE; char *method = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; char *ipv6addr, *ipv6addr_secondaries; @@ -1279,8 +1326,9 @@ make_ip6_setting (shvarFile *ifcfg, shvarFile *network_ifcfg; gboolean never_default = FALSE; gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; - char *ip6_privacy_str; NMSettingIP6ConfigPrivacy ip6_privacy_val; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; + char *tmp; s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); @@ -1289,7 +1337,7 @@ make_ip6_setting (shvarFile *ifcfg, * specified is IPV6_DEFROUTE=yes which means that this connection can be used * as a default route */ - never_default = !svTrueValue (ifcfg, "IPV6_DEFROUTE", TRUE); + never_default = !svGetValueBoolean (ifcfg, "IPV6_DEFROUTE", TRUE); /* Then check if IPV6_DEFAULTGW or IPV6_DEFAULTDEV is specified; * they are global and override IPV6_DEFROUTE @@ -1304,6 +1352,7 @@ make_ip6_setting (shvarFile *ifcfg, value = svGetValue (ifcfg, "DEVICE", FALSE); ipv6_defaultgw = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE); ipv6_defaultdev = svGetValue (network_ifcfg, "IPV6_DEFAULTDEV", FALSE); + dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE); if (ipv6_defaultgw) { default_dev = strchr (ipv6_defaultgw, '%'); @@ -1328,11 +1377,11 @@ make_ip6_setting (shvarFile *ifcfg, /* Find out method property */ /* Is IPV6 enabled? Set method to "ignored", when not enabled */ str_value = svGetValue (ifcfg, "IPV6INIT", FALSE); - ipv6init = svTrueValue (ifcfg, "IPV6INIT", FALSE); + ipv6init = svGetValueBoolean (ifcfg, "IPV6INIT", FALSE); if (!str_value) { network_ifcfg = svOpenFile (network_file, NULL); if (network_ifcfg) { - ipv6init = svTrueValue (network_ifcfg, "IPV6INIT", FALSE); + ipv6init = svGetValueBoolean (network_ifcfg, "IPV6INIT", FALSE); svCloseFile (network_ifcfg); } } @@ -1341,9 +1390,9 @@ make_ip6_setting (shvarFile *ifcfg, if (!ipv6init) method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; /* IPv6 is disabled */ else { - ipv6forwarding = svTrueValue (ifcfg, "IPV6FORWARDING", FALSE); - ipv6_autoconf = svTrueValue (ifcfg, "IPV6_AUTOCONF", !ipv6forwarding); - dhcp6 = svTrueValue (ifcfg, "DHCPV6C", FALSE); + ipv6forwarding = svGetValueBoolean (ifcfg, "IPV6FORWARDING", FALSE); + ipv6_autoconf = svGetValueBoolean (ifcfg, "IPV6_AUTOCONF", !ipv6forwarding); + dhcp6 = svGetValueBoolean (ifcfg, "DHCPV6C", FALSE); if (ipv6_autoconf) method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; @@ -1363,27 +1412,27 @@ make_ip6_setting (shvarFile *ifcfg, /* TODO - handle other methods */ /* Read IPv6 Privacy Extensions configuration */ - ip6_privacy_str = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); - if (ip6_privacy_str) { - ip6_privacy = svTrueValue (ifcfg, "IPV6_PRIVACY", FALSE); + tmp = svGetValue (ifcfg, "IPV6_PRIVACY", FALSE); + if (tmp) { + ip6_privacy = svGetValueBoolean (ifcfg, "IPV6_PRIVACY", FALSE); if (!ip6_privacy) - ip6_privacy = g_strcmp0 (ip6_privacy_str, "rfc4941") == 0 || - g_strcmp0 (ip6_privacy_str, "rfc3041") == 0; + ip6_privacy = g_strcmp0 (tmp, "rfc4941") == 0 || + g_strcmp0 (tmp, "rfc3041") == 0; } - ip6_privacy_prefer_public_ip = svTrueValue (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); - ip6_privacy_val = ip6_privacy_str ? + ip6_privacy_prefer_public_ip = svGetValueBoolean (ifcfg, "IPV6_PRIVACY_PREFER_PUBLIC_IP", FALSE); + ip6_privacy_val = tmp ? (ip6_privacy ? (ip6_privacy_prefer_public_ip ? NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR : NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) : NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED) : NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - g_free (ip6_privacy_str); + g_free (tmp); g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, method, - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svTrueValue (ifcfg, "IPV6_PEERDNS", TRUE), - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svTrueValue (ifcfg, "IPV6_PEERROUTES", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, !svGetValueBoolean (ifcfg, "IPV6_PEERDNS", TRUE), + NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, !svGetValueBoolean (ifcfg, "IPV6_PEERROUTES", TRUE), NM_SETTING_IP_CONFIG_NEVER_DEFAULT, never_default, - NM_SETTING_IP_CONFIG_MAY_FAIL, !svTrueValue (ifcfg, "IPV6_FAILURE_FATAL", FALSE), + NM_SETTING_IP_CONFIG_MAY_FAIL, !svGetValueBoolean (ifcfg, "IPV6_FAILURE_FATAL", FALSE), NM_SETTING_IP_CONFIG_ROUTE_METRIC, svGetValueInt64 (ifcfg, "IPV6_ROUTE_METRIC", 10, -1, G_MAXUINT32, -1), NM_SETTING_IP6_CONFIG_IP6_PRIVACY, ip6_privacy_val, @@ -1460,6 +1509,22 @@ make_ip6_setting (shvarFile *ifcfg, } } + /* IPv6 addressing mode configuration */ + tmp = svGetValue (ifcfg, "IPV6_ADDR_GEN_MODE", FALSE); + if (tmp) { + if (nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), tmp, + (int *) &addr_gen_mode, NULL)) + g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, addr_gen_mode, NULL); + else + PARSE_WARNING ("Invalid IPV6_ADDR_GEN_MODE"); + g_free (tmp); + } else { + g_object_set (s_ip6, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + NULL); + } + /* DNS servers * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) */ @@ -1500,9 +1565,17 @@ make_ip6_setting (shvarFile *ifcfg, g_free (route6_path); } + /* DNS options */ + value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE); + parse_dns_options (s_ip6, value); + parse_dns_options (s_ip6, dns_options); + g_free (value); + g_free (dns_options); + return NM_SETTING (s_ip6); error: + g_free (dns_options); g_free (route6_path); g_object_unref (s_ip6); return NULL; @@ -1579,11 +1652,11 @@ read_dcb_flags (shvarFile *ifcfg, DcbFlagsProperty *property) { NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; - if (svTrueValue (ifcfg, property->enable_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->enable_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_ENABLE; - if (svTrueValue (ifcfg, property->advertise_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->advertise_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_ADVERTISE; - if (svTrueValue (ifcfg, property->willing_key, FALSE)) + if (svGetValueBoolean (ifcfg, property->willing_key, FALSE)) flags |= NM_SETTING_DCB_FLAG_WILLING; return flags; @@ -1813,7 +1886,7 @@ make_dcb_setting (shvarFile *ifcfg, g_return_val_if_fail (out_setting != NULL, FALSE); - dcb_on = !!svTrueValue (ifcfg, "DCB", FALSE); + dcb_on = !!svGetValueBoolean (ifcfg, "DCB", FALSE); if (!dcb_on) return TRUE; @@ -2611,7 +2684,7 @@ eap_peap_reader (const char *eap_method, } } - if (svTrueValue (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", FALSE)) + if (svGetValueBoolean (ifcfg, "IEEE_8021X_PEAP_FORCE_NEW_LABEL", FALSE)) g_object_set (s_8021x, NM_SETTING_802_1X_PHASE1_PEAPLABEL, "1", NULL); anon_ident = svGetValue (ifcfg, "IEEE_8021X_ANON_IDENTITY", FALSE); @@ -3052,9 +3125,9 @@ make_wpa_setting (shvarFile *ifcfg, allow_wpa = svGetValue (ifcfg, "WPA_ALLOW_WPA", FALSE); allow_rsn = svGetValue (ifcfg, "WPA_ALLOW_WPA2", FALSE); - if (allow_wpa && svTrueValue (ifcfg, "WPA_ALLOW_WPA", TRUE)) + if (allow_wpa && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA", TRUE)) nm_setting_wireless_security_add_proto (wsec, "wpa"); - if (allow_rsn && svTrueValue (ifcfg, "WPA_ALLOW_WPA2", TRUE)) + if (allow_rsn && svGetValueBoolean (ifcfg, "WPA_ALLOW_WPA2", TRUE)) nm_setting_wireless_security_add_proto (wsec, "rsn"); /* If neither WPA_ALLOW_WPA or WPA_ALLOW_WPA2 were present, default @@ -3250,6 +3323,7 @@ make_wireless_setting (shvarFile *ifcfg, NMSettingWireless *s_wireless; char *value = NULL; gint64 chan = 0; + NMSettingMacRandomization mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); @@ -3424,7 +3498,34 @@ make_wireless_setting (shvarFile *ifcfg, g_object_set (s_wireless, NM_SETTING_WIRELESS_HIDDEN, - svTrueValue (ifcfg, "SSID_HIDDEN", FALSE), + svGetValueBoolean (ifcfg, "SSID_HIDDEN", FALSE), + NULL); + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_POWERSAVE, + svGetValueBoolean (ifcfg, "POWERSAVE", FALSE) ? 1 : 0, + NULL); + + value = svGetValueFull (ifcfg, "MAC_ADDRESS_RANDOMIZATION", FALSE); + if (value) { + if (strcmp (value, "default") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_DEFAULT; + else if (strcmp (value, "never") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; + else if (strcmp (value, "always") == 0) + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_ALWAYS; + else { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid MAC_ADDRESS_RANDOMIZATION value '%s'", value); + goto error; + } + g_free (value); + } else + mac_randomization = NM_SETTING_MAC_RANDOMIZATION_NEVER; + + g_object_set (s_wireless, + NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, + mac_randomization, NULL); return NM_SETTING (s_wireless); @@ -3907,12 +4008,12 @@ make_infiniband_setting (shvarFile *ifcfg, g_free (value); } - if (svTrueValue (ifcfg, "CONNECTED_MODE", FALSE)) + if (svGetValueBoolean (ifcfg, "CONNECTED_MODE", FALSE)) g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "connected", NULL); else g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); - if (svTrueValue (ifcfg, "PKEY", FALSE)) { + if (svGetValueBoolean (ifcfg, "PKEY", FALSE)) { int p_key; char *parent; @@ -4230,6 +4331,12 @@ handle_bridge_option (NMSetting *setting, g_object_set (setting, NM_SETTING_BRIDGE_AGEING_TIME, u, NULL); else PARSE_WARNING ("invalid ageing_time value '%s'", value); + } else if (!strcmp (key, "multicast_snooping")) { + if (get_uint (value, &u)) + g_object_set (setting, NM_SETTING_BRIDGE_MULTICAST_SNOOPING, + (gboolean) u, NULL); + else + PARSE_WARNING ("invalid multicast_snooping value '%s'", value); } else PARSE_WARNING ("unhandled bridge option '%s'", key); } @@ -4443,7 +4550,7 @@ is_bond_device (const char *name, shvarFile *parsed) g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (parsed != NULL, FALSE); - if (svTrueValue (parsed, "BONDING_MASTER", FALSE)) + if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE)) return TRUE; /* XXX: Check for "bond[\d]+"? */ @@ -4457,7 +4564,7 @@ is_vlan_device (const char *name, shvarFile *parsed) g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (parsed != NULL, FALSE); - if (svTrueValue (parsed, "VLAN", FALSE)) + if (svGetValueBoolean (parsed, "VLAN", FALSE)) return TRUE; return FALSE; @@ -4517,6 +4624,7 @@ make_vlan_setting (shvarFile *ifcfg, char *end = NULL; gint vlan_id = -1; guint32 vlan_flags = 0; + gint gvrp; value = svGetValue (ifcfg, "VLAN_ID", FALSE); if (value) { @@ -4591,17 +4699,25 @@ make_vlan_setting (shvarFile *ifcfg, g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL); g_clear_pointer (&parent, g_free); - if (svTrueValue (ifcfg, "REORDER_HDR", FALSE)) + if (svGetValueBoolean (ifcfg, "REORDER_HDR", FALSE)) vlan_flags |= NM_VLAN_FLAG_REORDER_HEADERS; + gvrp = svGetValueBoolean (ifcfg, "GVRP", -1); + if (gvrp > 0) + vlan_flags |= NM_VLAN_FLAG_GVRP; + value = svGetValue (ifcfg, "VLAN_FLAGS", FALSE); if (value) { - if (g_strstr_len (value, -1, "GVRP")) + /* Prefer GVRP variable; only take VLAN_FLAG=GVRP when GVRP is not specified */ + if (g_strstr_len (value, -1, "GVRP") && gvrp == -1) vlan_flags |= NM_VLAN_FLAG_GVRP; if (g_strstr_len (value, -1, "LOOSE_BINDING")) vlan_flags |= NM_VLAN_FLAG_LOOSE_BINDING; } + if (svGetValueBoolean (ifcfg, "MVRP", FALSE)) + vlan_flags |= NM_VLAN_FLAG_MVRP; + g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, vlan_flags, NULL); g_free (value); @@ -4807,7 +4923,7 @@ connection_from_file_full (const char *filename, if (!parsed) return NULL; - if (!svTrueValue (parsed, "NM_CONTROLLED", TRUE)) { + if (!svGetValueBoolean (parsed, "NM_CONTROLLED", TRUE)) { g_assert (out_unhandled != NULL); connection = create_unhandled_connection (filename, parsed, "unmanaged", out_unhandled); @@ -4886,7 +5002,7 @@ connection_from_file_full (const char *filename, } } - if (svTrueValue (parsed, "BONDING_MASTER", FALSE) && + if (svGetValueBoolean (parsed, "BONDING_MASTER", FALSE) && strcasecmp (type, TYPE_BOND)) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "BONDING_MASTER=yes key only allowed in TYPE=bond connections"); diff --git a/src/settings/plugins/ifcfg-rh/reader.h b/src/settings/plugins/ifcfg-rh/reader.h index 2096ffc4..88f9a720 100644 --- a/src/settings/plugins/ifcfg-rh/reader.h +++ b/src/settings/plugins/ifcfg-rh/reader.h @@ -21,9 +21,9 @@ #ifndef __READER_H__ #define __READER_H__ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" #include "shvar.h" NMConnection *connection_from_file (const char *filename, diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 5fd7755f..43068c67 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -36,9 +36,8 @@ #include "shvar.h" -#include "gsystem-local-alloc.h" #include "nm-core-internal.h" -#include "nm-logging.h" +#include "nm-default.h" #define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) @@ -299,35 +298,55 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim) return value; } -/* return TRUE if <key> resolves to any truth value (e.g. "yes", "true", "y", "t", "1") - * return FALSE if <key> resolves to any non-truth value (e.g. "no", "false", "n", "f", "0") - * return <default> otherwise +/** + * svParseBoolean: + * @value: the input string + * @fallback: the fallback value + * + * Parses a string and returns the boolean value it contains or, + * in case no valid value is found, the fallback value. Valid values + * are: "yes", "true", "t", "y", "1" and "no", "false", "f", "n", "0". + * + * Returns: the parsed boolean value or @fallback. */ gint -svTrueValue (shvarFile *s, const char *key, gint def) +svParseBoolean (const char *value, gint fallback) { - char *tmp; - gint returnValue = def; + if (!value) + return fallback; - tmp = svGetValue (s, key, FALSE); - if (!tmp) - return returnValue; - - if ( !g_ascii_strcasecmp ("yes", tmp) - || !g_ascii_strcasecmp ("true", tmp) - || !g_ascii_strcasecmp ("t", tmp) - || !g_ascii_strcasecmp ("y", tmp) - || !g_ascii_strcasecmp ("1", tmp)) - returnValue = TRUE; - else if ( !g_ascii_strcasecmp ("no", tmp) - || !g_ascii_strcasecmp ("false", tmp) - || !g_ascii_strcasecmp ("f", tmp) - || !g_ascii_strcasecmp ("n", tmp) - || !g_ascii_strcasecmp ("0", tmp)) - returnValue = FALSE; + if ( !g_ascii_strcasecmp ("yes", value) + || !g_ascii_strcasecmp ("true", value) + || !g_ascii_strcasecmp ("t", value) + || !g_ascii_strcasecmp ("y", value) + || !g_ascii_strcasecmp ("1", value)) + return TRUE; + else if ( !g_ascii_strcasecmp ("no", value) + || !g_ascii_strcasecmp ("false", value) + || !g_ascii_strcasecmp ("f", value) + || !g_ascii_strcasecmp ("n", value) + || !g_ascii_strcasecmp ("0", value)) + return FALSE; + + return fallback; +} - g_free (tmp); - return returnValue; +/* svGetValueBoolean: + * @s: fhe file + * @key: the name of the key to read + * @fallback: the fallback value in any error case + * + * Reads a value @key and converts it to a boolean using svParseBoolean(). + * + * Returns: the parsed boolean value or @fallback. + */ +gint +svGetValueBoolean (shvarFile *s, const char *key, gint fallback) +{ + gs_free char *tmp = NULL; + + tmp = svGetValue (s, key, FALSE); + return svParseBoolean (tmp, fallback); } /* svGetValueInt64: @@ -426,6 +445,15 @@ svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verba g_free (keyValue); } +void +svSetValueInt64 (shvarFile *s, const char *key, gint64 value) +{ + gs_free char *v = NULL; + + v = g_strdup_printf ("%"G_GINT64_FORMAT, value); + svSetValueFull (s, key, v, TRUE); +} + /* Write the current contents iff modified. Returns FALSE on error * and TRUE on success. Do not write if no values have been modified. * The mode argument is only used if creating the file, not if diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index de7a3585..227a44db 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -31,7 +31,7 @@ #ifndef _SHVAR_H #define _SHVAR_H -#include <glib.h> +#include "nm-default.h" G_BEGIN_DECLS @@ -58,11 +58,13 @@ shvarFile *svOpenFile (const char *name, GError **error); char *svGetValue (shvarFile *s, const char *key, gboolean verbatim); char *svGetValueFull (shvarFile *s, const char *key, gboolean verbatim); +gint svParseBoolean (const char *value, gint def); + /* return TRUE if <key> resolves to any truth value (e.g. "yes", "y", "true") * return FALSE if <key> resolves to any non-truth value (e.g. "no", "n", "false") * return <def> otherwise */ -gint svTrueValue (shvarFile *s, const char *key, gint def); +gint svGetValueBoolean (shvarFile *s, const char *key, gint def); gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback); @@ -73,6 +75,7 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g */ void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim); void svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim); +void svSetValueInt64 (shvarFile *s, const char *key, gint64 value); /* Write the current contents iff modified. Returns FALSE on error diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/Makefile.am index 73f3b5d8..25d27197 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.am @@ -7,8 +7,8 @@ SUBDIRS=network-scripts AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src/ \ @@ -16,7 +16,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -25,7 +25,6 @@ AM_CPPFLAGS = \ AM_LDFLAGS = \ $(GLIB_LIBS) \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils diff --git a/src/settings/plugins/ifcfg-rh/tests/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/Makefile.in index da25c8b9..00636de9 100644 --- a/src/settings/plugins/ifcfg-rh/tests/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/Makefile.in @@ -459,7 +459,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -471,8 +470,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -482,6 +479,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -536,16 +534,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -582,6 +577,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -610,7 +607,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -625,6 +621,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -685,6 +683,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -692,6 +691,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -711,8 +711,8 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/ \ @@ -720,7 +720,7 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_IFCFG_DIR=\"$(abs_srcdir)\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @@ -729,7 +729,6 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(GLIB_LIBS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) @ENABLE_TESTS_TRUE@test_ifcfg_rh_SOURCES = \ diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am index c3fde548..a1b414fd 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.am @@ -67,6 +67,10 @@ EXTRA_DIST = \ ifcfg-test-wifi-band-a \ ifcfg-test-wifi-band-a-channel-mismatch \ ifcfg-test-wifi-band-bg-channel-mismatch \ + ifcfg-test-wifi-mac-random-always \ + ifcfg-test-wifi-mac-random-never \ + ifcfg-test-wifi-mac-random-default \ + ifcfg-test-wifi-mac-random-missing \ test_ca_cert.pem \ test1_key_and_cert.pem \ ifcfg-test-ibft \ @@ -102,6 +106,8 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ ifcfg-test-vlan-reorder-hdr-1 \ + ifcfg-test-vlan-flags-1 \ + ifcfg-test-vlan-flags-2 \ ifcfg-test-wifi-wep-no-keys \ ifcfg-test-permissions \ ifcfg-test-wifi-wep-agent-keys \ @@ -127,6 +133,7 @@ EXTRA_DIST = \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ ifcfg-test-vlan-trailing-spaces \ + ifcfg-test-dns-options \ ifcfg-test-wired-wake-on-lan \ ifcfg-test-wired-ipv6-only-1 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in index 4add27b7..cae7067e 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/Makefile.in @@ -146,7 +146,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -158,8 +157,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -169,6 +166,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -223,16 +221,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -269,6 +264,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -297,7 +294,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -312,6 +308,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -372,6 +370,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -379,6 +378,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -463,6 +463,10 @@ EXTRA_DIST = \ ifcfg-test-wifi-band-a \ ifcfg-test-wifi-band-a-channel-mismatch \ ifcfg-test-wifi-band-bg-channel-mismatch \ + ifcfg-test-wifi-mac-random-always \ + ifcfg-test-wifi-mac-random-never \ + ifcfg-test-wifi-mac-random-default \ + ifcfg-test-wifi-mac-random-missing \ test_ca_cert.pem \ test1_key_and_cert.pem \ ifcfg-test-ibft \ @@ -498,6 +502,8 @@ EXTRA_DIST = \ ifcfg-test-vlan-only-device \ ifcfg-test-vlan-physdev \ ifcfg-test-vlan-reorder-hdr-1 \ + ifcfg-test-vlan-flags-1 \ + ifcfg-test-vlan-flags-2 \ ifcfg-test-wifi-wep-no-keys \ ifcfg-test-permissions \ ifcfg-test-wifi-wep-agent-keys \ @@ -523,6 +529,7 @@ EXTRA_DIST = \ ifcfg-test-team-port \ ifcfg-test-team-port-empty-config \ ifcfg-test-vlan-trailing-spaces \ + ifcfg-test-dns-options \ ifcfg-test-wired-wake-on-lan \ ifcfg-test-wired-ipv6-only-1 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main index ee7a8dc6..1d31b5ba 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bridge-main @@ -4,5 +4,5 @@ TYPE=Bridge BOOTPROTO=dhcp STP=on DELAY=2 -BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352" +BRIDGING_OPTS="priority=32744 hello_time=7 max_age=39 ageing_time=235352 multicast_snooping=0" MACADDR=00:16:41:11:22:33 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options new file mode 100644 index 00000000..62e301e3 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options @@ -0,0 +1,15 @@ +TYPE=Ethernet +DEVICE=eth2 +HWADDR=00:11:22:33:44:ee +BOOTPROTO=dhcp +ONBOOT=yes +USERCTL=yes +NM_CONTROLLED=yes +PEERDNS=yes +DNS1=10.2.0.4 +DOMAIN="lorem.com ipsum.org dolor.edu" +RES_OPTIONS="ndots:3 single-request-reopen inet6" +IPV6INIT=yes +IPV6_AUTOCONF=no +IPV6ADDR="1001:abba::1234/56" +IPV6ADDR_SECONDARIES="2001:abba::2234/64 3001:abba::3234/96" diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 new file mode 100644 index 00000000..5ff87891 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-1 @@ -0,0 +1,14 @@ +VLAN=yes +TYPE=Vlan +DEVICE=super-vlan +VLAN_ID=44 +PHYSDEV=eth9 +REORDER_HDR=yes +GVRP=no +VLAN_FLAGS="GVRP LOOSE_BINDING" +VLAN_INGRESS_PRIORITY_MAP=0:1,2:5 +VLAN_EGRESS_PRIORITY_MAP=12:3,14:7,3:1 +ONBOOT=yes +BOOTPROTO=static +IPADDR=192.168.43.149 +NETMASK=255.255.255.0 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 new file mode 100644 index 00000000..3b536a66 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-flags-2 @@ -0,0 +1,11 @@ +VLAN=yes +TYPE=Vlan +DEVICE=super-vlan +VLAN_ID=44 +PHYSDEV=eth9 +REORDER_HDR=no +VLAN_FLAGS="GVRP LOOSE_BINDING" +ONBOOT=yes +BOOTPROTO=static +IPADDR=192.168.43.149 +NETMASK=255.255.255.0 diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always new file mode 100644 index 00000000..9dcb5bf8 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-always @@ -0,0 +1,7 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=always + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default new file mode 100644 index 00000000..3709c493 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-default @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=default diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing new file mode 100644 index 00000000..f896eb0f --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-missing @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes + diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never new file mode 100644 index 00000000..aa12d749 --- /dev/null +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wifi-mac-random-never @@ -0,0 +1,6 @@ +TYPE=Wireless +DEVICE=eth2 +BOOTPROTO=dhcp +ESSID=blahblah +ONBOOT=yes +MAC_ADDRESS_RANDOMIZATION=never diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static index c8315f45..6d49c01c 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static @@ -18,3 +18,4 @@ IPV6ADDR=dead:beaf::1 IPV6ADDR_SECONDARIES="dead:beaf::2/56" DNS3=1:2:3:4::a DNS4=1:2:3:4::b +RES_OPTIONS= diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto index ee821503..a01f6558 100644 --- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto +++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-static-bootproto @@ -13,3 +13,4 @@ DNS2=4.2.2.2 IPADDR=192.168.1.5 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 +RES_OPTIONS= diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index cd2d0417..b7a887d0 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -54,10 +54,16 @@ #include "reader.h" #include "writer.h" #include "utils.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-test-utils.h" +typedef struct { + const char *name; + const NMSettingMacRandomization value; + const char *write_expected; +} WifiMacRandomData; + #if 0 static void connection_diff (NMConnection *a, NMConnection *b) @@ -484,6 +490,9 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); g_assert (nm_setting_ip_config_get_may_fail (s_ip4)); + g_assert (nm_setting_ip_config_has_dns_options (s_ip4)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0); + /* DNS Addresses */ g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2); g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1"); @@ -506,6 +515,9 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); g_assert (nm_setting_ip_config_get_may_fail (s_ip6)); + g_assert (nm_setting_ip_config_has_dns_options (s_ip6)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip6), ==, 0); + /* DNS Addresses */ g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 2); g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 0), ==, "1:2:3:4::a"); @@ -525,6 +537,7 @@ test_read_wired_static (const char *file, g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "dead:beaf::2"); } else { g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + g_assert (!nm_setting_ip_config_has_dns_options (s_ip6)); } g_object_unref (connection); @@ -563,6 +576,9 @@ test_read_wired_static_no_prefix (gconstpointer user_data) g_assert (s_ip4); g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); + g_assert (!nm_setting_ip_config_has_dns_options (s_ip4)); + g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0); + g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1); ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); g_assert (ip4_addr); @@ -2535,6 +2551,165 @@ test_read_wired_aliases_bad_2 (void) test_read_wired_aliases_bad (TEST_IFCFG_ALIASES_BAD_2, "System aliasem2"); } +#define TEST_IFCFG_DNS_OPTIONS TEST_IFCFG_DIR "/network-scripts/ifcfg-test-dns-options" + +static void +test_read_dns_options (void) +{ + NMConnection *connection; + NMSettingIPConfig *s_ip4, *s_ip6; + char *unmanaged = NULL; + const char *option; + GError *error = NULL; + const char *options[] = { "ndots:3", "single-request-reopen", "inet6" }; + guint32 i, options_len = sizeof (options) / sizeof (options[0]); + + connection = connection_from_file_test (TEST_IFCFG_DNS_OPTIONS, + NULL, + TYPE_ETHERNET, + &unmanaged, + &error); + g_assert (connection); + g_assert (nm_connection_verify (connection, &error)); + g_assert_cmpstr (unmanaged, ==, NULL); + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + g_assert (s_ip4); + + s_ip6 = nm_connection_get_setting_ip6_config (connection); + g_assert (s_ip6); + + i = nm_setting_ip_config_get_num_dns_options (s_ip4); + g_assert_cmpint (i, ==, options_len); + + i = nm_setting_ip_config_get_num_dns_options (s_ip6); + g_assert_cmpint (i, ==, options_len); + + for (i = 0; i < options_len; i++) { + option = nm_setting_ip_config_get_dns_option (s_ip4, i); + g_assert_cmpstr (options[i], ==, option); + + option = nm_setting_ip_config_get_dns_option (s_ip6, i); + g_assert_cmpstr (options[i], ==, option); + } + + g_object_unref (connection); +} + +static void +test_write_dns_options (void) +{ + NMConnection *connection; + NMConnection *reread; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + static const char *mac = "31:33:33:37:be:cd"; + guint32 mtu = 1492; + char *uuid; + NMIPAddress *addr; + NMIPAddress *addr6; + gboolean success; + GError *error = NULL; + char *testfile = NULL; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test DNS options", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + g_object_set (s_wired, + NM_SETTING_WIRED_MAC_ADDRESS, mac, + NM_SETTING_WIRED_MTU, mtu, + NULL); + + /* IP4 setting */ + s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip4)); + + g_object_set (s_ip4, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_GATEWAY, "1.1.1.1", + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 204, + NULL); + + addr = nm_ip_address_new (AF_INET, "1.1.1.3", 24, &error); + nm_setting_ip_config_add_address (s_ip4, addr); + nm_ip_address_unref (addr); + + /* IP6 setting */ + s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ip6)); + + g_object_set (s_ip6, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP_CONFIG_ROUTE_METRIC, (gint64) 206, + NULL); + + /* Add addresses */ + addr6 = nm_ip_address_new (AF_INET6, "1003:1234:abcd::1", 11, &error); + nm_setting_ip_config_add_address (s_ip6, addr6); + nm_ip_address_unref (addr6); + + nm_setting_ip_config_add_dns_option (s_ip4, "debug"); + nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); + + g_assert (nm_connection_verify (connection, &error)); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert (success); + g_assert (testfile); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, + NULL, + TYPE_ETHERNET, + NULL, + &error); + unlink (testfile); + + /* RES_OPTIONS is copied to both IPv4 and IPv6 settings */ + nm_setting_ip_config_clear_dns_options (s_ip4, TRUE); + nm_setting_ip_config_add_dns_option (s_ip4, "debug"); + nm_setting_ip_config_add_dns_option (s_ip4, "timeout:3"); + + nm_setting_ip_config_clear_dns_options (s_ip6, TRUE); + nm_setting_ip_config_add_dns_option (s_ip6, "debug"); + nm_setting_ip_config_add_dns_option (s_ip6, "timeout:3"); + + g_assert (reread); + g_assert (nm_connection_verify (reread, &error)); + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + #define TEST_IFCFG_WIFI_OPEN TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-open" static void @@ -5297,6 +5472,117 @@ test_write_wifi_hidden (void) } static void +test_read_wifi_mac_random (gconstpointer user_data) +{ + const WifiMacRandomData *test_data = user_data; + NMConnection *connection; + NMSettingWireless *s_wifi; + gboolean success; + GError *error = NULL; + char *path; + + path = g_strdup_printf (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-wifi-mac-random-%s", test_data->name); + connection = connection_from_file_test (path, NULL, TYPE_WIRELESS, NULL, &error); + g_free (path); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_wifi = nm_connection_get_setting_wireless (connection); + g_assert (s_wifi); + g_assert_cmpint (nm_setting_wireless_get_mac_address_randomization (s_wifi), ==, test_data->value); + + g_object_unref (connection); +} + +static void +test_write_wifi_mac_random (gconstpointer user_data) +{ + const WifiMacRandomData *test_data = user_data; + NMConnection *connection, *reread; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + char *uuid, *testfile = NULL, *val; + gboolean success; + GError *error = NULL; + shvarFile *f; + GBytes *ssid; + const unsigned char ssid_data[] = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44 }; + + connection = nm_simple_connection_new (); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + val = g_strdup_printf ("Test Write WiFi MAC %s", test_data->name); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, val, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + g_free (val); + + /* Wifi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_bytes_new (ssid_data, sizeof (ssid_data)); + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_MODE, "infrastructure", + NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, test_data->value, + NULL); + g_bytes_unref (ssid); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Save the ifcfg */ + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &testfile, + &error); + g_assert_no_error (error); + g_assert (success); + + f = svOpenFile (testfile, &error); + g_assert_no_error (error); + g_assert (f); + + /* re-read the file to check that what key was written. */ + val = svGetValue (f, "MAC_ADDRESS_RANDOMIZATION", FALSE); + g_assert_cmpstr (val, ==, test_data->write_expected); + g_free (val); + svCloseFile (f); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (testfile, NULL, TYPE_WIRELESS, NULL, &error); + unlink (testfile); + g_assert_no_error (error); + g_assert (reread); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + g_free (testfile); + g_object_unref (connection); + g_object_unref (reread); +} + +static void test_write_wired_wake_on_lan (void) { NMConnection *connection, *reread; @@ -6356,7 +6642,6 @@ test_write_wired_static_ip6_only (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -6441,7 +6726,6 @@ test_write_wired_static_ip6_only (void) "wired-static-ip6-only-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -6592,8 +6876,8 @@ test_read_write_static_routes_legacy (void) NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; char *testfile = NULL; - char *routefile2 = NULL; - char *route6file2 = NULL; + char *routefile = NULL; + char *route6file = NULL; gboolean success; GError *error = NULL; const char *tmp; @@ -6689,17 +6973,14 @@ test_read_write_static_routes_legacy (void) NULL, &error); unlink (testfile); - routefile2 = utils_get_route_path (testfile); - unlink (routefile2); - route6file2 = utils_get_route6_path (testfile); - unlink (route6file2); + routefile = utils_get_route_path (testfile); + unlink (routefile); + route6file = utils_get_route6_path (testfile); + unlink (route6file); ASSERT (reread != NULL, "read-write-static-routes-legacy-reread", "failed to read %s: %s", testfile, error->message); - ASSERT (routefile2 != NULL, - "read-write-static-routes-legacy-reread", "expected routefile for '%s'", testfile); - ASSERT (nm_connection_verify (reread, &error), "read-write-static-routes-legacy-reread-verify", "failed to verify %s: %s", testfile, error->message); @@ -6707,8 +6988,8 @@ test_read_write_static_routes_legacy (void) "read-write-static-routes-legacy-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (routefile2); - g_free (route6file2); + g_free (routefile); + g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9859,7 +10140,6 @@ test_write_wired_qeth_dhcp (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -9947,7 +10227,6 @@ test_write_wired_qeth_dhcp (void) "wired-qeth-dhcp-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -9966,7 +10245,6 @@ test_write_wired_ctc_dhcp (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; shvarFile *ifcfg; char *tmp; @@ -10066,7 +10344,6 @@ test_write_wired_ctc_dhcp (void) g_assert (success); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10084,7 +10361,6 @@ test_write_permissions (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -10164,7 +10440,6 @@ test_write_permissions (void) "permissions-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10185,7 +10460,6 @@ test_write_wifi_wep_agent_keys (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); g_assert (connection != NULL); @@ -10290,7 +10564,6 @@ test_write_wifi_wep_agent_keys (void) g_assert (success); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10544,6 +10817,7 @@ test_read_bridge_main (void) g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7); g_assert_cmpuint (nm_setting_bridge_get_max_age (s_bridge), ==, 39); g_assert_cmpuint (nm_setting_bridge_get_ageing_time (s_bridge), ==, 235352); + g_assert (!nm_setting_bridge_get_multicast_snooping (s_bridge)); /* MAC address */ mac = nm_setting_bridge_get_mac_address (s_bridge); @@ -10702,7 +10976,6 @@ test_write_bridge_component (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); g_assert (connection); @@ -10773,7 +11046,6 @@ test_write_bridge_component (void) g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -10849,17 +11121,17 @@ test_read_vlan_interface (void) g_assert_cmpint (nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP), ==, 3); g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 0, &from, &to)); + g_assert_cmpint (from, ==, 3); + g_assert_cmpint (to, ==, 1); + + g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1, &from, &to)); g_assert_cmpint (from, ==, 12); g_assert_cmpint (to, ==, 3); - g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 1, &from, &to)); + g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 2, &from, &to)); g_assert_cmpint (from, ==, 14); g_assert_cmpint (to, ==, 7); - g_assert (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, 2, &from, &to)); - g_assert_cmpint (from, ==, 3); - g_assert_cmpint (to, ==, 1); - g_object_unref (connection); } @@ -10976,6 +11248,62 @@ test_read_vlan_reorder_hdr_1 (void) } static void +test_read_vlan_flags_1 (void) +{ + NMConnection *connection; + GError *error = NULL; + NMSettingVlan *s_vlan; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-1", + NULL, + TYPE_ETHERNET, + NULL, + &error); + g_assert_no_error (error); + g_assert (connection != NULL); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "super-vlan"); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 44); + /* reorder_hdr and loose_binding */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 5); + + g_object_unref (connection); +} + +static void +test_read_vlan_flags_2 (void) +{ + NMConnection *connection; + GError *error = NULL; + NMSettingVlan *s_vlan; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", + NULL, + TYPE_ETHERNET, + NULL, + &error); + g_assert_no_error (error); + g_assert (connection != NULL); + + g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "super-vlan"); + + s_vlan = nm_connection_get_setting_vlan (connection); + g_assert (s_vlan); + + g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9"); + g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 44); + /* gvrp and loose_binding */ + g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==, 6); + + g_object_unref (connection); +} + +static void test_write_vlan (void) { NMConnection *connection; @@ -11003,6 +11331,54 @@ test_write_vlan (void) } static void +test_write_vlan_flags (void) +{ + NMConnection *connection, *reread; + char *written = NULL; + GError *error = NULL; + gboolean success = FALSE; + + connection = connection_from_file_test (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-vlan-flags-2", + NULL, + TYPE_VLAN, + NULL, + &error); + g_assert (connection != NULL); + + success = writer_new_connection (connection, + TEST_SCRATCH_DIR "/network-scripts/", + &written, + &error); + g_assert (success); + + /* reread will be normalized, so we must normalize connection too. */ + nm_connection_normalize (connection, NULL, NULL, NULL); + + /* re-read the connection for comparison */ + reread = connection_from_file_test (written, + NULL, + TYPE_ETHERNET, + NULL, + &error); + + unlink (written); + g_free (written); + + g_assert_no_error (error); + g_assert (reread != NULL); + + success = nm_connection_verify (reread, &error); + g_assert_no_error (error); + g_assert (success); + + success = nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT); + g_assert (success); + + g_object_unref (connection); + g_object_unref (reread); +} + +static void test_write_vlan_only_vlanid (void) { NMConnection *connection, *reread; @@ -11434,7 +11810,6 @@ test_write_bond_slave (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -11499,7 +11874,6 @@ test_write_bond_slave (void) "bond-slave-write", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -11724,7 +12098,6 @@ test_write_bond_slave_ib (void) gboolean success; GError *error = NULL; char *testfile = NULL; - char *route6file = NULL; connection = nm_simple_connection_new (); @@ -11790,7 +12163,6 @@ test_write_bond_slave_ib (void) "bond-slave-write-ib", "written and re-read connection weren't the same."); g_free (testfile); - g_free (route6file); g_object_unref (connection); g_object_unref (reread); } @@ -12741,6 +13113,7 @@ int main (int argc, char **argv) g_test_add_data_func (TPATH "static-ip6-only-gw/::", "::", test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/2001:db8:8:4::2", "2001:db8:8:4::2", test_write_wired_static_ip6_only_gw); g_test_add_data_func (TPATH "static-ip6-only-gw/::ffff:255.255.255.255", "::ffff:255.255.255.255", test_write_wired_static_ip6_only_gw); + g_test_add_func (TPATH "read-dns-options", test_read_dns_options); test_read_wired_static (TEST_IFCFG_WIRED_STATIC, "System test-wired-static", TRUE); test_read_wired_static (TEST_IFCFG_WIRED_STATIC_BOOTPROTO, "System test-wired-static-bootproto", FALSE); @@ -12805,6 +13178,35 @@ int main (int argc, char **argv) g_test_add_func (TPATH "wifi/read-band-a-channel-mismatch", test_read_wifi_band_a_channel_mismatch); g_test_add_func (TPATH "wifi/read-band-bg-channel-mismatch", test_read_wifi_band_bg_channel_mismatch); g_test_add_func (TPATH "wifi/read-hidden", test_read_wifi_hidden); + + { + static const WifiMacRandomData test_wifi_mac_random[] = { + { "always", NM_SETTING_MAC_RANDOMIZATION_ALWAYS, "always" }, + { "never", NM_SETTING_MAC_RANDOMIZATION_NEVER, "never" }, + { "default", NM_SETTING_MAC_RANDOMIZATION_DEFAULT, "default" }, + { "missing", NM_SETTING_MAC_RANDOMIZATION_NEVER, "never" }, + }; + int i; + + for (i = 0; i < G_N_ELEMENTS (test_wifi_mac_random); i++) { + char *tpath; + + tpath = g_strdup_printf (TPATH "wifi/read-mac-random-%s", test_wifi_mac_random[i].name); + g_test_add_data_func_full (tpath, + g_memdup (&test_wifi_mac_random[i], sizeof (test_wifi_mac_random[i])), + test_read_wifi_mac_random, + g_free); + g_free (tpath); + + tpath = g_strdup_printf (TPATH "wifi/write-mac-random-%s", test_wifi_mac_random[i].name); + g_test_add_data_func_full (tpath, + g_memdup (&test_wifi_mac_random[i], sizeof (test_wifi_mac_random[i])), + test_write_wifi_mac_random, + g_free); + g_free (tpath); + } + } + test_read_wired_qeth_static (); test_read_wired_ctc_static (); test_read_wifi_wep_no_keys (); @@ -12812,6 +13214,8 @@ int main (int argc, char **argv) test_read_wifi_wep_agent_keys (); test_read_infiniband (); test_read_vlan_interface (); + g_test_add_func (TPATH "vlan/read-flags-1", test_read_vlan_flags_1); + g_test_add_func (TPATH "vlan/read-flags-2", test_read_vlan_flags_2); test_read_vlan_only_vlan_id (); test_read_vlan_only_device (); g_test_add_func (TPATH "vlan/physdev", test_read_vlan_physdev); @@ -12894,9 +13298,11 @@ int main (int argc, char **argv) test_write_wifi_wep_agent_keys (); test_write_infiniband (); test_write_vlan (); + g_test_add_func (TPATH "vlan/write-flags", test_write_vlan_flags); test_write_vlan_only_vlanid (); g_test_add_func (TPATH "vlan/write-vlan-reorder-hdr", test_write_vlan_reorder_hdr); test_write_ethernet_missing_ipv6 (); + g_test_add_func (TPATH "write-dns-options", test_write_dns_options); /* iSCSI / ibft */ g_test_add_func (TPATH "ibft/ignored", test_read_ibft_ignored); diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index a793288d..599e3a49 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -20,14 +20,13 @@ #include "config.h" -#include <glib.h> #include <stdlib.h> #include <string.h> +#include "nm-default.h" #include "nm-core-internal.h" #include "nm-macros-internal.h" #include "NetworkManagerUtils.h" -#include "gsystem-local-alloc.h" #include "utils.h" #include "shvar.h" diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h index 547bfcb2..329f4547 100644 --- a/src/settings/plugins/ifcfg-rh/utils.h +++ b/src/settings/plugins/ifcfg-rh/utils.h @@ -21,11 +21,10 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" #include "shvar.h" #include "common.h" -#include "nm-logging.h" #define NM_IFCFG_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory") #define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")" diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 3640a104..5770d668 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright 2009 - 2014 Red Hat, Inc. + * Copyright 2009 - 2015 Red Hat, Inc. */ #include "config.h" @@ -45,8 +45,7 @@ #include "nm-core-internal.h" #include "nm-macros-internal.h" -#include "nm-logging.h" -#include "gsystem-local-alloc.h" +#include "nm-default.h" #include "common.h" #include "shvar.h" #include "reader.h" @@ -968,7 +967,7 @@ write_wireless_setting (NMConnection *connection, tmp = g_strdup_printf ("KEY_PASSPHRASE%d", i + 1); set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); g_free (tmp); - + tmp = g_strdup_printf ("KEY%d", i + 1); set_secret (ifcfg, tmp, NULL, "WEP_KEY_FLAGS", NM_SETTING_SECRET_FLAG_NONE, FALSE); g_free (tmp); @@ -988,6 +987,21 @@ write_wireless_setting (NMConnection *connection, } svSetValue (ifcfg, "SSID_HIDDEN", nm_setting_wireless_get_hidden (s_wireless) ? "yes" : NULL, TRUE); + svSetValue (ifcfg, "POWERSAVE", nm_setting_wireless_get_powersave (s_wireless) ? "yes" : NULL, TRUE); + + svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", NULL, TRUE); + switch (nm_setting_wireless_get_mac_address_randomization (s_wireless)) { + case NM_SETTING_MAC_RANDOMIZATION_DEFAULT: + svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "default", TRUE); + break; + case NM_SETTING_MAC_RANDOMIZATION_ALWAYS: + svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "always", TRUE); + break; + default: + case NM_SETTING_MAC_RANDOMIZATION_NEVER: + svSetValue (ifcfg, "MAC_ADDRESS_RANDOMIZATION", "never", TRUE); + break; + } svSetValue (ifcfg, "TYPE", TYPE_WIRELESS, FALSE); @@ -1268,15 +1282,14 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, else svSetValue (ifcfg, "REORDER_HDR", "no", FALSE); + svSetValue (ifcfg, "GVRP", vlan_flags & NM_VLAN_FLAG_GVRP ? "yes" : "no", FALSE); + svSetValue (ifcfg, "VLAN_FLAGS", NULL, FALSE); - if (vlan_flags & NM_VLAN_FLAG_GVRP) { - if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) - svSetValue (ifcfg, "VLAN_FLAGS", "GVRP,LOOSE_BINDING", FALSE); - else - svSetValue (ifcfg, "VLAN_FLAGS", "GVRP", FALSE); - } else if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) + if (vlan_flags & NM_VLAN_FLAG_LOOSE_BINDING) svSetValue (ifcfg, "VLAN_FLAGS", "LOOSE_BINDING", FALSE); + svSetValue (ifcfg, "MVRP", vlan_flags & NM_VLAN_FLAG_MVRP ? "yes" : "no", FALSE); + tmp = vlan_priority_maplist_to_stringlist (s_vlan, NM_VLAN_INGRESS_MAP); svSetValue (ifcfg, "VLAN_INGRESS_PRIORITY_MAP", tmp, FALSE); g_free (tmp); @@ -1380,7 +1393,7 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired, } static guint32 -get_setting_default (NMSetting *setting, const char *prop) +get_setting_default_uint (NMSetting *setting, const char *prop) { GParamSpec *pspec; GValue val = G_VALUE_INIT; @@ -1397,11 +1410,29 @@ get_setting_default (NMSetting *setting, const char *prop) } static gboolean +get_setting_default_boolean (NMSetting *setting, const char *prop) +{ + GParamSpec *pspec; + GValue val = G_VALUE_INIT; + gboolean ret = 0; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop); + g_assert (pspec); + g_value_init (&val, pspec->value_type); + g_param_value_set_default (pspec, &val); + g_assert (G_VALUE_HOLDS_BOOLEAN (&val)); + ret = g_value_get_boolean (&val); + g_value_unset (&val); + return ret; +} + +static gboolean write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) { NMSettingBridge *s_bridge; const char *iface; guint32 i; + gboolean b; GString *opts; const char *mac; char *s; @@ -1435,7 +1466,7 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error svSetValue (ifcfg, "STP", "yes", FALSE); i = nm_setting_bridge_get_forward_delay (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY)) { s = g_strdup_printf ("%u", i); svSetValue (ifcfg, "DELAY", s, FALSE); g_free (s); @@ -1444,14 +1475,14 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error g_string_append_printf (opts, "priority=%u", nm_setting_bridge_get_priority (s_bridge)); i = nm_setting_bridge_get_hello_time (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME)) { + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME)) { if (opts->len) g_string_append_c (opts, ' '); g_string_append_printf (opts, "hello_time=%u", i); } i = nm_setting_bridge_get_max_age (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MAX_AGE)) { + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MAX_AGE)) { if (opts->len) g_string_append_c (opts, ' '); g_string_append_printf (opts, "max_age=%u", i); @@ -1459,12 +1490,19 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error } i = nm_setting_bridge_get_ageing_time (s_bridge); - if (i != get_setting_default (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME)) { + if (i != get_setting_default_uint (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME)) { if (opts->len) g_string_append_c (opts, ' '); g_string_append_printf (opts, "ageing_time=%u", i); } + b = nm_setting_bridge_get_multicast_snooping (s_bridge); + if (b != get_setting_default_boolean (NM_SETTING (s_bridge), NM_SETTING_BRIDGE_MULTICAST_SNOOPING)) { + if (opts->len) + g_string_append_c (opts, ' '); + g_string_append_printf (opts, "multicast_snooping=%u", (guint32) b); + } + if (opts->len) svSetValue (ifcfg, "BRIDGING_OPTS", opts->str, FALSE); g_string_free (opts, TRUE); @@ -1491,11 +1529,11 @@ write_bridge_port_setting (NMConnection *connection, shvarFile *ifcfg, GError ** opts = g_string_sized_new (32); i = nm_setting_bridge_port_get_priority (s_port); - if (i != get_setting_default (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PRIORITY)) + if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PRIORITY)) g_string_append_printf (opts, "priority=%u", i); i = nm_setting_bridge_port_get_path_cost (s_port); - if (i != get_setting_default (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PATH_COST)) { + if (i != get_setting_default_uint (NM_SETTING (s_port), NM_SETTING_BRIDGE_PORT_PATH_COST)) { if (opts->len) g_string_append_c (opts, ' '); g_string_append_printf (opts, "path_cost=%u", i); @@ -1753,6 +1791,18 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) FALSE); } + switch (nm_setting_connection_get_lldp (s_con)) { + case NM_SETTING_CONNECTION_LLDP_ENABLE_RX: + tmp = "rx"; + break; + case NM_SETTING_CONNECTION_LLDP_DISABLE: + tmp = "no"; + break; + default: + tmp = NULL; + } + svSetValue (ifcfg, "LLDP", tmp, FALSE); + /* Permissions */ svSetValue (ifcfg, "USERS", NULL, FALSE); n = nm_setting_connection_get_num_permissions (s_con); @@ -1897,6 +1947,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gint32 j; guint32 i, n, num; gint64 route_metric; + int dhcp_timeout; GString *searches; gboolean success = FALSE; gboolean fake_ip4 = FALSE; @@ -2090,6 +2141,10 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) if (value) svSetValue (ifcfg, "DHCP_HOSTNAME", value, FALSE); + value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)); + if (value) + svSetValue (ifcfg, "DHCP_FQDN", value, FALSE); + /* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly * in that case, because it is NM-specific variable */ @@ -2100,6 +2155,11 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4)); if (value) svSetValue (ifcfg, "DHCP_CLIENT_ID", value, FALSE); + + dhcp_timeout = nm_setting_ip4_config_get_dhcp_timeout (NM_SETTING_IP4_CONFIG (s_ip4)); + tmp = dhcp_timeout ? g_strdup_printf ("%d", dhcp_timeout) : NULL; + svSetValue (ifcfg, "IPV4_DHCP_TIMEOUT", tmp, FALSE); + g_free (tmp); } svSetValue (ifcfg, "IPV4_FAILURE_FATAL", @@ -2353,6 +2413,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gint64 route_metric; GString *ip_str1, *ip_str2, *ip_ptr; char *route6_path; + NMSettingIP6ConfigAddrGenMode addr_gen_mode; s_ip6 = nm_connection_get_setting_ip6_config (connection); if (!s_ip6) { @@ -2365,6 +2426,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) svSetValue (ifcfg, "IPV6_PEERROUTES", "yes", FALSE); svSetValue (ifcfg, "IPV6_FAILURE_FATAL", "no", FALSE); svSetValue (ifcfg, "IPV6_ROUTE_METRIC", NULL, FALSE); + svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", "stable-privacy", FALSE); return TRUE; } @@ -2502,6 +2564,15 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) break; } + /* IPv6 Address generation mode */ + addr_gen_mode = nm_setting_ip6_config_get_addr_gen_mode (NM_SETTING_IP6_CONFIG (s_ip6)); + if (addr_gen_mode != NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64) { + tmp = nm_utils_enum_to_str (nm_setting_ip6_config_addr_gen_mode_get_type (), + addr_gen_mode); + svSetValue (ifcfg, "IPV6_ADDR_GEN_MODE", tmp, FALSE); + g_free (tmp); + } + /* Static routes go to route6-<dev> file */ route6_path = utils_get_route6_path (ifcfg->fileName); if (!route6_path) { @@ -2520,6 +2591,63 @@ error: return FALSE; } +static void +add_dns_option (GPtrArray *array, const char *option) +{ + if (_nm_utils_dns_option_find_idx (array, option) < 0) + g_ptr_array_add (array, (gpointer) option); +} + +static gboolean +write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error) +{ + NMSettingIPConfig *s_ip6; + NMSettingIPConfig *s_ip4; + const char *method; + int i, num_options; + GPtrArray *array; + GString *value; + + s_ip4 = nm_connection_get_setting_ip4_config (connection); + s_ip6 = nm_connection_get_setting_ip6_config (connection); + array = g_ptr_array_new (); + + if (s_ip4) { + method = nm_setting_ip_config_get_method (s_ip4); + if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) { + num_options = nm_setting_ip_config_get_num_dns_options (s_ip4); + for (i = 0; i < num_options; i++) + add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip4, i)); + } + } + + if (s_ip6) { + method = nm_setting_ip_config_get_method (s_ip6); + if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { + num_options = nm_setting_ip_config_get_num_dns_options (s_ip6); + for (i = 0; i < num_options; i++) + add_dns_option (array, nm_setting_ip_config_get_dns_option (s_ip6, i)); + } + } + + if (array->len > 0 + || (s_ip4 && nm_setting_ip_config_has_dns_options (s_ip4)) + || (s_ip6 && nm_setting_ip_config_has_dns_options (s_ip6))) { + value = g_string_new (NULL); + for (i = 0; i < array->len; i++) { + if (i > 0) + g_string_append_c (value, ' '); + g_string_append (value, array->pdata[i]); + } + svSetValueFull (ifcfg, "RES_OPTIONS", value->str, FALSE); + g_string_free (value, TRUE); + } else + svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); + + g_ptr_array_unref (array); + return TRUE; +} + static char * escape_id (const char *id) { @@ -2660,6 +2788,7 @@ write_connection (NMConnection *connection, if (!utils_ignore_ip_config (connection)) { svSetValue (ifcfg, "DHCP_HOSTNAME", NULL, FALSE); + svSetValue (ifcfg, "DHCP_FQDN", NULL, FALSE); if (!write_ip4_setting (connection, ifcfg, error)) goto out; @@ -2667,6 +2796,9 @@ write_connection (NMConnection *connection, if (!write_ip6_setting (connection, ifcfg, error)) goto out; + + if (!write_res_options (connection, ifcfg, error)) + goto out; } write_connection_setting (s_con, ifcfg); diff --git a/src/settings/plugins/ifcfg-rh/writer.h b/src/settings/plugins/ifcfg-rh/writer.h index 894313dd..69389361 100644 --- a/src/settings/plugins/ifcfg-rh/writer.h +++ b/src/settings/plugins/ifcfg-rh/writer.h @@ -22,9 +22,11 @@ #define _WRITER_H_ #include <sys/types.h> -#include <glib.h> + #include <nm-connection.h> +#include "nm-default.h" + gboolean writer_can_write_connection (NMConnection *connection, GError **error); diff --git a/src/settings/plugins/ifcfg-suse/Makefile.am b/src/settings/plugins/ifcfg-suse/Makefile.am deleted file mode 100644 index 55494536..00000000 --- a/src/settings/plugins/ifcfg-suse/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-suse.la - -libnm_settings_plugin_ifcfg_suse_la_SOURCES = \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifcfg_suse_la_LDFLAGS = -module -avoid-version diff --git a/src/settings/plugins/ifcfg-suse/Makefile.in b/src/settings/plugins/ifcfg-suse/Makefile.in deleted file mode 100644 index fa51b0aa..00000000 --- a/src/settings/plugins/ifcfg-suse/Makefile.in +++ /dev/null @@ -1,819 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/settings/plugins/ifcfg-suse -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ - $(top_srcdir)/m4/compiler_warnings.m4 \ - $(top_srcdir)/m4/gettext.m4 \ - $(top_srcdir)/m4/gnome-code-coverage.m4 \ - $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ - $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkglibdir)" -LTLIBRARIES = $(pkglib_LTLIBRARIES) -libnm_settings_plugin_ifcfg_suse_la_LIBADD = -am_libnm_settings_plugin_ifcfg_suse_la_OBJECTS = plugin.lo -libnm_settings_plugin_ifcfg_suse_la_OBJECTS = \ - $(am_libnm_settings_plugin_ifcfg_suse_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libnm_settings_plugin_ifcfg_suse_la_LINK = $(LIBTOOL) $(AM_V_lt) \ - --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ - $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libnm_settings_plugin_ifcfg_suse_la_LDFLAGS) $(LDFLAGS) -o \ - $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libnm_settings_plugin_ifcfg_suse_la_SOURCES) -DIST_SOURCES = $(libnm_settings_plugin_ifcfg_suse_la_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALL_LINGUAS = @ALL_LINGUAS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_TESTS_FD_REDIRECT = @AM_TESTS_FD_REDIRECT@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ -BLUEZ5_LIBS = @BLUEZ5_LIBS@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ -DBUS_LIBS = @DBUS_LIBS@ -DBUS_SYS_DIR = @DBUS_SYS_DIR@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHCLIENT_PATH = @DHCLIENT_PATH@ -DHCPCD_PATH = @DHCPCD_PATH@ -DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ -DLLTOOL = @DLLTOOL@ -DNSMASQ_PATH = @DNSMASQ_PATH@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GENHTML = @GENHTML@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ -GLIB_LIBS = @GLIB_LIBS@ -GLIB_MAKEFILE = @GLIB_MAKEFILE@ -GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ -GNUTLS_LIBS = @GNUTLS_LIBS@ -GREP = @GREP@ -GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ -GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ -GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ -GTKDOC_MKPDF = @GTKDOC_MKPDF@ -GTKDOC_REBASE = @GTKDOC_REBASE@ -GUDEV_CFLAGS = @GUDEV_CFLAGS@ -GUDEV_LIBS = @GUDEV_LIBS@ -HTML_DIR = @HTML_DIR@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ -INTLTOOL_MERGE = @INTLTOOL_MERGE@ -INTLTOOL_PERL = @INTLTOOL_PERL@ -INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ -INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ -INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ -INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ -INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ -INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ -INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ -INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ -INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ -INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ -INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ -INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ -IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ -KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ -LCOV = @LCOV@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBM = @LIBM@ -LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ -LIBNDP_LIBS = @LIBNDP_LIBS@ -LIBNL_CFLAGS = @LIBNL_CFLAGS@ -LIBNL_LIBS = @LIBNL_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ -LIBSOUP_LIBS = @LIBSOUP_LIBS@ -LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ -LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LOG_DRIVER = @LOG_DRIVER@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ -MM_GLIB_LIBS = @MM_GLIB_LIBS@ -MOC = @MOC@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NEWT_CFLAGS = @NEWT_CFLAGS@ -NEWT_LIBS = @NEWT_LIBS@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ -NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ -NM_MICRO_VERSION = @NM_MICRO_VERSION@ -NM_MINOR_VERSION = @NM_MINOR_VERSION@ -NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ -NM_VERSION = @NM_VERSION@ -NSS_CFLAGS = @NSS_CFLAGS@ -NSS_LIBS = @NSS_LIBS@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POLKIT_CFLAGS = @POLKIT_CFLAGS@ -POLKIT_LIBS = @POLKIT_LIBS@ -POSUB = @POSUB@ -PPPD_PATH = @PPPD_PATH@ -PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ -QT_CFLAGS = @QT_CFLAGS@ -QT_LIBS = @QT_LIBS@ -RANLIB = @RANLIB@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ -SELINUX_CFLAGS = @SELINUX_CFLAGS@ -SELINUX_LIBS = @SELINUX_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ -SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ -SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ -SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ -SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ -SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ -SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_DIR = @UDEV_DIR@ -USE_NLS = @USE_NLS@ -UUID_CFLAGS = @UUID_CFLAGS@ -UUID_LIBS = @UUID_LIBS@ -VALGRIND_RULES = @VALGRIND_RULES@ -VAPIGEN = @VAPIGEN@ -VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ -VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ -VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -intltool__v_merge_options_ = @intltool__v_merge_options_@ -intltool__v_merge_options_0 = @intltool__v_merge_options_0@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -nmbinary = @nmbinary@ -nmconfdir = @nmconfdir@ -nmdatadir = @nmdatadir@ -nmrundir = @nmrundir@ -nmstatedir = @nmstatedir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -systemdsystemunitdir = @systemdsystemunitdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -with_dhclient = @with_dhclient@ -with_dhcpcd = @with_dhcpcd@ -with_netconfig = @with_netconfig@ -with_resolvconf = @with_resolvconf@ -with_valgrind = @with_valgrind@ -AM_CPPFLAGS = \ - $(GLIB_CFLAGS) \ - -I${top_srcdir}/src \ - -I${top_srcdir}/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-core \ - -I$(top_builddir)/libnm-core \ - -DG_LOG_DOMAIN=\""NetworkManager-ifcfg-suse"\" \ - -DNETWORKMANAGER_COMPILATION \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ - -DSYSCONFDIR=\"$(sysconfdir)\" - -pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-suse.la -libnm_settings_plugin_ifcfg_suse_la_SOURCES = \ - plugin.c \ - plugin.h - -libnm_settings_plugin_ifcfg_suse_la_LDFLAGS = -module -avoid-version -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-suse/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/settings/plugins/ifcfg-suse/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ - } - -uninstall-pkglibLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ - done - -clean-pkglibLTLIBRARIES: - -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) - @list='$(pkglib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnm-settings-plugin-ifcfg-suse.la: $(libnm_settings_plugin_ifcfg_suse_la_OBJECTS) $(libnm_settings_plugin_ifcfg_suse_la_DEPENDENCIES) $(EXTRA_libnm_settings_plugin_ifcfg_suse_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnm_settings_plugin_ifcfg_suse_la_LINK) -rpath $(pkglibdir) $(libnm_settings_plugin_ifcfg_suse_la_OBJECTS) $(libnm_settings_plugin_ifcfg_suse_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) -installdirs: - for dir in "$(DESTDIR)$(pkglibdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-pkglibLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-pkglibLTLIBRARIES - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pkglibLTLIBRARIES install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-pkglibLTLIBRARIES - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/settings/plugins/ifcfg-suse/plugin.c b/src/settings/plugins/ifcfg-suse/plugin.c deleted file mode 100644 index a1667f64..00000000 --- a/src/settings/plugins/ifcfg-suse/plugin.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ - -/* NetworkManager system settings service - * - * Søren Sandmann <sandmann@daimi.au.dk> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2007 - 2011 Red Hat, Inc. - * (C) Copyright 2007 - 2008 Novell, Inc. - */ - -#include "config.h" - -#include <string.h> - -#include <gmodule.h> -#include <glib-object.h> -#include <gio/gio.h> - -#include "plugin.h" -#include "nm-system-config-interface.h" - -#define IFCFG_PLUGIN_NAME "ifcfg-suse" -#define IFCFG_PLUGIN_INFO "(C) 2008 Novell, Inc. To report bugs please use the NetworkManager mailing list." -#define IFCFG_DIR SYSCONFDIR "/sysconfig/network" -#define CONF_DHCP IFCFG_DIR "/dhcp" -#define HOSTNAME_FILE "/etc/HOSTNAME" - -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); - -G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) - -#define SC_PLUGIN_IFCFG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgPrivate)) - - -#define IFCFG_FILE_PATH_TAG "ifcfg-file-path" - -typedef struct { - GFileMonitor *hostname_monitor; - GFileMonitor *dhcp_monitor; - char *hostname; -} SCPluginIfcfgPrivate; - -typedef void (*FileChangedFn) (gpointer user_data); - -typedef struct { - FileChangedFn callback; - gpointer user_data; -} FileMonitorInfo; - -static void -file_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer user_data) -{ - FileMonitorInfo *info; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - case G_FILE_MONITOR_EVENT_DELETED: - info = (FileMonitorInfo *) user_data; - info->callback (info->user_data); - break; - default: - break; - } -} - -static GFileMonitor * -monitor_file_changes (const char *filename, - FileChangedFn callback, - gpointer user_data) -{ - GFile *file; - GFileMonitor *monitor; - FileMonitorInfo *info; - - file = g_file_new_for_path (filename); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - info = g_new0 (FileMonitorInfo, 1); - info->callback = callback; - info->user_data = user_data; - g_object_weak_ref (G_OBJECT (monitor), (GWeakNotify) g_free, info); - g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), info); - } - - return monitor; -} - -static gboolean -hostname_is_dynamic (void) -{ - GIOChannel *channel; - const char *pattern = "DHCLIENT_SET_HOSTNAME="; - char *str = NULL; - int pattern_len; - gboolean dynamic = FALSE; - - channel = g_io_channel_new_file (CONF_DHCP, "r", NULL); - if (!channel) - return dynamic; - - pattern_len = strlen (pattern); - - while (g_io_channel_read_line (channel, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF) { - if (!strncmp (str, pattern, pattern_len)) { - if (!strncmp (str + pattern_len, "\"yes\"", 5)) - dynamic = TRUE; - break; - } - g_free (str); - } - - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - - return dynamic; -} - -static char * -hostname_read (void) -{ - GIOChannel *channel; - char *hostname = NULL; - - channel = g_io_channel_new_file (HOSTNAME_FILE, "r", NULL); - if (channel) { - g_io_channel_read_line (channel, &hostname, NULL, NULL, NULL); - g_io_channel_shutdown (channel, FALSE, NULL); - g_io_channel_unref (channel); - - if (hostname) - hostname = g_strchomp (hostname); - } - - return hostname; -} - -static void -hostname_changed (gpointer data) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (data); - - g_free (priv->hostname); - if (hostname_is_dynamic ()) - priv->hostname = NULL; - else - priv->hostname = hostname_read (); - - g_object_notify (G_OBJECT (data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); - GIOChannel *channel; - - channel = g_io_channel_new_file (HOSTNAME_FILE, "w", NULL); - if (channel) { - g_io_channel_write_chars (channel, hostname, -1, NULL, NULL); - g_io_channel_write_chars (channel, "\n", -1, NULL, NULL); - g_io_channel_shutdown (channel, TRUE, NULL); - g_io_channel_unref (channel); - } - - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); -} - -static void -init (NMSystemConfigInterface *config) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config); - - priv->hostname_monitor = monitor_file_changes (HOSTNAME_FILE, hostname_changed, config); - priv->dhcp_monitor = monitor_file_changes (CONF_DHCP, hostname_changed, config); - - if (!hostname_is_dynamic ()) - priv->hostname = hostname_read (); -} - -static void -sc_plugin_ifcfg_init (SCPluginIfcfg *self) -{ -} - -static void -dispose (GObject *object) -{ - SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object); - - if (priv->dhcp_monitor) - g_object_unref (priv->dhcp_monitor); - - if (priv->hostname_monitor) - g_object_unref (priv->hostname_monitor); - - g_free (priv->hostname); - - G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object); -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: - g_value_set_string (value, IFCFG_PLUGIN_NAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: - g_value_set_string (value, IFCFG_PLUGIN_INFO); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, SC_PLUGIN_IFCFG_GET_PRIVATE (object)->hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - const char *hostname; - - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_IFCFG (object), hostname); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (req_class); - - g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate)); - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) -{ - /* interface implementation */ - system_config_interface_class->init = init; -} - -G_MODULE_EXPORT GObject * -nm_system_config_factory (void) -{ - static SCPluginIfcfg *singleton = NULL; - - if (!singleton) - singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL)); - else - g_object_ref (singleton); - - return G_OBJECT (singleton); -} diff --git a/src/settings/plugins/ifcfg-suse/plugin.h b/src/settings/plugins/ifcfg-suse/plugin.h deleted file mode 100644 index 24dbff95..00000000 --- a/src/settings/plugins/ifcfg-suse/plugin.h +++ /dev/null @@ -1,50 +0,0 @@ -/* NetworkManager system settings service - * - * Søren Sandmann <sandmann@daimi.au.dk> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2007 Red Hat, Inc. - */ - -#ifndef _PLUGIN_H_ -#define _PLUGIN_H_ - -#include <glib-object.h> - -#define PLUGIN_NAME "ifcfg-suse" - -#define SC_TYPE_PLUGIN_IFCFG (sc_plugin_ifcfg_get_type ()) -#define SC_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfg)) -#define SC_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) -#define SC_IS_PLUGIN_IFCFG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFCFG)) -#define SC_IS_PLUGIN_IFCFG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFCFG)) -#define SC_PLUGIN_IFCFG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFCFG, SCPluginIfcfgClass)) - -typedef struct _SCPluginIfcfg SCPluginIfcfg; -typedef struct _SCPluginIfcfgClass SCPluginIfcfgClass; - -struct _SCPluginIfcfg { - GObject parent; -}; - -struct _SCPluginIfcfgClass { - GObjectClass parent; -}; - -GType sc_plugin_ifcfg_get_type (void); - -#endif /* _PLUGIN_H_ */ - diff --git a/src/settings/plugins/ifnet/Makefile.am b/src/settings/plugins/ifnet/Makefile.am index 84e2e697..ffd8ab3c 100644 --- a/src/settings/plugins/ifnet/Makefile.am +++ b/src/settings/plugins/ifnet/Makefile.am @@ -6,12 +6,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/Makefile.in b/src/settings/plugins/ifnet/Makefile.in index 589f1f22..c6e13316 100644 --- a/src/settings/plugins/ifnet/Makefile.in +++ b/src/settings/plugins/ifnet/Makefile.in @@ -278,7 +278,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -290,8 +289,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -301,6 +298,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -355,16 +353,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -401,6 +396,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -429,7 +426,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -444,6 +440,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -504,6 +502,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -511,6 +510,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -531,12 +531,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 888ee589..51ff9da6 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -25,10 +25,9 @@ #include <arpa/inet.h> #include <stdlib.h> #include <errno.h> -#include <glib/gi18n.h> -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" #include "nm-core-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c index 8f528d0f..ee66ff53 100644 --- a/src/settings/plugins/ifnet/net_parser.c +++ b/src/settings/plugins/ifnet/net_parser.c @@ -26,8 +26,8 @@ #include <sys/ioctl.h> #include <unistd.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "plugin.h" #include "nm-platform.h" diff --git a/src/settings/plugins/ifnet/net_parser.h b/src/settings/plugins/ifnet/net_parser.h index d10979cc..968feaf5 100644 --- a/src/settings/plugins/ifnet/net_parser.h +++ b/src/settings/plugins/ifnet/net_parser.h @@ -22,7 +22,7 @@ #ifndef _NET_PARSER_H #define _NET_PARSER_H -#include <glib.h> +#include "nm-default.h" #define CONF_NET_FILE SYSCONFDIR "/conf.d/net" diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c index adb23c43..1c72e0b2 100644 --- a/src/settings/plugins/ifnet/net_utils.c +++ b/src/settings/plugins/ifnet/net_utils.c @@ -26,11 +26,10 @@ #include <string.h> #include <errno.h> #include <nm-utils.h> -#include <NetworkManagerUtils.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> -#include <nm-config.h> -#include <gio/gio.h> +#include "NetworkManagerUtils.h" +#include <nm-settings-plugin.h> +#include "nm-config.h" +#include "nm-default.h" #include "net_utils.h" #include "wpa_parser.h" #include "net_parser.h" @@ -136,47 +135,6 @@ reload_parsers (void) return TRUE; } -gchar * -read_hostname (const char *path) -{ - gchar *contents = NULL, *result = NULL, *tmp; - gchar **all_lines = NULL; - guint line_num, i; - - if (!g_file_get_contents (path, &contents, NULL, NULL)) - return NULL; - all_lines = g_strsplit (contents, "\n", 0); - line_num = g_strv_length (all_lines); - for (i = 0; i < line_num; i++) { - g_strstrip (all_lines[i]); - if (all_lines[i][0] == '#' || all_lines[i][0] == '\0') - continue; - if (g_str_has_prefix (all_lines[i], "hostname")) { - tmp = strstr (all_lines[i], "="); - tmp++; - result = g_shell_unquote (tmp, NULL); - break; - } - - } - g_strfreev (all_lines); - g_free (contents); - return result; -} - -gboolean -write_hostname (const char *path, const gchar *hostname) -{ - gboolean result; - char *contents; - - contents = g_strdup_printf ("#Generated by NetworkManager\n" - "hostname=\"%s\"\n", hostname); - result = g_file_set_contents (path, contents, -1, NULL); - g_free (contents); - return result; -} - gboolean is_static_ip4 (const char *conn_name) { diff --git a/src/settings/plugins/ifnet/net_utils.h b/src/settings/plugins/ifnet/net_utils.h index d58e7ec6..45969369 100644 --- a/src/settings/plugins/ifnet/net_utils.h +++ b/src/settings/plugins/ifnet/net_utils.h @@ -21,11 +21,11 @@ #ifndef _IFNET_UTILS_H #define _IFNET_UTILS_H -#define IFNET_PLUGIN_NAME "SCPlugin-Ifnet" -#include <glib.h> +#define IFNET_PLUGIN_NAME "SettingsPlugin-Ifnet" #include <arpa/inet.h> #include <nm-setting-ip6-config.h> #include <nm-setting-ip4-config.h> +#include "nm-default.h" #include "net_parser.h" #define has_default_ip4_route(conn_name) has_default_route((conn_name), &is_ip4_address) #define has_default_ip6_route(conn_name) has_default_route((conn_name), &is_ip6_address) @@ -37,8 +37,6 @@ typedef struct _ip_block { struct _ip_block *next; } ip_block; -gchar *read_hostname (const char *path); -gboolean write_hostname (const char *path, const char *hostname); gboolean is_static_ip4 (const char *conn_name); gboolean is_static_ip6 (const char *conn_name); gboolean is_ip4_address (const char *in_address); diff --git a/src/settings/plugins/ifnet/nm-ifnet-connection.c b/src/settings/plugins/ifnet/nm-ifnet-connection.c index 693e6532..450fe931 100644 --- a/src/settings/plugins/ifnet/nm-ifnet-connection.c +++ b/src/settings/plugins/ifnet/nm-ifnet-connection.c @@ -27,8 +27,8 @@ #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "nm-ifnet-connection.h" #include "connection_parser.h" #include "net_parser.h" @@ -50,7 +50,7 @@ static guint signals[IFNET_LAST_SIGNAL] = { 0 }; typedef struct { gchar *conn_name; - NMSystemConfigInterface *config; + NMSettingsPlugin *config; } NMIfnetConnectionPrivate; NMIfnetConnection * @@ -102,8 +102,9 @@ nm_ifnet_connection_get_conn_name (NMIfnetConnection *connection) static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, - gpointer user_data) + gpointer user_data) { GError *error = NULL; NMIfnetConnectionPrivate *priv = NM_IFNET_CONNECTION_GET_PRIVATE (connection); @@ -139,7 +140,7 @@ commit_changes (NMSettingsConnection *connection, g_free (priv->conn_name); priv->conn_name = new_name; - NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, callback, user_data); + NM_SETTINGS_CONNECTION_CLASS (nm_ifnet_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data); nm_log_info (LOGD_SETTINGS, "Successfully updated %s", priv->conn_name); } else { nm_log_warn (LOGD_SETTINGS, "Failed to update %s", diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c index 5eab31ab..b670cdac 100644 --- a/src/settings/plugins/ifnet/plugin.c +++ b/src/settings/plugins/ifnet/plugin.c @@ -25,17 +25,16 @@ #include <string.h> #include <gmodule.h> -#include <glib.h> -#include <gio/gio.h> #include <nm-utils.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "nm-dbus-interface.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" #include "nm-ifnet-connection.h" #include "nm-config.h" +#include "NetworkManagerUtils.h" #include "plugin.h" #include "net_utils.h" @@ -45,19 +44,16 @@ #define IFNET_PLUGIN_NAME_PRINT "ifnet" #define IFNET_PLUGIN_INFO "(C) 1999-2010 Gentoo Foundation, Inc. To report bugs please use bugs.gentoo.org with [networkmanager] or [qiaomuf] prefix." -#define IFNET_SYSTEM_HOSTNAME_FILE "/etc/conf.d/hostname" #define IFNET_MANAGE_WELL_KNOWN_DEFAULT TRUE typedef struct { GHashTable *connections; /* uuid::connection */ - gchar *hostname; gboolean unmanaged_well_known; - GFileMonitor *hostname_monitor; GFileMonitor *net_monitor; GFileMonitor *wpa_monitor; -} SCPluginIfnetPrivate; +} SettingsPluginIfnetPrivate; typedef void (*FileChangedFn) (gpointer user_data); @@ -66,56 +62,17 @@ typedef struct { gpointer user_data; } FileMonitorInfo; -static void system_config_interface_init (NMSystemConfigInterface *class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -static void reload_connections (NMSystemConfigInterface *config); +static void reload_connections (NMSettingsPlugin *config); -G_DEFINE_TYPE_EXTENDED (SCPluginIfnet, sc_plugin_ifnet, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init)) -#define SC_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetPrivate)) -/* -static void -ignore_cb(NMSettingsConnectionInterface * connection, - GError * error, gpointer user_data) -{ -} -*/ -static const char * -get_hostname (NMSystemConfigInterface * config) -{ - return SC_PLUGIN_IFNET_GET_PRIVATE (config)->hostname; -} - -static void -update_system_hostname (gpointer config) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - if (priv->hostname) - g_free (priv->hostname); - priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE); +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfnet, settings_plugin_ifnet, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) +#define SETTINGS_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetPrivate)) - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - nm_log_info (LOGD_SETTINGS, "Hostname updated to: %s", priv->hostname); -} - -static void -write_system_hostname (NMSystemConfigInterface * config, - const gchar * newhostname) -{ - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); - - g_return_if_fail (newhostname); - nm_log_info (LOGD_SETTINGS, "Write system hostname: %s", newhostname); - if (write_hostname (IFNET_SYSTEM_HOSTNAME_FILE, newhostname)) { - g_free (priv->hostname); - priv->hostname = g_strdup (newhostname); - g_object_notify (G_OBJECT (config), - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } else - nm_log_warn (LOGD_SETTINGS, "Write system hostname: %s failed", newhostname); -} +static SettingsPluginIfnet *settings_plugin_ifnet_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfnet, settings_plugin_ifnet_get, SETTINGS_TYPE_PLUGIN_IFNET); static gboolean is_managed_plugin (void) @@ -177,12 +134,9 @@ monitor_file_changes (const char *filename, static void setup_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - priv->hostname_monitor = - monitor_file_changes (IFNET_SYSTEM_HOSTNAME_FILE, - update_system_hostname, user_data); if (nm_config_get_monitor_connection_files (nm_config_get ())) { priv->net_monitor = monitor_file_changes (CONF_NET_FILE, (FileChangedFn) reload_connections, @@ -196,13 +150,9 @@ setup_monitors (NMIfnetConnection * connection, gpointer user_data) static void cancel_monitors (NMIfnetConnection * connection, gpointer user_data) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (user_data); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (user_data); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); - if (priv->hostname_monitor) { - g_file_monitor_cancel (priv->hostname_monitor); - g_object_unref (priv->hostname_monitor); - } if (priv->net_monitor) { g_file_monitor_cancel (priv->net_monitor); g_object_unref (priv->net_monitor); @@ -216,14 +166,14 @@ cancel_monitors (NMIfnetConnection * connection, gpointer user_data) static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } static void -track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) +track_new_connection (SettingsPluginIfnet *self, NMIfnetConnection *connection) { - g_hash_table_insert (SC_PLUGIN_IFNET_GET_PRIVATE (self)->connections, + g_hash_table_insert (SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self)->connections, g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))), g_object_ref (connection)); g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, @@ -232,10 +182,10 @@ track_new_connection (SCPluginIfnet *self, NMIfnetConnection *connection) } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); GList *conn_names = NULL, *n_iter = NULL; gboolean auto_refresh; GError *error = NULL; @@ -293,7 +243,7 @@ reload_connections (NMSystemConfigInterface *config) nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (old)); track_new_connection (self, new); if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } } else { /* Update existing connection with new settings */ @@ -310,11 +260,11 @@ reload_connections (NMSystemConfigInterface *config) nm_log_info (LOGD_SETTINGS, "Connection %s updated", nm_connection_get_id (NM_CONNECTION (new))); } - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } else if (new) { track_new_connection (self, new); if (is_managed_plugin () && is_managed (conn_name)) - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, new); } /* Track all valid connections so we can remove deleted ones later */ @@ -341,12 +291,12 @@ reload_connections (NMSystemConfigInterface *config) } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *source, gboolean save_to_disk, GError **error) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); NMIfnetConnection *new = NULL; /* Ensure we reject attempts to add the connection long before we're @@ -363,7 +313,7 @@ add_connection (NMSystemConfigInterface *config, } else { new = nm_ifnet_connection_new (source, NULL); if (new) { - track_new_connection (SC_PLUGIN_IFNET (config), new); + track_new_connection (SETTINGS_PLUGIN_IFNET (config), new); /* track_new_connection refs 'new' */ g_object_unref (new); } @@ -406,9 +356,9 @@ check_unmanaged (gpointer key, gpointer data, gpointer user_data) } static GSList * -get_unmanaged_specs (NMSystemConfigInterface * config) +get_unmanaged_specs (NMSettingsPlugin * config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *list = NULL; nm_log_info (LOGD_SETTINGS, "getting unmanaged specs..."); @@ -417,10 +367,10 @@ get_unmanaged_specs (NMSystemConfigInterface * config) } static void -init (NMSystemConfigInterface *config) +init (NMSettingsPlugin *config) { - SCPluginIfnet *self = SC_PLUGIN_IFNET (config); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self); + SettingsPluginIfnet *self = SETTINGS_PLUGIN_IFNET (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (self); nm_log_info (LOGD_SETTINGS, "Initializing!"); @@ -431,15 +381,14 @@ init (NMSystemConfigInterface *config) setup_monitors (NULL, config); reload_connections (config); - update_system_hostname (self); nm_log_info (LOGD_SETTINGS, "Initialzation complete!"); } static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (config); GSList *connections = NULL; GHashTableIter iter; NMIfnetConnection *connection; @@ -459,17 +408,17 @@ get_connections (NMSystemConfigInterface *config) } static void -system_config_interface_init (NMSystemConfigInterface *class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - class->init = init; - class->get_connections = get_connections; - class->get_unmanaged_specs = get_unmanaged_specs; - class->add_connection = add_connection; - class->reload_connections = reload_connections; + plugin_iface->init = init; + plugin_iface->get_connections = get_connections; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->add_connection = add_connection; + plugin_iface->reload_connections = reload_connections; } static void -sc_plugin_ifnet_init (SCPluginIfnet * plugin) +settings_plugin_ifnet_init (SettingsPluginIfnet * plugin) { } @@ -477,23 +426,16 @@ static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFNET_PLUGIN_NAME_PRINT); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFNET_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: g_value_set_uint (value, - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS - | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, get_hostname (self)); + NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -506,15 +448,6 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME:{ - const gchar *hostname = g_value_get_string (value); - - if (hostname && strlen (hostname) < 1) - hostname = NULL; - write_system_hostname (NM_SYSTEM_CONFIG_INTERFACE - (object), hostname); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -524,8 +457,8 @@ set_property (GObject * object, guint prop_id, const GValue * value, static void dispose (GObject * object) { - SCPluginIfnet *plugin = SC_PLUGIN_IFNET (object); - SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (plugin); + SettingsPluginIfnet *plugin = SETTINGS_PLUGIN_IFNET (object); + SettingsPluginIfnetPrivate *priv = SETTINGS_PLUGIN_IFNET_GET_PRIVATE (plugin); cancel_monitors (NULL, object); if (priv->connections) { @@ -533,53 +466,37 @@ dispose (GObject * object) priv->connections = NULL; } - g_free (priv->hostname); - priv->hostname = NULL; - ifnet_destroy (); wpa_parser_destroy (); - G_OBJECT_CLASS (sc_plugin_ifnet_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifnet_parent_class)->dispose (object); } static void -sc_plugin_ifnet_class_init (SCPluginIfnetClass * req_class) +settings_plugin_ifnet_class_init (SettingsPluginIfnetClass * req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfnetPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIfnetPrivate)); object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfnet *singleton = NULL; - SCPluginIfnetPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL)); - priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifnet_get ()); } diff --git a/src/settings/plugins/ifnet/plugin.h b/src/settings/plugins/ifnet/plugin.h index 6ac0f482..33dcc201 100644 --- a/src/settings/plugins/ifnet/plugin.h +++ b/src/settings/plugins/ifnet/plugin.h @@ -23,25 +23,25 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_IFNET (sc_plugin_ifnet_get_type ()) -#define SC_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnet)) -#define SC_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) -#define SC_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFNET)) -#define SC_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFNET)) -#define SC_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetClass)) +#define SETTINGS_TYPE_PLUGIN_IFNET (settings_plugin_ifnet_get_type ()) +#define SETTINGS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnet)) +#define SETTINGS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) +#define SETTINGS_IS_PLUGIN_IFNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_IS_PLUGIN_IFNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFNET)) +#define SETTINGS_PLUGIN_IFNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFNET, SettingsPluginIfnetClass)) -typedef struct _SCPluginIfnet SCPluginIfnet; -typedef struct _SCPluginIfnetClass SCPluginIfnetClass; +typedef struct _SettingsPluginIfnet SettingsPluginIfnet; +typedef struct _SettingsPluginIfnetClass SettingsPluginIfnetClass; -struct _SCPluginIfnet { +struct _SettingsPluginIfnet { GObject parent; }; -struct _SCPluginIfnetClass { +struct _SettingsPluginIfnetClass { GObjectClass parent; }; -GType sc_plugin_ifnet_get_type (void); +GType settings_plugin_ifnet_get_type (void); #endif diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index 754bb182..1919f141 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -4,42 +4,43 @@ if ENABLE_TESTS AM_CPPFLAGS= \ -I$(srcdir)/../ \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/platform \ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(CHECK_CFLAGS) \ $(GLIB_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ + -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ + -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ -DSYSCONFDIR=\"nonexistent\" -noinst_PROGRAMS = check_ifnet -check_ifnet_SOURCES = \ - test_all.c \ +noinst_PROGRAMS = test-ifnet +test_ifnet_SOURCES = \ + test-ifnet.c \ ../connection_parser.c \ ../net_parser.c \ ../net_utils.c \ ../wpa_parser.c -check_ifnet_LDFLAGS = \ +test_ifnet_LDFLAGS = \ $(CODE_COVERAGE_LDFLAGS) -check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la -check-local: check_ifnet - $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) +#@VALGRIND_RULES@ +TESTS = test-ifnet endif EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ diff --git a/src/settings/plugins/ifnet/tests/Makefile.in b/src/settings/plugins/ifnet/tests/Makefile.in index d331ecee..1e08b955 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.in +++ b/src/settings/plugins/ifnet/tests/Makefile.in @@ -88,7 +88,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@ENABLE_TESTS_TRUE@noinst_PROGRAMS = check_ifnet$(EXEEXT) +@ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-ifnet$(EXEEXT) +@ENABLE_TESTS_TRUE@TESTS = test-ifnet$(EXEEXT) subdir = src/settings/plugins/ifnet/tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ @@ -112,22 +113,22 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am__check_ifnet_SOURCES_DIST = test_all.c ../connection_parser.c \ +am__test_ifnet_SOURCES_DIST = test-ifnet.c ../connection_parser.c \ ../net_parser.c ../net_utils.c ../wpa_parser.c -@ENABLE_TESTS_TRUE@am_check_ifnet_OBJECTS = test_all.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@am_test_ifnet_OBJECTS = test-ifnet.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ connection_parser.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ net_parser.$(OBJEXT) net_utils.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ wpa_parser.$(OBJEXT) -check_ifnet_OBJECTS = $(am_check_ifnet_OBJECTS) -@ENABLE_TESTS_TRUE@check_ifnet_DEPENDENCIES = \ +test_ifnet_OBJECTS = $(am_test_ifnet_OBJECTS) +@ENABLE_TESTS_TRUE@test_ifnet_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -check_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ +test_ifnet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(check_ifnet_LDFLAGS) $(LDFLAGS) -o $@ + $(test_ifnet_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -162,8 +163,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(check_ifnet_SOURCES) -DIST_SOURCES = $(am__check_ifnet_SOURCES_DIST) +SOURCES = $(test_ifnet_SOURCES) +DIST_SOURCES = $(am__test_ifnet_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -188,8 +189,212 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +AM_RECURSIVE_TARGETS = check recheck +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp + $(top_srcdir)/build-aux/depcomp \ + $(top_srcdir)/build-aux/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ @@ -206,7 +411,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -218,8 +422,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -229,6 +431,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -283,16 +486,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -329,6 +529,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -357,7 +559,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -372,6 +573,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -432,6 +635,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -439,6 +643,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -456,35 +661,36 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/platform \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifnet"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(CHECK_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ +@ENABLE_TESTS_TRUE@ -DTEST_IFNET_DIR=\"$(abs_srcdir)\" \ +@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/\" \ @ENABLE_TESTS_TRUE@ -DTEST_WPA_SUPPLICANT_CONF='"$(srcdir)/wpa_supplicant.conf"' \ @ENABLE_TESTS_TRUE@ -DSYSCONFDIR=\"nonexistent\" -@ENABLE_TESTS_TRUE@check_ifnet_SOURCES = \ -@ENABLE_TESTS_TRUE@ test_all.c \ +@ENABLE_TESTS_TRUE@test_ifnet_SOURCES = \ +@ENABLE_TESTS_TRUE@ test-ifnet.c \ @ENABLE_TESTS_TRUE@ ../connection_parser.c \ @ENABLE_TESTS_TRUE@ ../net_parser.c \ @ENABLE_TESTS_TRUE@ ../net_utils.c \ @ENABLE_TESTS_TRUE@ ../wpa_parser.c -@ENABLE_TESTS_TRUE@check_ifnet_LDFLAGS = \ +@ENABLE_TESTS_TRUE@test_ifnet_LDFLAGS = \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) -@ENABLE_TESTS_TRUE@check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la +@ENABLE_TESTS_TRUE@test_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la EXTRA_DIST = \ - hostname \ net \ net.all \ nm-system-settings.conf \ @@ -494,7 +700,7 @@ EXTRA_DIST = \ all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -534,9 +740,9 @@ clean-noinstPROGRAMS: echo " rm -f" $$list; \ rm -f $$list -check_ifnet$(EXEEXT): $(check_ifnet_OBJECTS) $(check_ifnet_DEPENDENCIES) $(EXTRA_check_ifnet_DEPENDENCIES) - @rm -f check_ifnet$(EXEEXT) - $(AM_V_CCLD)$(check_ifnet_LINK) $(check_ifnet_OBJECTS) $(check_ifnet_LDADD) $(LIBS) +test-ifnet$(EXEEXT): $(test_ifnet_OBJECTS) $(test_ifnet_DEPENDENCIES) $(EXTRA_test_ifnet_DEPENDENCIES) + @rm -f test-ifnet$(EXEEXT) + $(AM_V_CCLD)$(test_ifnet_LINK) $(test_ifnet_OBJECTS) $(test_ifnet_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -547,7 +753,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_all.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ifnet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wpa_parser.Po@am__quote@ .c.o: @@ -685,6 +891,169 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +test-ifnet.log: test-ifnet$(EXEEXT) + @p='test-ifnet$(EXEEXT)'; \ + b='test-ifnet'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -715,9 +1084,8 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -@ENABLE_TESTS_FALSE@check-local: check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -741,6 +1109,9 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -824,7 +1195,7 @@ uninstall-am: .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \ +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ @@ -836,16 +1207,13 @@ uninstall-am: installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am + recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile @ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ -@ENABLE_TESTS_TRUE@check-local: check_ifnet -@ENABLE_TESTS_TRUE@ $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/settings/plugins/ifnet/tests/hostname b/src/settings/plugins/ifnet/tests/hostname deleted file mode 100644 index 25c76165..00000000 --- a/src/settings/plugins/ifnet/tests/hostname +++ /dev/null @@ -1,2 +0,0 @@ -#Generated by NetworkManager -hostname="gentoo" diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test-ifnet.c index 55e7e283..96fb5dd3 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test-ifnet.c @@ -24,14 +24,13 @@ #include <stdio.h> #include <string.h> -#include <glib.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <nm-utils.h> +#include "nm-default.h" #include "nm-linux-platform.h" -#include "nm-logging.h" #include "net_parser.h" #include "net_utils.h" @@ -59,82 +58,38 @@ nm_config_get_dhcp_client (NMConfig *config) static void test_getdata (void) { - ASSERT (ifnet_get_data ("eth1", "config") - && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0, - "get data", "config_eth1 is not correct"); - ASSERT (ifnet_get_data ("ppp0", "username") - && strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0, - "get data", "config_ppp0 username is not correctly read"); - ASSERT (ifnet_get_data ("ppp0", "password") - && strcmp (ifnet_get_data ("ppp0", "password"), - "password") == 0, "get data", - "config_ppp0 password is not correctly read"); - ASSERT (ifnet_get_global_data ("modules") - && strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0, - "get data", "config_eth1 is not correct"); -} - -static void -test_read_hostname (const char *base_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (base_path, "hostname", NULL); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo"); - - g_free (hostname); - g_free (hostname_path); -} - -static void -test_write_hostname (const char *temp_path) -{ - char *hostname_path, *hostname; - - hostname_path = g_build_filename (temp_path, "hostname-test", NULL); - write_hostname (hostname_path, "gentoo-nm"); - hostname = read_hostname (hostname_path); - - g_assert_cmpstr (hostname, ==, "gentoo-nm"); - - g_free (hostname); - unlink (hostname_path); - g_free (hostname_path); + g_assert (ifnet_get_data ("eth1", "config") && + strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0); + g_assert (ifnet_get_data ("ppp0", "username") && + strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0); + g_assert (ifnet_get_data ("ppp0", "password") && + strcmp (ifnet_get_data ("ppp0", "password"), "password") == 0); + g_assert (ifnet_get_global_data ("modules") && + strcmp ("!wpa_supplicant", ifnet_get_global_data ("modules")) == 0); } static void test_is_static (void) { - ASSERT (is_static_ip4 ("eth1") == FALSE, "is static", - "a dhcp interface is recognized as static"); - ASSERT (is_static_ip4 ("eth0") == TRUE, "is static", - "a static interface is recognized as dhcp"); - ASSERT (is_static_ip6 ("eth0") == FALSE, "is static", - "a dhcp interface is recognized as static"); + g_assert (!is_static_ip4 ("eth1")); + g_assert (is_static_ip4 ("eth0")); + g_assert (!is_static_ip6 ("eth0")); } static void test_has_default_route (void) { - ASSERT (has_default_ip4_route ("eth0"), - "has default route", "eth0 should have a default ipv4 route"); - ASSERT (has_default_ip6_route ("eth4"), - "has default route", "eth4 should have a default ipv6 route"); - ASSERT (!has_default_ip4_route ("eth5") - && !has_default_ip6_route ("eth5"), - "has default route", "eth5 shouldn't have a default route"); + g_assert (has_default_ip4_route ("eth0")); + g_assert (has_default_ip6_route ("eth4")); + g_assert (!has_default_ip4_route ("eth5") && + !has_default_ip6_route ("eth5")); } static void test_has_ip6_address (void) { - ASSERT (has_ip6_address ("eth2"), "has ip6 address", - "eth2 should have a ipv6 address"); - ASSERT (!has_ip6_address ("eth0"), "has ip6 address", - "eth0 shouldn't have a ipv6 address") - + g_assert (has_ip6_address ("eth2")); + g_assert (!has_ip6_address ("eth0")); } static void @@ -144,12 +99,9 @@ test_is_ip4_address (void) gchar *address2 = "192.168.100.{1..254}/24"; gchar *address3 = "192.168.4.2555/24"; - ASSERT (is_ip4_address (address1), "is ip4 address", - "%s should be a valid address", address1); - ASSERT (is_ip4_address (address2), "is ip4 address", - "%s should be a valid address", address2); - ASSERT (!is_ip4_address (address3), "is ip4 address", - "%s should be an invalid address", address3); + g_assert (is_ip4_address (address1)); + g_assert (is_ip4_address (address2)); + g_assert (!is_ip4_address (address3)); } static void @@ -157,19 +109,15 @@ test_is_ip6_address (void) { gchar *address1 = "4321:0:1:2:3:4:567:89ac/24"; - ASSERT (is_ip6_address (address1), "is ip6 address", - "%s should be a valid address", address1); + g_assert (is_ip6_address (address1)); } static void check_ip_block (ip_block * iblock, gchar * ip, guint32 prefix, gchar * gateway) { - ASSERT (strcmp (ip, iblock->ip) == 0, "check ip", - "ip expected:%s, find:%s", ip, iblock->ip); - ASSERT (prefix == iblock->prefix, "check netmask", - "prefix expected:%d, find:%d", prefix, iblock->prefix); - ASSERT (g_strcmp0 (gateway, iblock->next_hop) == 0, "check gateway", - "gateway expected:%s, find:%s", gateway, iblock->next_hop); + g_assert_cmpstr (ip, ==, iblock->ip); + g_assert (prefix == iblock->prefix); + g_assert_cmpstr (gateway, ==, iblock->next_hop); } static void @@ -178,13 +126,11 @@ test_convert_ipv4_config_block (void) ip_block *iblock = convert_ip4_config_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should not be NULL"); + g_assert (iblock != NULL); check_ip_block (iblock, "202.117.16.121", 24, "202.117.16.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock != NULL, "convert ipv4 block", - "block eth0 should have a second IP address"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.121", 24, "202.117.16.1"); destroy_ip_block (iblock); @@ -192,17 +138,14 @@ test_convert_ipv4_config_block (void) "*Can't handle IPv4 address*202.117.16.1211*"); iblock = convert_ip4_config_block ("eth2"); g_test_assert_expected_messages (); - ASSERT (iblock != NULL - && iblock->next == NULL, - "convert error IPv4 address", "should only get one address"); + g_assert (iblock != NULL && iblock->next == NULL); check_ip_block (iblock, "192.168.4.121", 24, NULL); destroy_ip_block (iblock); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, "*missing netmask or prefix*"); iblock = convert_ip4_config_block ("eth3"); - ASSERT (iblock == NULL, "convert config_block", - "convert error configuration"); + g_assert (iblock == NULL); } static void @@ -211,22 +154,20 @@ test_convert_ipv4_routes_block (void) ip_block *iblock = convert_ip4_routes_block ("eth0"); ip_block *tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "192.168.4.0", 24, "192.168.4.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); iblock = convert_ip4_routes_block ("eth9"); tmp = iblock; - ASSERT (iblock != NULL, "convert ip4 routes", "should get one route"); + g_assert (iblock != NULL); check_ip_block (iblock, "10.0.0.0", 8, "192.168.0.1"); iblock = iblock->next; destroy_ip_block (tmp); - ASSERT (iblock == NULL, "convert ip4 routes", - "should only get one route"); + g_assert (iblock == NULL); } static void @@ -258,19 +199,15 @@ test_strip_string (void) result = strip_string (result, '('); result = strip_string (result, ')'); result = strip_string (result, '"'); - ASSERT (strcmp (result, "default via 202.117.16.1") == - 0, "strip_string", - "string isn't stripped, result is: %s", result); + g_assert_cmpstr (result, ==, "default via 202.117.16.1"); g_free (result_b); } static void test_is_unmanaged (void) { - ASSERT (is_managed ("eth0"), "test_is_unmanaged", - "eth0 should be managed"); - ASSERT (!is_managed ("eth4"), "test_is_unmanaged", - "eth4 should be unmanaged"); + g_assert (is_managed ("eth0")); + g_assert (!is_managed ("eth4")); } static void @@ -285,33 +222,23 @@ test_new_connection (void) "*Can't handle IPv6 address*202.117.16.1211*"); connection = ifnet_update_connection_from_config_block ("eth2", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("myxjtu2", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth9", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth9) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("eth10", NULL, &error); - ASSERT (connection != NULL, "new connection", - "new connection(eth10) failed: %s", - error ? error->message : "NONE"); + g_assert (connection != NULL); g_object_unref (connection); } @@ -329,17 +256,16 @@ kill_backup (char **path) #define SUP_GEN_NAME "wpa_supplicant.conf.generate" static void -test_update_connection (const char *basepath) +test_update_connection (void) { GError *error = NULL; NMConnection *connection; gboolean success; char *backup = NULL; + char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "eth0", NET_GEN_NAME, @@ -348,12 +274,11 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "eth0"); + g_assert (success); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("0xab3ace", basepath, &error); - ASSERT (connection != NULL, "get connection", "get connection failed: %s", - error ? error->message : "None"); + g_assert (connection != NULL); success = ifnet_update_parsers_by_connection (connection, "0xab3ace", NET_GEN_NAME, @@ -362,7 +287,7 @@ test_update_connection (const char *basepath) &backup, &error); kill_backup (&backup); - ASSERT (success, "update connection", "update connection failed %s", "0xab3ace"); + g_assert (success); g_object_unref (connection); unlink (NET_GEN_NAME); @@ -370,14 +295,14 @@ test_update_connection (const char *basepath) } static void -test_add_connection (const char *basepath) +test_add_connection (void) { NMConnection *connection; char *backup = NULL; + const char *basepath = TEST_IFNET_DIR; connection = ifnet_update_connection_from_config_block ("eth0", basepath, NULL); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "eth0"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -387,8 +312,7 @@ test_add_connection (const char *basepath) "*Can't handle ipv4 address: 202.117.16.255, missing netmask or prefix*"); connection = ifnet_update_connection_from_config_block ("myxjtu2", basepath, NULL); g_test_assert_expected_messages (); - ASSERT (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL), - "add connection", "add connection failed: %s", "myxjtu2"); + g_assert (ifnet_add_new_connection (connection, NET_GEN_NAME, SUP_GEN_NAME, NULL, &backup, NULL)); kill_backup (&backup); g_object_unref (connection); @@ -404,20 +328,14 @@ test_delete_connection (void) char *backup = NULL; connection = ifnet_update_connection_from_config_block ("eth7", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "eth7"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("eth7", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); connection = ifnet_update_connection_from_config_block ("qiaomuf", NULL, &error); - ASSERT (connection != NULL, "get connection", - "get connection failed: %s", - error ? error->message : "None"); - ASSERT (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup), - "delete connection", "delete connection failed: %s", "qiaomuf"); + g_assert (connection != NULL); + g_assert (ifnet_delete_connection_in_parsers ("qiaomuf", NET_GEN_NAME, SUP_GEN_NAME, &backup)); kill_backup (&backup); g_object_unref (connection); @@ -435,54 +353,46 @@ test_missing_config (void) "*Unknown config for eth8*"); connection = ifnet_update_connection_from_config_block ("eth8", NULL, &error); g_test_assert_expected_messages (); - ASSERT (connection == NULL && error != NULL, "get connection", - "get connection should fail with 'Unknown config for eth8'"); + g_assert (connection == NULL && error != NULL); } NMTST_DEFINE (); +#define TPATH "/settings/plugins/ifnet/" + int main (int argc, char **argv) { - char *f; + int ret; nm_linux_platform_setup (); nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); - f = g_build_filename (argv[1], "net", NULL); - ifnet_init (f); - g_free (f); - - f = g_build_filename (argv[1], "wpa_supplicant.conf", NULL); - wpa_parser_init (f); - g_free (f); - - test_strip_string (); - test_is_static (); - test_has_ip6_address (); - test_has_default_route (); - test_getdata (); - test_read_hostname (argv[1]); - test_write_hostname (argv[2]); - test_is_ip4_address (); - test_is_ip6_address (); - test_convert_ipv4_config_block (); - test_convert_ipv4_routes_block (); - test_is_unmanaged (); - test_wpa_parser (); - test_convert_ipv4_routes_block (); - test_new_connection (); - test_update_connection (argv[1]); - test_add_connection (argv[1]); - test_delete_connection (); - test_missing_config (); + ifnet_init (TEST_IFNET_DIR "/net"); + wpa_parser_init (TEST_IFNET_DIR "/wpa_supplicant.conf"); + + g_test_add_func (TPATH "strip-string", test_strip_string); + g_test_add_func (TPATH "is-static", test_is_static); + g_test_add_func (TPATH "has-ip6-address", test_has_ip6_address); + g_test_add_func (TPATH "has-default-route", test_has_default_route); + g_test_add_func (TPATH "get-data", test_getdata); + g_test_add_func (TPATH "is-ip4-address", test_is_ip4_address); + g_test_add_func (TPATH "is-ip6-address", test_is_ip6_address); + g_test_add_func (TPATH "convert-ip4-config", test_convert_ipv4_config_block); + g_test_add_func (TPATH "convert-ip4-routes", test_convert_ipv4_routes_block); + g_test_add_func (TPATH "is-unmanaged", test_is_unmanaged); + g_test_add_func (TPATH "wpa-parser", test_wpa_parser); + g_test_add_func (TPATH "new-connection", test_new_connection); + g_test_add_func (TPATH "update-connection", test_update_connection); + g_test_add_func (TPATH "add-connection", test_add_connection); + g_test_add_func (TPATH "delete-connection", test_delete_connection); + g_test_add_func (TPATH "missing-config", test_missing_config); + + ret = g_test_run (); ifnet_destroy (); wpa_parser_destroy (); - f = g_path_get_basename (argv[0]); - fprintf (stdout, "%s: SUCCESS\n", f); - g_free (f); - return 0; + return ret; } diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c index 3f912da8..9f228d0b 100644 --- a/src/settings/plugins/ifnet/wpa_parser.c +++ b/src/settings/plugins/ifnet/wpa_parser.c @@ -23,8 +23,8 @@ #include <string.h> #include <stdlib.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "wpa_parser.h" #include "net_parser.h" #include "net_utils.h" diff --git a/src/settings/plugins/ifnet/wpa_parser.h b/src/settings/plugins/ifnet/wpa_parser.h index 3a0d377e..8099d19c 100644 --- a/src/settings/plugins/ifnet/wpa_parser.h +++ b/src/settings/plugins/ifnet/wpa_parser.h @@ -22,7 +22,7 @@ #ifndef _WPA_PARSER_H #define _WPA_PARSER_H -#include <glib.h> +#include "nm-default.h" #define WPA_SUPPLICANT_CONF SYSCONFDIR "/wpa_supplicant/wpa_supplicant.conf" diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am index e1f2b339..c5c645d3 100644 --- a/src/settings/plugins/ifupdown/Makefile.am +++ b/src/settings/plugins/ifupdown/Makefile.am @@ -5,12 +5,12 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in index 3bd19afc..b16c3053 100644 --- a/src/settings/plugins/ifupdown/Makefile.in +++ b/src/settings/plugins/ifupdown/Makefile.in @@ -277,7 +277,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -289,8 +288,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -300,6 +297,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -354,16 +352,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -400,6 +395,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -428,7 +425,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -443,6 +439,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -503,6 +501,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -510,6 +509,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -529,12 +529,12 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ diff --git a/src/settings/plugins/ifupdown/interface_parser.c b/src/settings/plugins/ifupdown/interface_parser.c index 32d27c57..4606f5ab 100644 --- a/src/settings/plugins/ifupdown/interface_parser.c +++ b/src/settings/plugins/ifupdown/interface_parser.c @@ -29,7 +29,7 @@ #include <wordexp.h> #include <libgen.h> #include "nm-utils.h" -#include "nm-logging.h" +#include "nm-default.h" if_block* first; if_block* last; diff --git a/src/settings/plugins/ifupdown/interface_parser.h b/src/settings/plugins/ifupdown/interface_parser.h index e68abcf6..4034d44c 100644 --- a/src/settings/plugins/ifupdown/interface_parser.h +++ b/src/settings/plugins/ifupdown/interface_parser.h @@ -24,7 +24,7 @@ #ifndef _INTERFACE_PARSER_H #define _INTERFACE_PARSER_H -#include <glib.h> +#include "nm-default.h" typedef struct _if_data { diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c index c6073bd7..2c8504b0 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -29,8 +29,8 @@ #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> -#include <nm-system-config-interface.h> -#include <nm-logging.h> +#include <nm-settings-plugin.h> +#include "nm-default.h" #include "nm-ifupdown-connection.h" #include "parser.h" diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h index be2ebc0a..54c219f4 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h @@ -25,6 +25,7 @@ #define __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ #include <nm-settings-connection.h> +#include "nm-default.h" #include "interface_parser.h" G_BEGIN_DECLS diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 15081a4c..8a3d4551 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -30,8 +30,8 @@ #include <ctype.h> #include "nm-core-internal.h" -#include "nm-system-config-interface.h" -#include "nm-logging.h" +#include "nm-settings-plugin.h" +#include "nm-default.h" #include "parser.h" #include "plugin.h" diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c index 8652dd8d..fc361de5 100644 --- a/src/settings/plugins/ifupdown/plugin.c +++ b/src/settings/plugins/ifupdown/plugin.c @@ -25,32 +25,27 @@ #include "config.h" #include <string.h> -#include <sys/inotify.h> - #include <gmodule.h> -#include <glib-object.h> -#include <glib/gi18n.h> -#include <glib.h> #include <nm-setting-connection.h> +#include "nm-default.h" #include "interface_parser.h" #include "nm-dbus-interface.h" -#include "nm-system-config-interface.h" +#include "nm-settings-plugin.h" #include "nm-setting-ip4-config.h" #include "nm-setting-wireless.h" #include "nm-setting-wired.h" #include "nm-setting-ppp.h" #include "nm-utils.h" #include "nm-core-internal.h" +#include "NetworkManagerUtils.h" #include "nm-ifupdown-connection.h" #include "plugin.h" #include "parser.h" -#include "nm-inotify-helper.h" -#include "nm-logging.h" #include "nm-config.h" #include <arpa/inet.h> @@ -61,7 +56,6 @@ #define IFUPDOWN_PLUGIN_NAME "ifupdown" #define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list." -#define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname" #define IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT TRUE @@ -74,7 +68,6 @@ typedef struct { GUdevClient *client; GHashTable *connections; /* /e/n/i block name :: NMIfupdownConnection */ - gchar* hostname; /* Stores all blocks/interfaces read from /e/n/i regardless of whether * there is an NMIfupdownConnection for block. @@ -85,31 +78,31 @@ typedef struct { GHashTable *kernel_ifaces; gboolean unmanage_well_known; - - gulong inotify_event_id; - int inotify_system_hostname_wd; -} SCPluginIfupdownPrivate; +} SettingsPluginIfupdownPrivate; static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); + +G_DEFINE_TYPE_EXTENDED (SettingsPluginIfupdown, settings_plugin_ifupdown, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -G_DEFINE_TYPE_EXTENDED (SCPluginIfupdown, sc_plugin_ifupdown, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +#define SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownPrivate)) -#define SC_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownPrivate)) +static SettingsPluginIfupdown *settings_plugin_ifupdown_get (void); +NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfupdown, settings_plugin_ifupdown_get, SETTINGS_TYPE_PLUGIN_IFUPDOWN); static void -sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class); +settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class); static void -SCPluginIfupdown_init (NMSystemConfigInterface *config); +SettingsPluginIfupdown_init (NMSettingsPlugin *config); /* Returns the plugins currently known list of connections. The returned * list is freed by the system settings service. */ static GSList* -SCPluginIfupdown_get_connections (NMSystemConfigInterface *config); +SettingsPluginIfupdown_get_connections (NMSettingsPlugin *config); /* * Return a list of device specifications which NetworkManager should not @@ -117,7 +110,7 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config); * each element must be allocated using g_malloc() or its variants. */ static GSList* -SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config); +SettingsPluginIfupdown_get_unmanaged_specs (NMSettingsPlugin *config); /* GObject */ @@ -132,56 +125,40 @@ GObject__set_property (GObject *object, guint prop_id, static void GObject__dispose (GObject *object); -/* other helpers */ -static const char * -get_hostname (NMSystemConfigInterface *config); - - -static void -update_system_hostname(NMInotifyHelper *inotify_helper, - struct inotify_event *evt, - const char *path, - NMSystemConfigInterface *config); - - static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { - system_config_interface_class->init = SCPluginIfupdown_init; - system_config_interface_class->get_connections = SCPluginIfupdown_get_connections; - system_config_interface_class->get_unmanaged_specs = SCPluginIfupdown_get_unmanaged_specs; + plugin_iface->init = SettingsPluginIfupdown_init; + plugin_iface->get_connections = SettingsPluginIfupdown_get_connections; + plugin_iface->get_unmanaged_specs = SettingsPluginIfupdown_get_unmanaged_specs; } static void -sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class) +settings_plugin_ifupdown_class_init (SettingsPluginIfupdownClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginIfupdownPrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginIfupdownPrivate)); object_class->dispose = GObject__dispose; object_class->get_property = GObject__get_property; object_class->set_property = GObject__set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -bind_device_to_connection (SCPluginIfupdown *self, +bind_device_to_connection (SettingsPluginIfupdown *self, GUdevDevice *device, NMIfupdownConnection *exported) { @@ -217,13 +194,13 @@ bind_device_to_connection (SCPluginIfupdown *self, g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL); } - nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NULL, NULL); + nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, NULL); } static void -udev_device_added (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_added (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; NMIfupdownConnection *exported; @@ -250,13 +227,13 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device) bind_device_to_connection (self, device, exported); if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_removed (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; iface = g_udev_device_get_name (device); @@ -270,13 +247,13 @@ udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device) return; if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -udev_device_changed (SCPluginIfupdown *self, GUdevDevice *device) +udev_device_changed (SettingsPluginIfupdown *self, GUdevDevice *device) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); const char *iface, *path; iface = g_udev_device_get_name (device); @@ -290,7 +267,7 @@ udev_device_changed (SCPluginIfupdown *self, GUdevDevice *device) return; if (ALWAYS_UNMANAGE || priv->unmanage_well_known) - g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); + g_signal_emit_by_name (G_OBJECT (self), NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void @@ -299,7 +276,7 @@ handle_uevent (GUdevClient *client, GUdevDevice *device, gpointer user_data) { - SCPluginIfupdown *self = SC_PLUGIN_IFUPDOWN (user_data); + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (user_data); const char *subsys; g_return_if_fail (action != NULL); @@ -318,13 +295,12 @@ handle_uevent (GUdevClient *client, } static void -SCPluginIfupdown_init (NMSystemConfigInterface *config) +SettingsPluginIfupdown_init (NMSettingsPlugin *config) { - SCPluginIfupdown *self = SC_PLUGIN_IFUPDOWN (config); - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self); + SettingsPluginIfupdown *self = SETTINGS_PLUGIN_IFUPDOWN (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (self); GHashTable *auto_ifaces; if_block *block = NULL; - NMInotifyHelper *inotify_helper; GList *keys, *iter; GHashTableIter con_iter; const char *block_name; @@ -350,17 +326,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) } else g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self); - inotify_helper = nm_inotify_helper_get (); - priv->inotify_event_id = g_signal_connect (inotify_helper, - "event", - G_CALLBACK (update_system_hostname), - config); - - priv->inotify_system_hostname_wd = - nm_inotify_helper_add_watch (inotify_helper, IFUPDOWN_SYSTEM_HOSTNAME_FILE); - - update_system_hostname (inotify_helper, NULL, NULL, config); - /* Read in all the interfaces */ ifparser_init (ENI_INTERFACES_FILE, 0); block = ifparser_getfirst (); @@ -471,7 +436,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) { g_signal_emit_by_name (self, - NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, + NM_SETTINGS_PLUGIN_CONNECTION_ADDED, NM_SETTINGS_CONNECTION (cl_iter->data)); } g_list_free (con_list); @@ -485,9 +450,9 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config) * list is freed by the system settings service. */ static GSList* -SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) +SettingsPluginIfupdown_get_connections (NMSettingsPlugin *config) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); GSList *connections; nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config)); @@ -509,9 +474,9 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) * each element must be allocated using g_malloc() or its variants. */ static GSList* -SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config) +SettingsPluginIfupdown_get_unmanaged_specs (NMSettingsPlugin *config) { - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (config); GSList *specs = NULL; GHashTableIter iter; GUdevDevice *device; @@ -536,78 +501,8 @@ SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config) return specs; } - -static const char * -get_hostname (NMSystemConfigInterface *config) -{ - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - return priv->hostname; -} - static void -update_system_hostname(NMInotifyHelper *inotify_helper, - struct inotify_event *evt, - const char *path, - NMSystemConfigInterface *config) -{ - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - gchar *hostname_file = NULL; - gsize hostname_file_len = 0; - GError *error = NULL; - - nm_log_info (LOGD_SETTINGS, "update_system_hostname"); - - if (evt && evt->wd != priv->inotify_system_hostname_wd) - return; - - if(!g_file_get_contents ( IFUPDOWN_SYSTEM_HOSTNAME_FILE, - &hostname_file, - &hostname_file_len, - &error)) { - nm_log_warn (LOGD_SETTINGS, "update_system_hostname() - couldn't read " - IFUPDOWN_SYSTEM_HOSTNAME_FILE " (%d/%s)", - error->code, error->message); - return; - } - - g_free(priv->hostname); - priv->hostname = g_strstrip(hostname_file); - - /* We shouldn't return a zero-length hostname, but NULL */ - if (priv->hostname && !strlen (priv->hostname)) { - g_free (priv->hostname); - priv->hostname = NULL; - } - - g_object_notify (G_OBJECT (config), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - -static void -write_system_hostname(NMSystemConfigInterface *config, - const char *newhostname) -{ - GError *error = NULL; - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - nm_log_info (LOGD_SETTINGS, "write_system_hostname: %s", newhostname); - - g_return_if_fail (newhostname); - - if(!g_file_set_contents ( IFUPDOWN_SYSTEM_HOSTNAME_FILE, - newhostname, - -1, - &error)) { - nm_log_warn (LOGD_SETTINGS, "update_system_hostname() - couldn't write hostname (%s) to " - IFUPDOWN_SYSTEM_HOSTNAME_FILE " (%d/%s)", - newhostname, error->code, error->message); - } else { - priv->hostname = g_strdup (newhostname); - } - g_object_notify (G_OBJECT (config), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); -} - - -static void -sc_plugin_ifupdown_init (SCPluginIfupdown *plugin) +settings_plugin_ifupdown_init (SettingsPluginIfupdown *plugin) { } @@ -615,23 +510,16 @@ static void GObject__get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSystemConfigInterface *self = NM_SYSTEM_CONFIG_INTERFACE (object); - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, IFUPDOWN_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, IFUPDOWN_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_NONE); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - { - g_value_set_string (value, get_hostname(self)); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -643,15 +531,6 @@ GObject__set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - { - const gchar *hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - write_system_hostname(NM_SYSTEM_CONFIG_INTERFACE(object), - hostname); - break; - } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -661,14 +540,8 @@ GObject__set_property (GObject *object, guint prop_id, static void GObject__dispose (GObject *object) { - SCPluginIfupdown *plugin = SC_PLUGIN_IFUPDOWN (object); - SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (plugin); - NMInotifyHelper *inotify_helper = nm_inotify_helper_get (); - - g_signal_handler_disconnect (inotify_helper, priv->inotify_event_id); - - if (priv->inotify_system_hostname_wd >= 0) - nm_inotify_helper_remove_watch (inotify_helper, priv->inotify_system_hostname_wd); + SettingsPluginIfupdown *plugin = SETTINGS_PLUGIN_IFUPDOWN (object); + SettingsPluginIfupdownPrivate *priv = SETTINGS_PLUGIN_IFUPDOWN_GET_PRIVATE (plugin); if (priv->kernel_ifaces) g_hash_table_destroy(priv->kernel_ifaces); @@ -680,21 +553,12 @@ GObject__dispose (GObject *object) g_object_unref (priv->client); - G_OBJECT_CLASS (sc_plugin_ifupdown_parent_class)->dispose (object); + G_OBJECT_CLASS (settings_plugin_ifupdown_parent_class)->dispose (object); } G_MODULE_EXPORT GObject * -nm_system_config_factory (void) +nm_settings_plugin_factory (void) { - static SCPluginIfupdown *singleton = NULL; - SCPluginIfupdownPrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_IFUPDOWN (g_object_new (SC_TYPE_PLUGIN_IFUPDOWN, NULL)); - priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_ref (settings_plugin_ifupdown_get ()); } diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h index 943b8b9f..090178f2 100644 --- a/src/settings/plugins/ifupdown/plugin.h +++ b/src/settings/plugins/ifupdown/plugin.h @@ -24,28 +24,28 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" #define PLUGIN_NAME "ifupdown" -#define SC_TYPE_PLUGIN_IFUPDOWN (sc_plugin_ifupdown_get_type ()) -#define SC_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdown)) -#define SC_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownClass)) -#define SC_IS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_IFUPDOWN)) -#define SC_IS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_IFUPDOWN)) -#define SC_PLUGIN_IFUPDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownClass)) +#define SETTINGS_TYPE_PLUGIN_IFUPDOWN (settings_plugin_ifupdown_get_type ()) +#define SETTINGS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdown)) +#define SETTINGS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) +#define SETTINGS_IS_PLUGIN_IFUPDOWN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) +#define SETTINGS_IS_PLUGIN_IFUPDOWN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_IFUPDOWN)) +#define SETTINGS_PLUGIN_IFUPDOWN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_IFUPDOWN, SettingsPluginIfupdownClass)) -typedef struct _SCPluginIfupdown SCPluginIfupdown; -typedef struct _SCPluginIfupdownClass SCPluginIfupdownClass; +typedef struct _SettingsPluginIfupdown SettingsPluginIfupdown; +typedef struct _SettingsPluginIfupdownClass SettingsPluginIfupdownClass; -struct _SCPluginIfupdown { +struct _SettingsPluginIfupdown { GObject parent; }; -struct _SCPluginIfupdownClass { +struct _SettingsPluginIfupdownClass { GObjectClass parent; }; -GType sc_plugin_ifupdown_get_type (void); +GType settings_plugin_ifupdown_get_type (void); #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.am b/src/settings/plugins/ifupdown/tests/Makefile.am index 4ae44a0b..29e9a7ed 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ b/src/settings/plugins/ifupdown/tests/Makefile.am @@ -1,15 +1,15 @@ if ENABLE_TESTS AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ -DTEST_ENI_DIR=\"$(abs_srcdir)\" diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in index 2387a257..8ad1c0ab 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ b/src/settings/plugins/ifupdown/tests/Makefile.in @@ -406,7 +406,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -418,8 +417,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -429,6 +426,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -483,16 +481,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -529,6 +524,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -557,7 +554,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -572,6 +568,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -632,6 +630,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -639,6 +638,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -655,15 +655,15 @@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DTEST_ENI_DIR=\"$(abs_srcdir)\" diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 1c100ac2..24e8afdc 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -20,11 +20,10 @@ #include "config.h" -#include <glib.h> #include <string.h> +#include "nm-default.h" #include "nm-core-internal.h" -#include "nm-logging.h" #include "interface_parser.h" #include "parser.h" @@ -844,16 +843,12 @@ test20_source_stanza (const char *path) expected_free (e); } +NMTST_DEFINE (); + int main (int argc, char **argv) { -#if !GLIB_CHECK_VERSION (2, 35, 0) - g_type_init (); -#endif - - nm_logging_setup ("WARN", "DEFAULT", NULL, NULL); - - g_test_init (&argc, &argv, NULL); + nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT"); if (0) dump_blocks (); diff --git a/src/settings/plugins/keyfile/Makefile.am b/src/settings/plugins/keyfile/Makefile.am index 919b0805..ddcd15b2 100644 --- a/src/settings/plugins/keyfile/Makefile.am +++ b/src/settings/plugins/keyfile/Makefile.am @@ -5,15 +5,14 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DNMCONFDIR=\"$(nmconfdir)\" noinst_LTLIBRARIES = \ @@ -28,8 +27,7 @@ libkeyfile_io_la_SOURCES = \ writer.c \ writer.h \ utils.c \ - utils.h \ - common.h + utils.h libkeyfile_io_la_LIBADD = $(GLIB_LIBS) diff --git a/src/settings/plugins/keyfile/Makefile.in b/src/settings/plugins/keyfile/Makefile.in index 1514768b..9c078ca4 100644 --- a/src/settings/plugins/keyfile/Makefile.in +++ b/src/settings/plugins/keyfile/Makefile.in @@ -246,7 +246,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -258,8 +257,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -269,6 +266,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -323,16 +321,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -369,6 +364,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -397,7 +394,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -412,6 +408,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -472,6 +470,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -479,6 +478,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -498,15 +498,14 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ -DNMCONFDIR=\"$(nmconfdir)\" noinst_LTLIBRARIES = \ @@ -521,8 +520,7 @@ libkeyfile_io_la_SOURCES = \ writer.c \ writer.h \ utils.c \ - utils.h \ - common.h + utils.h libkeyfile_io_la_LIBADD = $(GLIB_LIBS) diff --git a/src/settings/plugins/keyfile/common.h b/src/settings/plugins/keyfile/common.h deleted file mode 100644 index 86fe0028..00000000 --- a/src/settings/plugins/keyfile/common.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* NetworkManager system settings service - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 - 2013 Red Hat, Inc. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#include <glib.h> - -#define KEYFILE_PLUGIN_NAME "keyfile" -#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." - -#define KEYFILE_DIR NMCONFDIR "/system-connections" - -#endif /* __COMMON_H__ */ - diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c index 8fb94302..c217de68 100644 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c @@ -27,12 +27,13 @@ #include <nm-setting-connection.h> #include <nm-utils.h> -#include "nm-system-config-interface.h" -#include "nm-dbus-glib-types.h" +#include "nm-default.h" +#include "nm-settings-plugin.h" #include "nm-keyfile-connection.h" #include "reader.h" #include "writer.h" -#include "common.h" +#include "utils.h" +#include "nm-logging.h" G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) @@ -88,6 +89,7 @@ nm_keyfile_connection_new (NMConnection *source, static void commit_changes (NMSettingsConnection *connection, + NMSettingsConnectionCommitReason commit_reason, NMSettingsConnectionCommitFunc callback, gpointer user_data) { @@ -96,6 +98,8 @@ commit_changes (NMSettingsConnection *connection, if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection), nm_settings_connection_get_filename (connection), + NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION + | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED), &path, &error)) { callback (connection, error, user_data); @@ -104,10 +108,28 @@ commit_changes (NMSettingsConnection *connection, } /* Update the filename if it changed */ - if (path) + if ( path + && g_strcmp0 (path, nm_settings_connection_get_filename (connection)) != 0) { + gs_free char *old_path = g_strdup (nm_settings_connection_get_filename (connection)); + nm_settings_connection_set_filename (connection, path); + if (old_path) { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"", + NM_KEYFILE_CONNECTION_LOG_ARG (connection), + old_path); + } else { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and persist connection", + NM_KEYFILE_CONNECTION_LOG_ARG (connection)); + } + } else { + nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, + NM_KEYFILE_CONNECTION_LOG_ARG (connection)); + } + + g_free (path); NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection, + commit_reason, callback, user_data); } diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index 7f21e71e..e352e523 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -27,62 +27,51 @@ #include <string.h> #include <gmodule.h> -#include <glib.h> #include <glib/gstdio.h> -#include <gio/gio.h> #include <nm-connection.h> #include <nm-setting.h> #include <nm-setting-connection.h> #include <nm-utils.h> -#include <nm-config.h> -#include <nm-logging.h> +#include "nm-config.h" +#include "nm-default.h" #include "nm-core-internal.h" #include "plugin.h" -#include "nm-system-config-interface.h" +#include "nm-settings-plugin.h" #include "nm-keyfile-connection.h" #include "writer.h" -#include "common.h" #include "utils.h" -#include "gsystem-local-alloc.h" -static char *plugin_get_hostname (SCPluginKeyfile *plugin); -static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); +static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SCPluginKeyfile, sc_plugin_keyfile, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, - system_config_interface_init)) +G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0, + G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, + settings_plugin_interface_init)) -#define SC_PLUGIN_KEYFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfilePrivate)) +#define SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfilePrivate)) typedef struct { GHashTable *connections; /* uuid::connection */ gboolean initialized; GFileMonitor *monitor; - guint monitor_id; + gulong monitor_id; - const char *conf_file; - GFileMonitor *conf_file_monitor; - guint conf_file_monitor_id; - - char *hostname; - - gboolean disposed; -} SCPluginKeyfilePrivate; + NMConfig *config; +} SettingsPluginKeyfilePrivate; static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SC_PLUGIN_KEYFILE_GET_PRIVATE (user_data)->connections, + g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } /* Monitoring */ static void -remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection) +remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) { gboolean removed; @@ -93,7 +82,7 @@ remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection) /* Removing from the hash table should drop the last reference */ g_object_ref (connection); g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self); - removed = g_hash_table_remove (SC_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, + removed = g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); g_object_unref (connection); @@ -102,9 +91,9 @@ remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection) } static NMKeyfileConnection * -find_by_path (SCPluginKeyfile *self, const char *path) +find_by_path (SettingsPluginKeyfile *self, const char *path) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); GHashTableIter iter; NMSettingsConnection *candidate = NULL; @@ -150,7 +139,7 @@ find_by_path (SCPluginKeyfile *self, const char *path) * Returns: the updated connection. * */ static NMKeyfileConnection * -update_connection (SCPluginKeyfile *self, +update_connection (SettingsPluginKeyfile *self, NMConnection *source, const char *full_path, NMKeyfileConnection *connection, @@ -158,7 +147,7 @@ update_connection (SCPluginKeyfile *self, GHashTable *protected_connections, GError **error) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); NMKeyfileConnection *connection_new; NMKeyfileConnection *connection_by_uuid; GError *local = NULL; @@ -274,7 +263,7 @@ update_connection (SCPluginKeyfile *self, if (!source) { /* Only raise the signal if we were called without source, i.e. if we read the connection from file. * Otherwise, we were called by add_connection() which does not expect the signal. */ - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection_new); + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_CONNECTION_ADDED, connection_new); } return connection_new; } @@ -287,8 +276,8 @@ dir_changed (GFileMonitor *monitor, GFileMonitorEvent event_type, gpointer user_data) { - NMSystemConfigInterface *config = NM_SYSTEM_CONFIG_INTERFACE (user_data); - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); NMKeyfileConnection *connection; char *full_path; gboolean exists; @@ -307,12 +296,12 @@ dir_changed (GFileMonitor *monitor, switch (event_type) { case G_FILE_MONITOR_EVENT_DELETED: if (!exists && connection) - remove_connection (SC_PLUGIN_KEYFILE (config), connection); + remove_connection (SETTINGS_PLUGIN_KEYFILE (config), connection); break; case G_FILE_MONITOR_EVENT_CREATED: case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: if (exists) - update_connection (SC_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); + update_connection (SETTINGS_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); break; default: break; @@ -322,51 +311,30 @@ dir_changed (GFileMonitor *monitor, } static void -conf_file_changed (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - gpointer data) +config_changed_cb (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + SettingsPluginKeyfile *self) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (data); - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); - char *tmp; - - switch (event_type) { - case G_FILE_MONITOR_EVENT_DELETED: - case G_FILE_MONITOR_EVENT_CREATED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED); - - /* hostname */ - tmp = plugin_get_hostname (self); - if ((tmp && !priv->hostname) - || (!tmp && priv->hostname) - || (priv->hostname && tmp && strcmp (priv->hostname, tmp))) { - - g_free (priv->hostname); - priv->hostname = tmp; - tmp = NULL; - g_object_notify (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); - } + gs_free char *old_value = NULL, *new_value = NULL; - g_free (tmp); + old_value = nm_config_data_get_value (old_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); + new_value = nm_config_data_get_value (config_data, NM_CONFIG_KEYFILE_GROUP_KEYFILE, NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, NM_CONFIG_GET_VALUE_TYPE_SPEC); - break; - default: - break; - } + if (g_strcmp0 (old_value, new_value) != 0) + g_signal_emit_by_name (self, NM_SETTINGS_PLUGIN_UNMANAGED_SPECS_CHANGED); } static void -setup_monitoring (NMSystemConfigInterface *config) +setup_monitoring (NMSettingsPlugin *config) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); GFile *file; GFileMonitor *monitor; if (nm_config_get_monitor_connection_files (nm_config_get ())) { - file = g_file_new_for_path (KEYFILE_DIR); + file = g_file_new_for_path (nm_keyfile_plugin_get_path ()); monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); g_object_unref (file); @@ -376,16 +344,10 @@ setup_monitoring (NMSystemConfigInterface *config) } } - if (priv->conf_file) { - file = g_file_new_for_path (priv->conf_file); - monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref (file); - - if (monitor) { - priv->conf_file_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (conf_file_changed), config); - priv->conf_file_monitor = monitor; - } - } + g_signal_connect (G_OBJECT (priv->config), + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_cb), + config); } static GHashTable * @@ -426,10 +388,10 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) } static void -read_connections (NMSystemConfigInterface *config) +read_connections (NMSettingsPlugin *config) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); GDir *dir; GError *error = NULL; const char *item; @@ -441,10 +403,10 @@ read_connections (NMSystemConfigInterface *config) GPtrArray *filenames; GHashTable *paths; - dir = g_dir_open (KEYFILE_DIR, 0, &error); + dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error); if (!dir) { nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s", - KEYFILE_DIR, + nm_keyfile_plugin_get_path (), error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); @@ -457,7 +419,7 @@ read_connections (NMSystemConfigInterface *config) while ((item = g_dir_read_name (dir))) { if (nm_keyfile_plugin_utils_should_ignore_file (item)) continue; - g_ptr_array_add (filenames, g_build_filename (KEYFILE_DIR, item, NULL)); + g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL)); } g_dir_close (dir); @@ -499,9 +461,9 @@ read_connections (NMSystemConfigInterface *config) /* Plugin */ static GSList * -get_connections (NMSystemConfigInterface *config) +get_connections (NMSettingsPlugin *config) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); if (!priv->initialized) { setup_monitoring (config); @@ -512,14 +474,14 @@ get_connections (NMSystemConfigInterface *config) } static gboolean -load_connection (NMSystemConfigInterface *config, +load_connection (NMSettingsPlugin *config, const char *filename) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); NMKeyfileConnection *connection; - int dir_len = strlen (KEYFILE_DIR); + int dir_len = strlen (nm_keyfile_plugin_get_path ()); - if ( strncmp (filename, KEYFILE_DIR, dir_len) != 0 + if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0 || filename[dir_len] != '/' || strchr (filename + dir_len + 1, '/') != NULL) return FALSE; @@ -533,157 +495,46 @@ load_connection (NMSystemConfigInterface *config, } static void -reload_connections (NMSystemConfigInterface *config) +reload_connections (NMSettingsPlugin *config) { read_connections (config); } static NMSettingsConnection * -add_connection (NMSystemConfigInterface *config, +add_connection (NMSettingsPlugin *config, NMConnection *connection, gboolean save_to_disk, GError **error) { - SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config); + SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); gs_free char *path = NULL; if (save_to_disk) { - if (!nm_keyfile_plugin_write_connection (connection, NULL, &path, error)) + if (!nm_keyfile_plugin_write_connection (connection, NULL, FALSE, &path, error)) return NULL; } return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); } -static gboolean -parse_key_file_allow_none (SCPluginKeyfilePrivate *priv, - GKeyFile *key_file, - GError **error) -{ - gboolean ret = FALSE; - GError *local_error = NULL; - - if (!g_key_file_load_from_file (key_file, priv->conf_file, G_KEY_FILE_NONE, &local_error)) { - if (g_error_matches (local_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - g_clear_error (&local_error); - else { - g_propagate_prefixed_error (error, local_error, - "Error parsing file '%s': ", - priv->conf_file); - goto out; - } - } - ret = TRUE; - - out: - return ret; -} - static GSList * -get_unmanaged_specs (NMSystemConfigInterface *config) -{ - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); - GKeyFile *key_file; - GSList *specs = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - key_file = nm_config_create_keyfile (); - if (parse_key_file_allow_none (priv, key_file, &error)) - specs = nm_config_get_device_match_spec (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "unmanaged-devices", NULL); - - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error getting unmanaged specs: %s", error->message); - g_error_free (error); - } - g_key_file_free (key_file); - - return specs; -} - -static char * -plugin_get_hostname (SCPluginKeyfile *plugin) -{ - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin); - GKeyFile *key_file; - char *hostname = NULL; - GError *error = NULL; - - if (!priv->conf_file) - return NULL; - - key_file = g_key_file_new (); - if (!parse_key_file_allow_none (priv, key_file, &error)) - goto out; - - hostname = g_key_file_get_value (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname", NULL); - - out: - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error getting hostname: %s", error->message); - g_error_free (error); - } - if (key_file) - g_key_file_free (key_file); - - return hostname; -} - -static gboolean -plugin_set_hostname (SCPluginKeyfile *plugin, const char *hostname) +get_unmanaged_specs (NMSettingsPlugin *config) { - gboolean ret = FALSE; - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin); - GKeyFile *key_file = NULL; - GError *error = NULL; - char *data = NULL; - gsize len; - - if (!priv->conf_file) { - g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Error saving hostname: no config file"); - goto out; - } - - g_free (priv->hostname); - priv->hostname = g_strdup (hostname); - - key_file = g_key_file_new (); - if (!parse_key_file_allow_none (priv, key_file, &error)) - goto out; - - g_key_file_set_string (key_file, NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname", hostname); - - data = g_key_file_to_data (key_file, &len, &error); - if (!data) - goto out; - - if (!g_file_set_contents (priv->conf_file, data, len, &error)) { - g_prefix_error (&error, "Error saving hostname: "); - goto out; - } - - ret = TRUE; - - out: - if (error) { - nm_log_warn (LOGD_SETTINGS, "keyfile: error setting hostname: %s", error->message); - g_error_free (error); - } - g_free (data); - if (key_file) - g_key_file_free (key_file); - - return ret; + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (config); + gs_free char *value = NULL; + + value = nm_config_data_get_value (nm_config_get_data (priv->config), + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES, + NM_CONFIG_GET_VALUE_TYPE_SPEC); + return nm_match_spec_split (value); } /* GObject */ static void -sc_plugin_keyfile_init (SCPluginKeyfile *plugin) +settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (plugin); + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (plugin); priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } @@ -693,18 +544,14 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: + case NM_SETTINGS_PLUGIN_PROP_NAME: g_value_set_string (value, KEYFILE_PLUGIN_NAME); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO: + case NM_SETTINGS_PLUGIN_PROP_INFO: g_value_set_string (value, KEYFILE_PLUGIN_INFO); break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES: - g_value_set_uint (value, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS | - NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME); - break; - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - g_value_set_string (value, SC_PLUGIN_KEYFILE_GET_PRIVATE (object)->hostname); + case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: + g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -716,15 +563,7 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - const char *hostname; - switch (prop_id) { - case NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME: - hostname = g_value_get_string (value); - if (hostname && strlen (hostname) < 1) - hostname = NULL; - plugin_set_hostname (SC_PLUGIN_KEYFILE (object), hostname); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -732,97 +571,81 @@ set_property (GObject *object, guint prop_id, } static void -dispose (GObject *object) +constructed (GObject *object) { - SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (object); - - if (priv->disposed) - goto out; + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (object); + + priv->config = g_object_ref (nm_config_get ()); + if (nm_config_data_has_value (nm_config_get_data_orig (priv->config), + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_HOSTNAME, + NM_CONFIG_GET_VALUE_RAW)) + nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect"); +} - priv->disposed = TRUE; +static void +dispose (GObject *object) +{ + SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (object); if (priv->monitor) { - if (priv->monitor_id) - g_signal_handler_disconnect (priv->monitor, priv->monitor_id); + nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id); g_file_monitor_cancel (priv->monitor); - g_object_unref (priv->monitor); - } - - if (priv->conf_file_monitor) { - if (priv->conf_file_monitor_id) - g_signal_handler_disconnect (priv->conf_file_monitor, priv->conf_file_monitor_id); - - g_file_monitor_cancel (priv->conf_file_monitor); - g_object_unref (priv->conf_file_monitor); + g_clear_object (&priv->monitor); } - g_free (priv->hostname); - if (priv->connections) { g_hash_table_destroy (priv->connections); priv->connections = NULL; } -out: - G_OBJECT_CLASS (sc_plugin_keyfile_parent_class)->dispose (object); + if (priv->config) { + g_signal_handlers_disconnect_by_func (priv->config, config_changed_cb, object); + g_clear_object (&priv->config); + } + + G_OBJECT_CLASS (settings_plugin_keyfile_parent_class)->dispose (object); } static void -sc_plugin_keyfile_class_init (SCPluginKeyfileClass *req_class) +settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); - g_type_class_add_private (req_class, sizeof (SCPluginKeyfilePrivate)); + g_type_class_add_private (req_class, sizeof (SettingsPluginKeyfilePrivate)); + object_class->constructed = constructed; object_class->dispose = dispose; object_class->get_property = get_property; object_class->set_property = set_property; g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME, - NM_SYSTEM_CONFIG_INTERFACE_NAME); - - g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_INFO, - NM_SYSTEM_CONFIG_INTERFACE_INFO); + NM_SETTINGS_PLUGIN_PROP_NAME, + NM_SETTINGS_PLUGIN_NAME); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_CAPABILITIES, - NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES); + NM_SETTINGS_PLUGIN_PROP_INFO, + NM_SETTINGS_PLUGIN_INFO); g_object_class_override_property (object_class, - NM_SYSTEM_CONFIG_INTERFACE_PROP_HOSTNAME, - NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME); + NM_SETTINGS_PLUGIN_PROP_CAPABILITIES, + NM_SETTINGS_PLUGIN_CAPABILITIES); } static void -system_config_interface_init (NMSystemConfigInterface *system_config_interface_class) +settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface) { /* interface implementation */ - system_config_interface_class->get_connections = get_connections; - system_config_interface_class->load_connection = load_connection; - system_config_interface_class->reload_connections = reload_connections; - system_config_interface_class->add_connection = add_connection; - system_config_interface_class->get_unmanaged_specs = get_unmanaged_specs; + plugin_iface->get_connections = get_connections; + plugin_iface->load_connection = load_connection; + plugin_iface->reload_connections = reload_connections; + plugin_iface->add_connection = add_connection; + plugin_iface->get_unmanaged_specs = get_unmanaged_specs; } GObject * nm_settings_keyfile_plugin_new (void) { - static SCPluginKeyfile *singleton = NULL; - SCPluginKeyfilePrivate *priv; - - if (!singleton) { - singleton = SC_PLUGIN_KEYFILE (g_object_new (SC_TYPE_PLUGIN_KEYFILE, NULL)); - priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (singleton); - - priv->conf_file = nm_config_data_get_config_main_file (nm_config_get_data (nm_config_get ())); - - /* plugin_set_hostname() has to be called *after* priv->conf_file is set */ - priv->hostname = plugin_get_hostname (singleton); - } else - g_object_ref (singleton); - - return G_OBJECT (singleton); + return g_object_new (SETTINGS_TYPE_PLUGIN_KEYFILE, NULL); } diff --git a/src/settings/plugins/keyfile/plugin.h b/src/settings/plugins/keyfile/plugin.h index 48579785..07403270 100644 --- a/src/settings/plugins/keyfile/plugin.h +++ b/src/settings/plugins/keyfile/plugin.h @@ -22,24 +22,24 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include <glib-object.h> +#include "nm-default.h" -#define SC_TYPE_PLUGIN_KEYFILE (sc_plugin_keyfile_get_type ()) -#define SC_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfile)) -#define SC_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfileClass)) -#define SC_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_PLUGIN_KEYFILE)) -#define SC_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_PLUGIN_KEYFILE)) -#define SC_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SC_TYPE_PLUGIN_KEYFILE, SCPluginKeyfileClass)) +#define SETTINGS_TYPE_PLUGIN_KEYFILE (settings_plugin_keyfile_get_type ()) +#define SETTINGS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfile)) +#define SETTINGS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) +#define SETTINGS_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE)) +#define SETTINGS_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE)) +#define SETTINGS_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) typedef struct { GObject parent; -} SCPluginKeyfile; +} SettingsPluginKeyfile; typedef struct { GObjectClass parent; -} SCPluginKeyfileClass; +} SettingsPluginKeyfileClass; -GType sc_plugin_keyfile_get_type (void); +GType settings_plugin_keyfile_get_type (void); GObject *nm_settings_keyfile_plugin_new (void); diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index bd08c17d..1c984a16 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -25,7 +25,7 @@ #include "reader.h" -#include "nm-logging.h" +#include "nm-default.h" #include "nm-keyfile-internal.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/keyfile/reader.h b/src/settings/plugins/keyfile/reader.h index 55819630..a8021cb7 100644 --- a/src/settings/plugins/keyfile/reader.h +++ b/src/settings/plugins/keyfile/reader.h @@ -22,9 +22,10 @@ #ifndef _KEYFILE_PLUGIN_READER_H #define _KEYFILE_PLUGIN_READER_H -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + NMConnection *nm_keyfile_plugin_connection_from_file (const char *filename, GError **error); #endif /* _KEYFILE_PLUGIN_READER_H */ diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am index cbe3f73b..4d85f09a 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ b/src/settings/plugins/keyfile/tests/Makefile.am @@ -5,18 +5,17 @@ SUBDIRS=keyfiles @GNOME_CODE_COVERAGE_RULES@ AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ + -I$(top_srcdir)/shared \ + -I$(top_builddir)/shared \ -I$(top_srcdir)/libnm-core \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ $(CODE_COVERAGE_CFLAGS) \ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ - -DNETWORKMANAGER_COMPILATION \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ @@ -32,7 +31,6 @@ test_keyfile_SOURCES = \ test_keyfile_LDADD = \ $(top_builddir)/src/libNetworkManager.la \ - $(DBUS_LIBS) \ $(CODE_COVERAGE_LDFLAGS) @VALGRIND_RULES@ diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in index 6dfaf110..7577df57 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ b/src/settings/plugins/keyfile/tests/Makefile.in @@ -122,7 +122,7 @@ test_keyfile_OBJECTS = $(am_test_keyfile_OBJECTS) am__DEPENDENCIES_1 = @ENABLE_TESTS_TRUE@test_keyfile_DEPENDENCIES = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent @@ -450,7 +450,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -462,8 +461,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -473,6 +470,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -527,16 +525,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -573,6 +568,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -601,7 +598,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -616,6 +612,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -676,6 +674,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -683,6 +682,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -700,18 +700,17 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@SUBDIRS = keyfiles @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/shared \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/shared \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ -@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ @ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ @@ -725,7 +724,6 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@test_keyfile_LDADD = \ @ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ @ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) all: all-recursive diff --git a/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain b/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain index 902b8427..11e1ec6f 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain +++ b/src/settings/plugins/keyfile/tests/keyfiles/ATT_Data_Connect_Plain @@ -15,6 +15,9 @@ password=CINGULAR1 apn=ISP.CINGULAR network-id=24005 pin=2345 +device-id=da812de91eec16620b06cd0ca5cbc7ea25245222 +sim-id=89148000000060671234 +sim-operator-id=310260 [serial] baud=115200 diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in index 33d0e0c5..56f0735f 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in @@ -146,7 +146,6 @@ BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CKDB_PATH = @CKDB_PATH@ CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ @@ -158,8 +157,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DBUS_CFLAGS = @DBUS_CFLAGS@ -DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ -DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ @@ -169,6 +166,7 @@ DHCPCD_PATH = @DHCPCD_PATH@ DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ +DNSSEC_TRIGGER_SCRIPT = @DNSSEC_TRIGGER_SCRIPT@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -223,16 +221,13 @@ INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ IPTABLES_PATH = @IPTABLES_PATH@ -IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ -IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ LCOV = @LCOV@ LD = @LD@ LDFLAGS = @LDFLAGS@ +LIBAUDIT_CFLAGS = @LIBAUDIT_CFLAGS@ +LIBAUDIT_LIBS = @LIBAUDIT_LIBS@ LIBDL = @LIBDL@ -LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ -LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ -LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ @@ -269,6 +264,8 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -297,7 +294,6 @@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ -PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ @@ -312,6 +308,8 @@ SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_JOURNAL_CFLAGS = @SYSTEMD_JOURNAL_CFLAGS@ +SYSTEMD_JOURNAL_LIBS = @SYSTEMD_JOURNAL_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ @@ -372,6 +370,7 @@ mkdir_p = @mkdir_p@ nmbinary = @nmbinary@ nmconfdir = @nmconfdir@ nmdatadir = @nmdatadir@ +nmlibdir = @nmlibdir@ nmrundir = @nmrundir@ nmstatedir = @nmstatedir@ oldincludedir = @oldincludedir@ @@ -379,6 +378,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main b/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main index 3b9fcb28..fc9fd8f8 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_Bridge_Main @@ -11,6 +11,7 @@ priority=32744 hello-time=7 max-age=39 ageing-time=235352 +multicast-snooping=false [ipv4] method=auto diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 785ad4cb..250bad36 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -29,7 +29,7 @@ #include <sys/socket.h> #include "nm-core-internal.h" -#include "nm-logging.h" +#include "nm-default.h" #include "reader.h" #include "writer.h" @@ -1882,153 +1882,43 @@ test_read_gsm_connection (void) NMSettingConnection *s_con; NMSettingSerial *s_serial; NMSettingGsm *s_gsm; - NMSettingBluetooth *s_bluetooth; GError *error = NULL; - const char *tmp; - NMSettingSerialParity parity; - const char *expected_id = "AT&T Data Connect"; - const char *expected_apn = "ISP.CINGULAR"; - const char *expected_username = "ISP@CINGULARGPRS.COM"; - const char *expected_password = "CINGULAR1"; - const char *expected_network_id = "24005"; - const char *expected_pin = "2345"; + gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_GSM_FILE, NULL); - ASSERT (connection != NULL, - "connection-read", "failed to read %s", TEST_GSM_FILE); + connection = nm_keyfile_plugin_connection_from_file (TEST_GSM_FILE, &error); + g_assert_no_error (error); + g_assert (connection); - ASSERT (nm_connection_verify (connection, &error), - "connection-verify", "failed to verify %s: %s", TEST_GSM_FILE, error->message); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection (connection); - ASSERT (s_con != NULL, - "connection-verify-connection", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME); - - /* ID */ - tmp = nm_setting_connection_get_id (s_con); - ASSERT (tmp != NULL, - "connection-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, expected_id) == 0, - "connection-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - - tmp = nm_setting_connection_get_connection_type (s_con); - ASSERT (tmp != NULL, - "connection-verify-connection", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_ID); - ASSERT (strcmp (tmp, NM_SETTING_GSM_SETTING_NAME) == 0, - "connection-verify-connection", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_CONNECTION_SETTING_NAME, - NM_SETTING_CONNECTION_TYPE); + g_assert (s_con); + g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "AT&T Data Connect"); + g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_GSM_SETTING_NAME); /* ===== BLUETOOTH SETTING ===== */ - /* Plain GSM, so no BT setting expected */ - s_bluetooth = nm_connection_get_setting_bluetooth (connection); - ASSERT (s_bluetooth == NULL, - "connection-verify-bt", "unexpected %s setting", - TEST_GSM_FILE, - NM_SETTING_BLUETOOTH_SETTING_NAME); + g_assert (nm_connection_get_setting_bluetooth (connection) == NULL); /* ===== GSM SETTING ===== */ - s_gsm = nm_connection_get_setting_gsm (connection); - ASSERT (s_gsm != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME); - - /* APN */ - tmp = nm_setting_gsm_get_apn (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_APN); - ASSERT (strcmp (tmp, expected_apn) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_APN); - - /* Username */ - tmp = nm_setting_gsm_get_username (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_USERNAME); - ASSERT (strcmp (tmp, expected_username) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_USERNAME); - - /* Password */ - tmp = nm_setting_gsm_get_password (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PASSWORD); - ASSERT (strcmp (tmp, expected_password) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PASSWORD); - - /* Network ID */ - tmp = nm_setting_gsm_get_network_id (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_NETWORK_ID); - ASSERT (strcmp (tmp, expected_network_id) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_NETWORK_ID); - - /* PIN */ - tmp = nm_setting_gsm_get_pin (s_gsm); - ASSERT (tmp != NULL, - "connection-verify-gsm", "failed to verify %s: missing %s / %s key", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PIN); - ASSERT (strcmp (tmp, expected_pin) == 0, - "connection-verify-gsm", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_GSM_PIN); + g_assert (s_gsm); + g_assert_cmpstr (nm_setting_gsm_get_apn (s_gsm), ==, "ISP.CINGULAR"); + g_assert_cmpstr (nm_setting_gsm_get_username (s_gsm), ==, "ISP@CINGULARGPRS.COM"); + g_assert_cmpstr (nm_setting_gsm_get_password (s_gsm), ==, "CINGULAR1"); + g_assert_cmpstr (nm_setting_gsm_get_network_id (s_gsm), ==, "24005"); + g_assert_cmpstr (nm_setting_gsm_get_pin (s_gsm), ==, "2345"); + g_assert_cmpstr (nm_setting_gsm_get_device_id (s_gsm), ==, "da812de91eec16620b06cd0ca5cbc7ea25245222"); + g_assert_cmpstr (nm_setting_gsm_get_sim_id (s_gsm), ==, "89148000000060671234"); + g_assert_cmpstr (nm_setting_gsm_get_sim_operator_id (s_gsm), ==, "310260"); /* ===== SERIAL SETTING ===== */ - s_serial = nm_connection_get_setting_serial (connection); - ASSERT (s_serial != NULL, - "connection-verify-serial", "failed to verify %s: missing %s setting", - TEST_GSM_FILE, - NM_SETTING_SERIAL_SETTING_NAME); - - parity = nm_setting_serial_get_parity (s_serial); - ASSERT (parity == NM_SETTING_SERIAL_PARITY_ODD, - "connection-verify-serial", "failed to verify %s: unexpected %s / %s key value", - TEST_GSM_FILE, - NM_SETTING_SERIAL_SETTING_NAME, - NM_SETTING_SERIAL_PARITY); + g_assert (s_serial); + g_assert_cmpint (nm_setting_serial_get_parity (s_serial), ==, NM_SETTING_SERIAL_PARITY_ODD); g_object_unref (connection); } @@ -2087,22 +1977,23 @@ test_write_gsm_connection (void) NM_SETTING_GSM_PIN, "123456", NM_SETTING_GSM_NETWORK_ID, "254098", NM_SETTING_GSM_HOME_ONLY, TRUE, + NM_SETTING_GSM_DEVICE_ID, "da812de91eec16620b06cd0ca5cbc7ea25245222", + NM_SETTING_GSM_SIM_ID, "89148000000060671234", + NM_SETTING_GSM_SIM_OPERATOR_ID, "310260", NULL); /* Write out the connection */ owner_uid = geteuid (); owner_grp = getegid (); success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); - ASSERT (success == TRUE, - "connection-write", "failed to write keyfile: %s", - error ? error->message : "(none)"); - - ASSERT (testfile != NULL, - "connection-write", "didn't get keyfile name back after writing connection"); + g_assert_no_error (error); + g_assert (success); + g_assert (testfile != NULL); /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, NULL); - ASSERT (reread != NULL, "connection-write", "failed to re-read test connection"); + reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + g_assert_no_error (error); + g_assert (reread); nmtst_assert_connection_equals (connection, TRUE, reread, FALSE); @@ -2821,6 +2712,7 @@ test_read_bridge_main (void) g_assert_cmpuint (nm_setting_bridge_get_hello_time (s_bridge), ==, 7); g_assert_cmpuint (nm_setting_bridge_get_max_age (s_bridge), ==, 39); g_assert_cmpuint (nm_setting_bridge_get_ageing_time (s_bridge), ==, 235352); + g_assert_cmpuint (nm_setting_bridge_get_multicast_snooping (s_bridge), ==, FALSE); g_object_unref (connection); } diff --git a/src/settings/plugins/keyfile/utils.c b/src/settings/plugins/keyfile/utils.c index 4809c642..48795ffb 100644 --- a/src/settings/plugins/keyfile/utils.c +++ b/src/settings/plugins/keyfile/utils.c @@ -20,15 +20,16 @@ #include "config.h" -#include <glib.h> #include <stdlib.h> #include <string.h> -#include "gsystem-local-alloc.h" +#include "nm-default.h" #include "utils.h" #include <nm-setting-wired.h> #include <nm-setting-wireless.h> #include <nm-setting-wireless-security.h> +#include "nm-config.h" +#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections" static const char temp_letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; @@ -146,3 +147,23 @@ nm_keyfile_plugin_utils_escape_filename (const char *filename) return g_string_free (str, FALSE);; } +/*****************************************************************************/ + +const char * +nm_keyfile_plugin_get_path (void) +{ + static char *path = NULL; + + if (G_UNLIKELY (!path)) { + path = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG, + NM_CONFIG_KEYFILE_GROUP_KEYFILE, + NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH, + NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY); + if (!path) + path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT""); + } + return path; +} + +/*****************************************************************************/ + diff --git a/src/settings/plugins/keyfile/utils.h b/src/settings/plugins/keyfile/utils.h index d0862284..0b2b6f4e 100644 --- a/src/settings/plugins/keyfile/utils.h +++ b/src/settings/plugins/keyfile/utils.h @@ -21,9 +21,12 @@ #ifndef _UTILS_H_ #define _UTILS_H_ -#include <glib.h> +#include "nm-default.h" #include "NetworkManagerUtils.h" +#define KEYFILE_PLUGIN_NAME "keyfile" +#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." + #define NM_KEYFILE_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory") #define NM_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" #define NM_KEYFILE_CONNECTION_LOG_ARG(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) @@ -34,5 +37,7 @@ gboolean nm_keyfile_plugin_utils_should_ignore_file (const char *filename); char *nm_keyfile_plugin_utils_escape_filename (const char *filename); +const char *nm_keyfile_plugin_get_path (void); + #endif /* _UTILS_H_ */ diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c index b6a8786d..db00b061 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -27,15 +27,11 @@ #include <errno.h> #include <string.h> -#include "nm-glib-compat.h" - -#include "nm-logging.h" +#include "nm-default.h" #include "writer.h" -#include "common.h" #include "utils.h" #include "nm-keyfile-internal.h" - typedef struct { const char *keyfile_dir; } WriteInfo; @@ -233,17 +229,18 @@ _internal_write_connection (NMConnection *connection, uid_t owner_uid, pid_t owner_grp, const char *existing_path, + gboolean force_rename, char **out_path, GError **error) { GKeyFile *key_file; - char *data; + gs_free char *data = NULL; gsize len; - gboolean success = FALSE; - char *path; + gs_free char *path = NULL; const char *id; WriteInfo info = { 0 }; GError *local_err = NULL; + int errsv; g_return_val_if_fail (!out_path || !*out_path, FALSE); g_return_val_if_fail (keyfile_dir && keyfile_dir[0] == '/', FALSE); @@ -267,7 +264,7 @@ _internal_write_connection (NMConnection *connection, /* If we have existing file path, use it. Else generate one from * connection's ID. */ - if (existing_path != NULL) { + if (existing_path != NULL && !force_rename) { path = g_strdup (existing_path); } else { char *filename_escaped = nm_keyfile_plugin_utils_escape_filename (id); @@ -312,8 +309,7 @@ _internal_write_connection (NMConnection *connection, /* this really should not happen, we tried hard to find an unused name... bail out. */ g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "could not find suitable keyfile file name (%s already used)", path); - g_free (path); - goto out; + return FALSE; } /* Both our preferred path based on connection id and id-uuid are taken. * Fallback to @existing_path */ @@ -331,49 +327,49 @@ _internal_write_connection (NMConnection *connection, g_file_set_contents (path, data, len, &local_err); if (local_err) { g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error writing to file '%s': %s", __FILE__, __LINE__, + "error writing to file '%s': %s", path, local_err->message); g_error_free (local_err); - g_free (path); - goto out; + return FALSE; } if (chown (path, owner_uid, owner_grp) < 0) { + errsv = errno; g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error chowning '%s': %d", __FILE__, __LINE__, - path, errno); + "error chowning '%s': %s (%d)", + path, g_strerror (errsv), errsv); unlink (path); - } else { - if (chmod (path, S_IRUSR | S_IWUSR) < 0) { - g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, - "%s.%d: error setting permissions on '%s': %d", __FILE__, - __LINE__, path, errno); - unlink (path); - } else { - if (out_path && g_strcmp0 (existing_path, path)) { - *out_path = path; /* pass path out to caller */ - path = NULL; - } - success = TRUE; - } + return FALSE; } - g_free (path); -out: - g_free (data); - return success; + if (chmod (path, S_IRUSR | S_IWUSR) < 0) { + errsv = errno; + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "error setting permissions on '%s': %s (%d)", + path, g_strerror (errsv), errsv); + unlink (path); + return FALSE; + } + + if (out_path && g_strcmp0 (existing_path, path)) { + *out_path = path; /* pass path out to caller */ + path = NULL; + } + return TRUE; } gboolean nm_keyfile_plugin_write_connection (NMConnection *connection, const char *existing_path, + gboolean force_rename, char **out_path, GError **error) { return _internal_write_connection (connection, - KEYFILE_DIR, + nm_keyfile_plugin_get_path (), 0, 0, existing_path, + force_rename, out_path, error); } @@ -390,6 +386,7 @@ nm_keyfile_plugin_write_test_connection (NMConnection *connection, keyfile_dir, owner_uid, owner_grp, NULL, + FALSE, out_path, error); } diff --git a/src/settings/plugins/keyfile/writer.h b/src/settings/plugins/keyfile/writer.h index 8b08812d..25f44e94 100644 --- a/src/settings/plugins/keyfile/writer.h +++ b/src/settings/plugins/keyfile/writer.h @@ -22,11 +22,13 @@ #ifndef _KEYFILE_PLUGIN_WRITER_H #define _KEYFILE_PLUGIN_WRITER_H -#include <glib.h> #include <nm-connection.h> +#include "nm-default.h" + gboolean nm_keyfile_plugin_write_connection (NMConnection *connection, const char *existing_path, + gboolean force_rename, char **out_path, GError **error); |