removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -59,7 +59,7 @@ static GValue* handler_to_val(nm_handler_t *handler,
|
||||
GArray *array;
|
||||
enumerator_t *enumerator;
|
||||
chunk_t chunk;
|
||||
|
||||
|
||||
enumerator = handler->create_enumerator(handler, type);
|
||||
array = g_array_new (FALSE, TRUE, sizeof (guint32));
|
||||
while (enumerator->enumerate(enumerator, &chunk))
|
||||
@@ -70,7 +70,7 @@ static GValue* handler_to_val(nm_handler_t *handler,
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
|
||||
g_value_set_boxed (val, array);
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -84,37 +84,37 @@ static void signal_ipv4_config(NMVPNPlugin *plugin,
|
||||
GHashTable *config;
|
||||
host_t *me, *other;
|
||||
nm_handler_t *handler;
|
||||
|
||||
|
||||
config = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
me = ike_sa->get_my_host(ike_sa);
|
||||
other = ike_sa->get_other_host(ike_sa);
|
||||
handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
|
||||
|
||||
|
||||
/* NM requires a tundev, but netkey does not use one. Passing an invalid
|
||||
* iface makes NM complain, but it accepts it without fiddling on eth0. */
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, "none");
|
||||
g_hash_table_insert (config, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV, val);
|
||||
|
||||
|
||||
val = g_slice_new0(GValue);
|
||||
g_value_init(val, G_TYPE_UINT);
|
||||
g_value_set_uint(val, *(u_int32_t*)me->get_address(me).ptr);
|
||||
g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS, val);
|
||||
|
||||
|
||||
val = g_slice_new0(GValue);
|
||||
g_value_init(val, G_TYPE_UINT);
|
||||
g_value_set_uint(val, me->get_address(me).len * 8);
|
||||
g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, val);
|
||||
|
||||
|
||||
val = handler_to_val(handler, INTERNAL_IP4_DNS);
|
||||
g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_DNS, val);
|
||||
|
||||
|
||||
val = handler_to_val(handler, INTERNAL_IP4_NBNS);
|
||||
g_hash_table_insert(config, NM_VPN_PLUGIN_IP4_CONFIG_NBNS, val);
|
||||
|
||||
|
||||
handler->reset(handler);
|
||||
|
||||
|
||||
nm_vpn_plugin_set_ip4_config(plugin, config);
|
||||
}
|
||||
|
||||
@@ -124,11 +124,11 @@ static void signal_ipv4_config(NMVPNPlugin *plugin,
|
||||
static void signal_failure(NMVPNPlugin *plugin, NMVPNPluginFailure failure)
|
||||
{
|
||||
nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
|
||||
|
||||
|
||||
handler->reset(handler);
|
||||
|
||||
|
||||
/* TODO: NM does not handle this failure!? */
|
||||
nm_vpn_plugin_failure(plugin, failure);
|
||||
nm_vpn_plugin_failure(plugin, failure);
|
||||
nm_vpn_plugin_set_state(plugin, NM_VPN_SERVICE_STATE_STOPPED);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static bool ike_state_change(listener_t *listener, ike_sa_t *ike_sa,
|
||||
ike_sa_state_t state)
|
||||
{
|
||||
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
|
||||
|
||||
|
||||
if (private->ike_sa == ike_sa && state == IKE_DESTROYING)
|
||||
{
|
||||
signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
|
||||
@@ -155,7 +155,7 @@ static bool child_state_change(listener_t *listener, ike_sa_t *ike_sa,
|
||||
child_sa_t *child_sa, child_sa_state_t state)
|
||||
{
|
||||
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
|
||||
|
||||
|
||||
if (private->ike_sa == ike_sa && state == CHILD_DESTROYING)
|
||||
{
|
||||
signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
|
||||
@@ -171,7 +171,7 @@ static bool child_updown(listener_t *listener, ike_sa_t *ike_sa,
|
||||
child_sa_t *child_sa, bool up)
|
||||
{
|
||||
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
|
||||
|
||||
|
||||
if (private->ike_sa == ike_sa)
|
||||
{
|
||||
if (up)
|
||||
@@ -195,7 +195,7 @@ static bool child_updown(listener_t *listener, ike_sa_t *ike_sa,
|
||||
static bool ike_rekey(listener_t *listener, ike_sa_t *old, ike_sa_t *new)
|
||||
{
|
||||
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
|
||||
|
||||
|
||||
if (private->ike_sa == old)
|
||||
{ /* follow a rekeyed IKE_SA */
|
||||
private->ike_sa = new;
|
||||
@@ -232,7 +232,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
.jitter = 300 /* 5min */
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Read parameters
|
||||
*/
|
||||
@@ -280,12 +280,12 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
auth_class = AUTH_CLASS_PUBKEY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register credentials
|
||||
*/
|
||||
priv->creds->clear(priv->creds);
|
||||
|
||||
|
||||
/* gateway/CA cert */
|
||||
str = nm_setting_vpn_get_data_item(vpn, "certificate");
|
||||
if (str)
|
||||
@@ -315,7 +315,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
gateway = gateway->clone(gateway);
|
||||
DBG1(DBG_CFG, "using gateway certificate, identity '%Y'", gateway);
|
||||
}
|
||||
|
||||
|
||||
if (auth_class == AUTH_CLASS_EAP)
|
||||
{
|
||||
/* username/password authentication ... */
|
||||
@@ -327,7 +327,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
priv->creds->set_username_password(priv->creds, user, (char*)str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (auth_class == AUTH_CLASS_PUBKEY)
|
||||
{
|
||||
/* ... or certificate/private key authenitcation */
|
||||
@@ -336,7 +336,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
{
|
||||
public_key_t *public;
|
||||
private_key_t *private = NULL;
|
||||
|
||||
|
||||
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
|
||||
BUILD_FROM_FILE, str, BUILD_END);
|
||||
if (!cert)
|
||||
@@ -347,7 +347,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
gateway->destroy(gateway);
|
||||
return FALSE;
|
||||
}
|
||||
/* try agent */
|
||||
/* try agent */
|
||||
str = nm_setting_vpn_get_secret(vpn, "agent");
|
||||
if (agent && str)
|
||||
{
|
||||
@@ -368,12 +368,12 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
"Connecting to SSH agent failed.");
|
||||
}
|
||||
}
|
||||
/* ... or key file */
|
||||
/* ... or key file */
|
||||
str = nm_setting_vpn_get_data_item(vpn, "userkey");
|
||||
if (!agent && str)
|
||||
{
|
||||
chunk_t secret;
|
||||
|
||||
|
||||
secret.ptr = (char*)nm_setting_vpn_get_secret(vpn, "password");
|
||||
if (secret.ptr)
|
||||
{
|
||||
@@ -403,7 +403,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!user)
|
||||
{
|
||||
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
|
||||
@@ -411,7 +411,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
gateway->destroy(gateway);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set up configurations
|
||||
*/
|
||||
@@ -432,7 +432,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
|
||||
auth->add(auth, AUTH_RULE_IDENTITY, gateway);
|
||||
peer_cfg->add_auth_cfg(peer_cfg, auth, FALSE);
|
||||
|
||||
|
||||
child_cfg = child_cfg_create(priv->name, &lifetime,
|
||||
NULL, TRUE, MODE_TUNNEL, /* updown, hostaccess */
|
||||
ACTION_NONE, ACTION_NONE, ipcomp);
|
||||
@@ -444,7 +444,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
"255.255.255.255", 65535);
|
||||
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
|
||||
peer_cfg->add_child_cfg(peer_cfg, child_cfg);
|
||||
|
||||
|
||||
/**
|
||||
* Prepare IKE_SA
|
||||
*/
|
||||
@@ -458,7 +458,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
{
|
||||
peer_cfg->destroy(peer_cfg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register listener, enable initiate-failure-detection hooks
|
||||
*/
|
||||
@@ -466,7 +466,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
priv->listener.ike_state_change = ike_state_change;
|
||||
priv->listener.child_state_change = child_state_change;
|
||||
charon->bus->add_listener(charon->bus, &priv->listener);
|
||||
|
||||
|
||||
/**
|
||||
* Initiate
|
||||
*/
|
||||
@@ -474,7 +474,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
{
|
||||
charon->bus->remove_listener(charon->bus, &priv->listener);
|
||||
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, ike_sa);
|
||||
|
||||
|
||||
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
|
||||
"Initiating failed.");
|
||||
return FALSE;
|
||||
@@ -484,14 +484,14 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
}
|
||||
|
||||
/**
|
||||
* NeedSecrets called from NM via DBUS
|
||||
* NeedSecrets called from NM via DBUS
|
||||
*/
|
||||
static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
char **setting_name, GError **error)
|
||||
{
|
||||
NMSettingVPN *settings;
|
||||
const char *method, *path;
|
||||
|
||||
|
||||
settings = NM_SETTING_VPN(nm_connection_get_setting(connection,
|
||||
NM_TYPE_SETTING_VPN));
|
||||
method = nm_setting_vpn_get_data_item(settings, "method");
|
||||
@@ -518,7 +518,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
{
|
||||
private_key_t *key;
|
||||
chunk_t secret;
|
||||
|
||||
|
||||
secret.ptr = (char*)nm_setting_vpn_get_secret(settings, "password");
|
||||
if (secret.ptr)
|
||||
{
|
||||
@@ -541,7 +541,7 @@ static gboolean need_secrets(NMVPNPlugin *plugin, NMConnection *connection,
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect called from NM via DBUS
|
||||
* Disconnect called from NM via DBUS
|
||||
*/
|
||||
static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
|
||||
{
|
||||
@@ -549,7 +549,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
|
||||
enumerator_t *enumerator;
|
||||
ike_sa_t *ike_sa;
|
||||
u_int id;
|
||||
|
||||
|
||||
/* our ike_sa pointer might be invalid, lookup sa */
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
|
||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||
@@ -564,7 +564,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
|
||||
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_GENERAL,
|
||||
"Connection not found.");
|
||||
return FALSE;
|
||||
@@ -576,7 +576,7 @@ static gboolean disconnect(NMVPNPlugin *plugin, GError **err)
|
||||
static void nm_strongswan_plugin_init(NMStrongswanPlugin *plugin)
|
||||
{
|
||||
NMStrongswanPluginPrivate *priv;
|
||||
|
||||
|
||||
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
|
||||
priv->plugin = NM_VPN_PLUGIN(plugin);
|
||||
memset(&priv->listener.log, 0, sizeof(listener_t));
|
||||
@@ -591,7 +591,7 @@ static void nm_strongswan_plugin_class_init(
|
||||
NMStrongswanPluginClass *strongswan_class)
|
||||
{
|
||||
NMVPNPluginClass *parent_class = NM_VPN_PLUGIN_CLASS(strongswan_class);
|
||||
|
||||
|
||||
g_type_class_add_private(G_OBJECT_CLASS(strongswan_class),
|
||||
sizeof(NMStrongswanPluginPrivate));
|
||||
parent_class->connect = connect_;
|
||||
@@ -612,7 +612,7 @@ NMStrongswanPlugin *nm_strongswan_plugin_new(nm_creds_t *creds,
|
||||
if (plugin)
|
||||
{
|
||||
NMStrongswanPluginPrivate *priv;
|
||||
|
||||
|
||||
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
|
||||
priv->creds = creds;
|
||||
priv->handler = handler;
|
||||
|
||||
Reference in New Issue
Block a user