CEPage * ce_page_dsl_new (NMConnectionEditor *editor, NMConnection *connection, GtkWindow *parent_window, NMClient *client, const char **out_secrets_setting_name, GError **error) { CEPageDsl *self; CEPageDslPrivate *priv; self = CE_PAGE_DSL (ce_page_new (CE_TYPE_PAGE_DSL, editor, connection, parent_window, client, UIDIR "/ce-page-dsl.ui", "DslPage", _("DSL"))); if (!self) { g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Could not load DSL user interface.")); return NULL; } dsl_private_init (self); priv = CE_PAGE_DSL_GET_PRIVATE (self); priv->setting = nm_connection_get_setting_pppoe (connection); if (!priv->setting) { priv->setting = NM_SETTING_PPPOE (nm_setting_pppoe_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->setting)); } g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL); *out_secrets_setting_name = NM_SETTING_PPPOE_SETTING_NAME; return CE_PAGE (self); }
static gboolean add_pppoe_secrets (NMSecretAgentSimpleRequest *request, GPtrArray *secrets) { NMSettingPppoe *s_pppoe = nm_connection_get_setting_pppoe (request->connection); NMSecretAgentSimpleSecret *secret; secret = nm_secret_agent_simple_secret_new (_("Username"), NM_SETTING (s_pppoe), NM_SETTING_PPPOE_USERNAME, FALSE); g_ptr_array_add (secrets, secret); secret = nm_secret_agent_simple_secret_new (_("Service"), NM_SETTING (s_pppoe), NM_SETTING_PPPOE_SERVICE, FALSE); g_ptr_array_add (secrets, secret); secret = nm_secret_agent_simple_secret_new (_("Password"), NM_SETTING (s_pppoe), NM_SETTING_PPPOE_PASSWORD, TRUE); g_ptr_array_add (secrets, secret); return TRUE; }
gboolean nm_ppp_manager_start (NMPPPManager *manager, NMActRequest *req, const char *ppp_name, guint32 timeout_secs, GError **err) { NMPPPManagerPrivate *priv; NMConnection *connection; NMSettingPpp *s_ppp; gboolean s_ppp_created = FALSE; NMSettingPppoe *pppoe_setting; NMSettingAdsl *adsl_setting; NMCmdLine *ppp_cmd; char *cmd_str; struct stat st; g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE); g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE); priv = NM_PPP_MANAGER_GET_PRIVATE (manager); #if !WITH_PPP /* PPP support disabled */ g_set_error_literal (err, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED, "PPP support is not enabled."); return FALSE; #endif priv->pid = 0; /* Make sure /dev/ppp exists (bgo #533064) */ if (stat ("/dev/ppp", &st) || !S_ISCHR (st.st_mode)) nm_utils_modprobe (NULL, FALSE, "ppp_generic", NULL); connection = nm_act_request_get_applied_connection (req); g_assert (connection); s_ppp = nm_connection_get_setting_ppp (connection); if (!s_ppp) { /* If the PPP settings are all default we may not have a PPP setting yet, * so just make a default one here. */ s_ppp = NM_SETTING_PPP (nm_setting_ppp_new ()); s_ppp_created = TRUE; } pppoe_setting = nm_connection_get_setting_pppoe (connection); if (pppoe_setting) pppoe_fill_defaults (s_ppp); adsl_setting = (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL); ppp_cmd = create_pppd_cmd_line (manager, s_ppp, pppoe_setting, adsl_setting, ppp_name, err); if (!ppp_cmd) goto out; g_ptr_array_add (ppp_cmd->array, NULL); _LOGI ("starting PPP connection"); cmd_str = nm_cmd_line_to_str (ppp_cmd); _LOGD ("command line: %s", cmd_str); g_free (cmd_str); priv->pid = 0; if (!g_spawn_async (NULL, (char **) ppp_cmd->array->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD, nm_utils_setpgid, NULL, &priv->pid, err)) { goto out; } _LOGI ("pppd started with pid %d", priv->pid); priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager); priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager); priv->act_req = g_object_ref (req); out: if (s_ppp_created) g_object_unref (s_ppp); if (ppp_cmd) nm_cmd_line_destroy (ppp_cmd); return priv->pid > 0; }