static gboolean nm_sstp_start_pppd_binary (NMSstpPlugin *plugin, NMSettingVpn *s_vpn, const char *gwaddr, GError **error) { NMSstpPluginPrivate *priv = NM_SSTP_PLUGIN_GET_PRIVATE (plugin); GPid pid; const char *pppd_binary; GPtrArray *pppd_argv; pppd_binary = nm_find_pppd (); if (!pppd_binary) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED, "%s", _("Could not find the pppd binary.")); return FALSE; } pppd_argv = construct_pppd_args (plugin, s_vpn, pppd_binary, gwaddr, error); if (!pppd_argv) return FALSE; if (!g_spawn_async (NULL, (char **) pppd_argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, error)) { g_ptr_array_free (pppd_argv, TRUE); return FALSE; } free_pppd_args (pppd_argv); g_message ("pppd started with pid %d", pid); NM_SSTP_PLUGIN_GET_PRIVATE (plugin)->pid = pid; g_child_watch_add (pid, pppd_watch_cb, plugin); priv->ppp_timeout_handler = g_timeout_add (NM_SSTP_WAIT_PPPD, pppd_timed_out, plugin); return TRUE; }
static NMCmdLine * create_pppd_cmd_line (NMPPPManager *self, NMSettingPPP *setting, NMSettingPPPOE *pppoe, const char *ppp_name, GError **err) { NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self); const char *ppp_binary; NMCmdLine *cmd; gboolean ppp_debug; g_return_val_if_fail (setting != NULL, NULL); ppp_binary = nm_find_pppd (); if (!ppp_binary) { g_set_error (err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR, "Could not find ppp binary."); return NULL; } /* Create pppd command line */ cmd = nm_cmd_line_new (); nm_cmd_line_add_string (cmd, ppp_binary); nm_cmd_line_add_string (cmd, "nodetach"); nm_cmd_line_add_string (cmd, "lock"); /* NM handles setting the default route */ nm_cmd_line_add_string (cmd, "nodefaultroute"); ppp_debug = !!getenv ("NM_PPP_DEBUG"); if ( nm_logging_level_enabled (LOGL_DEBUG) && nm_logging_domain_enabled (LOGD_PPP)) ppp_debug = TRUE; if (ppp_debug) nm_cmd_line_add_string (cmd, "debug"); if (ppp_name) { nm_cmd_line_add_string (cmd, "user"); nm_cmd_line_add_string (cmd, ppp_name); } if (pppoe) { char *dev_str; const char *pppoe_service; nm_cmd_line_add_string (cmd, "plugin"); nm_cmd_line_add_string (cmd, "rp-pppoe.so"); dev_str = g_strdup_printf ("nic-%s", priv->parent_iface); nm_cmd_line_add_string (cmd, dev_str); g_free (dev_str); pppoe_service = nm_setting_pppoe_get_service (pppoe); if (pppoe_service) { nm_cmd_line_add_string (cmd, "rp_pppoe_service"); nm_cmd_line_add_string (cmd, pppoe_service); } } else { nm_cmd_line_add_string (cmd, priv->parent_iface); /* Don't send some random address as the local address */ nm_cmd_line_add_string (cmd, "noipdefault"); } if (nm_setting_ppp_get_baud (setting)) nm_cmd_line_add_int (cmd, nm_setting_ppp_get_baud (setting)); /* noauth by default, because we certainly don't have any information * with which to verify anything the peer gives us if we ask it to * authenticate itself, which is what 'auth' really means. */ nm_cmd_line_add_string (cmd, "noauth"); if (nm_setting_ppp_get_refuse_eap (setting)) nm_cmd_line_add_string (cmd, "refuse-eap"); if (nm_setting_ppp_get_refuse_pap (setting)) nm_cmd_line_add_string (cmd, "refuse-pap"); if (nm_setting_ppp_get_refuse_chap (setting)) nm_cmd_line_add_string (cmd, "refuse-chap"); if (nm_setting_ppp_get_refuse_mschap (setting)) nm_cmd_line_add_string (cmd, "refuse-mschap"); if (nm_setting_ppp_get_refuse_mschapv2 (setting)) nm_cmd_line_add_string (cmd, "refuse-mschap-v2"); if (nm_setting_ppp_get_nobsdcomp (setting)) nm_cmd_line_add_string (cmd, "nobsdcomp"); if (nm_setting_ppp_get_no_vj_comp (setting)) nm_cmd_line_add_string (cmd, "novj"); if (nm_setting_ppp_get_nodeflate (setting)) nm_cmd_line_add_string (cmd, "nodeflate"); if (nm_setting_ppp_get_require_mppe (setting)) nm_cmd_line_add_string (cmd, "require-mppe"); if (nm_setting_ppp_get_require_mppe_128 (setting)) nm_cmd_line_add_string (cmd, "require-mppe-128"); if (nm_setting_ppp_get_mppe_stateful (setting)) nm_cmd_line_add_string (cmd, "mppe-stateful"); if (nm_setting_ppp_get_crtscts (setting)) nm_cmd_line_add_string (cmd, "crtscts"); /* Always ask for DNS, we don't have to use them if the connection * overrides the returned servers. */ nm_cmd_line_add_string (cmd, "usepeerdns"); if (nm_setting_ppp_get_mru (setting)) { nm_cmd_line_add_string (cmd, "mru"); nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mru (setting)); } if (nm_setting_ppp_get_mtu (setting)) { nm_cmd_line_add_string (cmd, "mtu"); nm_cmd_line_add_int (cmd, nm_setting_ppp_get_mtu (setting)); } nm_cmd_line_add_string (cmd, "lcp-echo-failure"); nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_failure (setting)); nm_cmd_line_add_string (cmd, "lcp-echo-interval"); nm_cmd_line_add_int (cmd, nm_setting_ppp_get_lcp_echo_interval (setting)); nm_cmd_line_add_string (cmd, "ipparam"); nm_cmd_line_add_string (cmd, priv->dbus_path); nm_cmd_line_add_string (cmd, "plugin"); nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN); return cmd; }