Commit 66cfc254 authored by microcai's avatar microcai

fix to support nm-0.9

parent cbfdb0c0
...@@ -231,6 +231,9 @@ fill_password (GladeXML *xml, ...@@ -231,6 +231,9 @@ fill_password (GladeXML *xml,
{ {
GtkWidget *widget = NULL; GtkWidget *widget = NULL;
gchar *password = NULL; gchar *password = NULL;
NMSettingVPN *s_vpn;
gboolean unused;
widget = glade_xml_get_widget (xml, widget_name); widget = glade_xml_get_widget (xml, widget_name);
g_assert (widget); g_assert (widget);
...@@ -238,27 +241,18 @@ fill_password (GladeXML *xml, ...@@ -238,27 +241,18 @@ fill_password (GladeXML *xml,
if (!connection) if (!connection)
return widget; return widget;
password = NULL; /* Try the connection first */
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) { if (s_vpn) {
NMSettingVPN *s_vpn; const gchar *tmp = NULL;
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (s_vpn) {
const gchar *tmp = NULL;
tmp = nm_setting_vpn_get_secret (s_vpn, password_type); tmp = nm_setting_vpn_get_secret (s_vpn, password_type);
if (tmp) if (tmp)
password = gnome_keyring_memory_strdup (tmp); password = gnome_keyring_memory_strdup (tmp);
} }
} else {
NMSettingConnection *s_con = NULL;
gboolean unused;
const char *uuid;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION)); if (!password) {
uuid = nm_setting_connection_get_uuid (s_con); password = keyring_helpers_lookup_secret (nm_connection_get_uuid (connection),
password = keyring_helpers_lookup_secret (uuid,
password_type, password_type,
&unused); &unused);
} }
......
...@@ -79,7 +79,7 @@ typedef struct { ...@@ -79,7 +79,7 @@ typedef struct {
GType nm_l2tp_ppp_service_get_type (void); GType nm_l2tp_ppp_service_get_type (void);
G_DEFINE_TYPE (NML2tpPppService, nm_l2tp_ppp_service, G_TYPE_OBJECT) G_DEFINE_TYPE (NML2tpPppService, nm_l2tp_ppp_service, G_TYPE_OBJECT);
static gboolean impl_l2tp_service_need_secrets (NML2tpPppService *self, static gboolean impl_l2tp_service_need_secrets (NML2tpPppService *self,
char **out_username, char **out_username,
...@@ -130,7 +130,7 @@ nm_l2tp_ppp_service_new (void) ...@@ -130,7 +130,7 @@ nm_l2tp_ppp_service_new (void)
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (!connection) { if (!connection) {
nm_warning ("Could not get the system bus. Make sure " g_warning ("Could not get the system bus. Make sure "
"the message bus daemon is running! Message: %s", "the message bus daemon is running! Message: %s",
error->message); error->message);
g_error_free (error); g_error_free (error);
...@@ -152,7 +152,7 @@ nm_l2tp_ppp_service_new (void) ...@@ -152,7 +152,7 @@ nm_l2tp_ppp_service_new (void)
dbus_g_connection_register_g_object (connection, NM_DBUS_PATH_L2TP_PPP, object); dbus_g_connection_register_g_object (connection, NM_DBUS_PATH_L2TP_PPP, object);
success = TRUE; success = TRUE;
} else { } else {
nm_warning ("Could not register D-Bus service name. Message: %s", error->message); g_warning ("Could not register D-Bus service name. Message: %s", error->message);
g_error_free (error); g_error_free (error);
g_object_unref (object); g_object_unref (object);
object = NULL; object = NULL;
...@@ -335,7 +335,7 @@ impl_l2tp_service_set_ip4_config (NML2tpPppService *self, ...@@ -335,7 +335,7 @@ impl_l2tp_service_set_ip4_config (NML2tpPppService *self,
GHashTable *config_hash, GHashTable *config_hash,
GError **err) GError **err)
{ {
nm_info ("L2TP service (IP Config Get) reply received."); g_message( ("L2TP service (IP Config Get) reply received."));
g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0); g_signal_emit (G_OBJECT (self), signals[PLUGIN_ALIVE], 0);
/* Just forward the pppd plugin config up to our superclass; no need to modify it */ /* Just forward the pppd plugin config up to our superclass; no need to modify it */
...@@ -349,7 +349,7 @@ impl_l2tp_service_set_ip4_config (NML2tpPppService *self, ...@@ -349,7 +349,7 @@ impl_l2tp_service_set_ip4_config (NML2tpPppService *self,
/* The VPN plugin service */ /* The VPN plugin service */
/********************************************************/ /********************************************************/
G_DEFINE_TYPE (NML2tpPlugin, nm_l2tp_plugin, NM_TYPE_VPN_PLUGIN) G_DEFINE_TYPE (NML2tpPlugin, nm_l2tp_plugin, NM_TYPE_VPN_PLUGIN);
typedef struct { typedef struct {
GPid pid; GPid pid;
...@@ -570,14 +570,14 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data) ...@@ -570,14 +570,14 @@ l2tpd_watch_cb (GPid pid, gint status, gpointer user_data)
if (WIFEXITED (status)) { if (WIFEXITED (status)) {
error = WEXITSTATUS (status); error = WEXITSTATUS (status);
if (error != 0) if (error != 0)
nm_warning ("xl2tpd exited with error code %d", error); g_warning ("xl2tpd exited with error code %d", error);
} }
else if (WIFSTOPPED (status)) else if (WIFSTOPPED (status))
nm_warning ("xl2tpd stopped unexpectedly with signal %d", WSTOPSIG (status)); g_warning ("xl2tpd stopped unexpectedly with signal %d", WSTOPSIG (status));
else if (WIFSIGNALED (status)) else if (WIFSIGNALED (status))
nm_warning ("xl2tpd died with signal %d", WTERMSIG (status)); g_warning ("xl2tpd died with signal %d", WTERMSIG (status));
else else
nm_warning ("xl2tpd died from an unknown cause"); g_warning ("xl2tpd died from an unknown cause");
/* Reap child if needed. */ /* Reap child if needed. */
waitpid (priv->pid, NULL, WNOHANG); waitpid (priv->pid, NULL, WNOHANG);
...@@ -641,7 +641,7 @@ pppd_timed_out (gpointer user_data) ...@@ -641,7 +641,7 @@ pppd_timed_out (gpointer user_data)
{ {
NML2tpPlugin *plugin = NM_L2TP_PLUGIN (user_data); NML2tpPlugin *plugin = NM_L2TP_PLUGIN (user_data);
nm_warning ("Looks like pppd didn't initialize our dbus module"); g_warning ("Looks like pppd didn't initialize our dbus module");
nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT); nm_vpn_plugin_failure (NM_VPN_PLUGIN (plugin), NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT);
return FALSE; return FALSE;
...@@ -721,13 +721,13 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection) ...@@ -721,13 +721,13 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection)
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (!s_vpn) { if (!s_vpn) {
nm_warning ("couldn't get VPN setting"); g_warning ("couldn't get VPN setting");
return NULL; return NULL;
} }
p = tmp = nm_setting_vpn_get_data_item (s_vpn, NM_L2TP_KEY_GATEWAY); p = tmp = nm_setting_vpn_get_data_item (s_vpn, NM_L2TP_KEY_GATEWAY);
if (!tmp || !strlen (tmp)) { if (!tmp || !strlen (tmp)) {
nm_warning ("couldn't get L2TP VPN gateway IP address"); g_warning ("couldn't get L2TP VPN gateway IP address");
return NULL; return NULL;
} }
...@@ -751,7 +751,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection) ...@@ -751,7 +751,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection)
hints.ai_flags = AI_ADDRCONFIG; hints.ai_flags = AI_ADDRCONFIG;
err = getaddrinfo (tmp, NULL, &hints, &result); err = getaddrinfo (tmp, NULL, &hints, &result);
if (err != 0) { if (err != 0) {
nm_warning ("couldn't look up L2TP VPN gateway IP address '%s' (%d)", tmp, err); g_warning ("couldn't look up L2TP VPN gateway IP address '%s' (%d)", tmp, err);
return NULL; return NULL;
} }
...@@ -773,7 +773,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection) ...@@ -773,7 +773,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection)
} else { } else {
errno = 0; errno = 0;
if (inet_pton (AF_INET, tmp, &addr) <= 0) { if (inet_pton (AF_INET, tmp, &addr) <= 0) {
nm_warning ("couldn't convert L2TP VPN gateway IP address '%s' (%d)", tmp, errno); g_warning ("couldn't convert L2TP VPN gateway IP address '%s' (%d)", tmp, errno);
return NULL; return NULL;
} }
} }
...@@ -783,7 +783,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection) ...@@ -783,7 +783,7 @@ get_l2tp_gw_address_as_gvalue (NMConnection *connection)
g_value_init (value, G_TYPE_UINT); g_value_init (value, G_TYPE_UINT);
g_value_set_uint (value, (guint32) addr.s_addr); g_value_set_uint (value, (guint32) addr.s_addr);
} else } else
nm_warning ("couldn't determine L2TP VPN gateway IP address from '%s'", tmp); g_warning ("couldn't determine L2TP VPN gateway IP address from '%s'", tmp);
return value; return value;
} }
...@@ -861,7 +861,7 @@ nm_l2tp_start_l2tpd_binary (NML2tpPlugin *plugin, ...@@ -861,7 +861,7 @@ nm_l2tp_start_l2tpd_binary (NML2tpPlugin *plugin,
} }
free_l2tpd_args (l2tpd_argv); free_l2tpd_args (l2tpd_argv);
nm_info ("xl2tpd started with pid %d", pid); g_message("xl2tpd started with pid %d",pid);
NM_L2TP_PLUGIN_GET_PRIVATE (plugin)->pid = pid; NM_L2TP_PLUGIN_GET_PRIVATE (plugin)->pid = pid;
g_child_watch_add (pid, l2tpd_watch_cb, plugin); g_child_watch_add (pid, l2tpd_watch_cb, plugin);
...@@ -1041,7 +1041,7 @@ nm_l2tp_config_write (NML2tpPlugin *plugin, ...@@ -1041,7 +1041,7 @@ nm_l2tp_config_write (NML2tpPlugin *plugin,
if (errno == 0) { if (errno == 0) {
write_config_option (pppopt_fd, "lcp-echo-failure %ld\n", tmp_int); write_config_option (pppopt_fd, "lcp-echo-failure %ld\n", tmp_int);
} else { } else {
nm_warning ("failed to convert lcp-echo-failure value '%s'", value); g_warning ("failed to convert lcp-echo-failure value '%s'", value);
} }
} else { } else {
write_config_option (pppopt_fd, "lcp-echo-failure 0\n"); write_config_option (pppopt_fd, "lcp-echo-failure 0\n");
...@@ -1059,7 +1059,7 @@ nm_l2tp_config_write (NML2tpPlugin *plugin, ...@@ -1059,7 +1059,7 @@ nm_l2tp_config_write (NML2tpPlugin *plugin,
if (errno == 0) { if (errno == 0) {
write_config_option (pppopt_fd, "lcp-echo-interval %ld\n", tmp_int); write_config_option (pppopt_fd, "lcp-echo-interval %ld\n", tmp_int);
} else { } else {
nm_warning ("failed to convert lcp-echo-interval value '%s'", value); g_warning ("failed to convert lcp-echo-interval value '%s'", value);
} }
} else { } else {
write_config_option (pppopt_fd, "lcp-echo-interval 0\n"); write_config_option (pppopt_fd, "lcp-echo-interval 0\n");
...@@ -1173,7 +1173,7 @@ real_disconnect (NMVPNPlugin *plugin, ...@@ -1173,7 +1173,7 @@ real_disconnect (NMVPNPlugin *plugin,
else else
kill (priv->pid, SIGKILL); kill (priv->pid, SIGKILL);
nm_info ("Terminated ppp daemon with PID %d.", priv->pid); g_message("Terminated ppp daemon with PID %d.", priv->pid);
priv->pid = 0; priv->pid = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment