mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 12:10:15 +01:00
Merge commit 'a734c836a56f3170202f0555f1a03c9b2835775c' into NETWORKMANAGER_0_7
Conflicts: libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h src/dhcp-manager/nm-dhcp-manager.c
This commit is contained in:
commit
6e120709e2
347 changed files with 3751 additions and 63412 deletions
|
|
@ -51,9 +51,10 @@ EXTRA_DIST = \
|
|||
intltool-merge.in \
|
||||
intltool-update.in
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --with-tests=yes
|
||||
|
||||
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = NetworkManager.pc
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include <NetworkManager.h>
|
||||
#include "nm-glib-compat.h"
|
||||
#include <libnm-util/nm-connection.h>
|
||||
#include <libnm-util/nm-setting-ip4-config.h>
|
||||
#include <libnm-util/nm-setting-connection.h>
|
||||
|
|
@ -486,7 +487,7 @@ nm_dispatcher_action (Handler *h,
|
|||
if (d->quit_timeout)
|
||||
g_source_remove (d->quit_timeout);
|
||||
if (!d->persist)
|
||||
d->quit_timeout = g_timeout_add (10000, quit_timeout_cb, NULL);
|
||||
d->quit_timeout = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
|
||||
|
||||
connection = nm_connection_new_from_hash (connection_hash, error);
|
||||
if (connection) {
|
||||
|
|
@ -780,7 +781,7 @@ main (int argc, char **argv)
|
|||
G_OBJECT (d->handler));
|
||||
|
||||
if (!persist)
|
||||
d->quit_timeout = g_timeout_add (10000, quit_timeout_cb, NULL);
|
||||
d->quit_timeout = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
|
||||
|
||||
g_main_loop_run (loop);
|
||||
|
||||
|
|
|
|||
23
configure.in
23
configure.in
|
|
@ -477,10 +477,26 @@ fi
|
|||
|
||||
GTK_DOC_CHECK(1.0)
|
||||
|
||||
dnl
|
||||
dnl Tests
|
||||
dnl
|
||||
AC_ARG_WITH(tests, AC_HELP_STRING([--with-tests], [Build NetworkManager tests]))
|
||||
AM_CONDITIONAL(WITH_TESTS, test "x$with_tests" = "xyes")
|
||||
case $with_tests in
|
||||
yes)
|
||||
with_tests=yes
|
||||
;;
|
||||
*)
|
||||
with_tests=no
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
src/tests/Makefile
|
||||
marshallers/Makefile
|
||||
src/named-manager/Makefile
|
||||
src/vpn-manager/Makefile
|
||||
|
|
@ -491,6 +507,8 @@ src/dnsmasq-manager/Makefile
|
|||
src/backends/Makefile
|
||||
libnm-util/libnm-util.pc
|
||||
libnm-util/Makefile
|
||||
libnm-util/tests/Makefile
|
||||
libnm-util/tests/certs/Makefile
|
||||
libnm-glib/libnm_glib.pc
|
||||
libnm-glib/libnm_glib_vpn.pc
|
||||
libnm-glib/Makefile
|
||||
|
|
@ -504,6 +522,9 @@ system-settings/plugins/ifupdown/Makefile
|
|||
system-settings/plugins/ifcfg-rh/Makefile
|
||||
system-settings/plugins/ifcfg-suse/Makefile
|
||||
system-settings/plugins/keyfile/Makefile
|
||||
system-settings/plugins/keyfile/io/Makefile
|
||||
system-settings/plugins/keyfile/tests/Makefile
|
||||
system-settings/plugins/keyfile/tests/keyfiles/Makefile
|
||||
test/Makefile
|
||||
initscript/Makefile
|
||||
initscript/RedHat/Makefile
|
||||
|
|
@ -541,4 +562,6 @@ echo 'if this is not correct, please specifiy your distro with --with-distro=DIS
|
|||
echo
|
||||
echo Building documentation: ${with_docs}
|
||||
echo
|
||||
echo Building tests: ${with_tests}
|
||||
echo
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,11 @@ _im_add (inotify_sub *sub)
|
|||
if (!scan_missing_running)
|
||||
{
|
||||
scan_missing_running = TRUE;
|
||||
#if !GLIB_CHECK_VERSION(2,14,0)
|
||||
g_timeout_add (SCAN_MISSING_TIME * G_USEC_PER_SEC, im_scan_missing, NULL);
|
||||
#else
|
||||
g_timeout_add_seconds (SCAN_MISSING_TIME, im_scan_missing, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ EXTRA_DIST = \
|
|||
NetworkManager.h \
|
||||
NetworkManagerVPN.h \
|
||||
wireless-helper.h \
|
||||
nm-dbus-glib-types.h
|
||||
nm-dbus-glib-types.h \
|
||||
nm-glib-compat.h \
|
||||
nm-test-helpers.h
|
||||
|
||||
NetworkManagerincludedir=$(includedir)/NetworkManager
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -17,16 +16,22 @@
|
|||
* 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 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _IMPORT_EXPORT_H_
|
||||
#define _IMPORT_EXPORT_H_
|
||||
#ifndef NM_GLIB_COMPAT_H
|
||||
#define NM_GLIB_COMPAT_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <nm-connection.h>
|
||||
|
||||
NMConnection *do_import (const char *path, char **lines, GError **error);
|
||||
#if !GLIB_CHECK_VERSION(2,14,0)
|
||||
|
||||
gboolean do_export (const char *path, NMConnection *connection, GError **error);
|
||||
#define g_timeout_add_seconds(i, f, d) \
|
||||
g_timeout_add (i * G_USEC_PER_SEC, f, d)
|
||||
|
||||
#endif
|
||||
#define g_timeout_add_seconds_full(p, i, f, d, n) \
|
||||
g_timeout_add_full (p, i * G_USEC_PER_SEC, f, d, n)
|
||||
|
||||
#endif /* !GLIB_CHECK_VERSION(2,14,0) */
|
||||
|
||||
#endif /* NM_GLIB_COMPAT_H */
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -17,16 +16,33 @@
|
|||
* 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 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _IMPORT_EXPORT_H_
|
||||
#define _IMPORT_EXPORT_H_
|
||||
#ifndef NM_TEST_HELPERS_H
|
||||
#define NM_TEST_HELPERS_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <nm-connection.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
NMConnection *do_import (const char *path, char **lines, GError **error);
|
||||
static void
|
||||
FAIL(const char *test_name, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[500];
|
||||
|
||||
gboolean do_export (const char *path, NMConnection *connection, GError **error);
|
||||
snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
|
||||
|
||||
va_start (args, fmt);
|
||||
vfprintf (stderr, buf, args);
|
||||
va_end (args);
|
||||
_exit (1);
|
||||
}
|
||||
|
||||
#define ASSERT(x, test_name, fmt, ...) \
|
||||
if (!(x)) { \
|
||||
FAIL (test_name, fmt, ## __VA_ARGS__); \
|
||||
}
|
||||
|
||||
#endif /* NM_TEST_HELPERS_H */
|
||||
|
||||
#endif
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
<property name="Default" type="b" access="read">
|
||||
<tp:docstring>Whether this active connection is the default connection, i.e. whether it currently owns the default route.</tp:docstring>
|
||||
</property>
|
||||
<property name="Vpn" type="b" access="read">
|
||||
<tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>
|
||||
</property>
|
||||
|
||||
<signal name="PropertiesChanged">
|
||||
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
|
||||
|
|
|
|||
|
|
@ -47,11 +47,9 @@
|
|||
Whether or not this device is managed by NetworkManager.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<!-- Ugh, but I see no other way of getting the type on the caller
|
||||
based on dbus object path only -->
|
||||
<property name="DeviceType" type="u" access="read">
|
||||
<property name="DeviceType" type="u" access="read" tp:type="NM_DEVICE_TYPE">
|
||||
<tp:docstring>
|
||||
The general type of the network device; ie Ethernet, WiFi, etc.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
|
|
@ -127,6 +125,34 @@
|
|||
</tp:enumvalue>
|
||||
</tp:enum>
|
||||
|
||||
<tp:enum name="NM_DEVICE_TYPE" type="u">
|
||||
<tp:enumvalue suffix="UNKNOWN" value="0">
|
||||
<tp:docstring>
|
||||
The device type is unknown.
|
||||
</tp:docstring>
|
||||
</tp:enumvalue>
|
||||
<tp:enumvalue suffix="ETHERNET" value="1">
|
||||
<tp:docstring>
|
||||
The device is wired Ethernet device.
|
||||
</tp:docstring>
|
||||
</tp:enumvalue>
|
||||
<tp:enumvalue suffix="WIFI" value="2">
|
||||
<tp:docstring>
|
||||
The device is an 802.11 WiFi device.
|
||||
</tp:docstring>
|
||||
</tp:enumvalue>
|
||||
<tp:enumvalue suffix="GSM" value="3">
|
||||
<tp:docstring>
|
||||
The device is a GSM-based cellular WAN device.
|
||||
</tp:docstring>
|
||||
</tp:enumvalue>
|
||||
<tp:enumvalue suffix="CDMA" value="4">
|
||||
<tp:docstring>
|
||||
The device is a CDMA/IS-95-based cellular WAN device.
|
||||
</tp:docstring>
|
||||
</tp:enumvalue>
|
||||
</tp:enum>
|
||||
|
||||
<tp:flags name="NM_DEVICE_CAP" value-prefix="NM_DEVICE_CAP" type="u">
|
||||
<tp:flag suffix="NONE" value="0x0">
|
||||
<tp:docstring>Null capability.</tp:docstring>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<method name="Update">
|
||||
<tp:docstring>
|
||||
Update the connection.
|
||||
Update the connection with new settings and properties, replacing all previous settings and properties.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_update"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_ACCESS_POINT_H
|
||||
#define NM_ACCESS_POINT_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <NetworkManager.h>
|
||||
#include "nm-object.h"
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ nm_active_connection_get_devices (NMActiveConnection *connection)
|
|||
return handle_ptr_array_return (priv->devices);
|
||||
|
||||
if (!_nm_object_get_property (NM_OBJECT (connection),
|
||||
NM_DBUS_INTERFACE,
|
||||
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
|
||||
DBUS_PROP_DEVICES,
|
||||
&value)) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_ACTIVE_CONNECTION_H
|
||||
#define NM_ACTIVE_CONNECTION_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-object.h"
|
||||
#include <nm-connection.h>
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ nm_client_get_active_connections (NMClient *client)
|
|||
return NULL;
|
||||
|
||||
if (!_nm_object_get_property (NM_OBJECT (client),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
"org.freedesktop.NetworkManager",
|
||||
"ActiveConnections",
|
||||
&value)) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_CLIENT_H
|
||||
#define NM_CLIENT_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <NetworkManager.h>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_DEVICE_H
|
||||
#define NM_DEVICE_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include "nm-object.h"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_DHCP4_CONFIG_H
|
||||
#define NM_DHCP4_CONFIG_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include "nm-object.h"
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ register_for_property_changed (NMIP4Config *config)
|
|||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
const NMPropertiesChangedInfo property_changed_info[] = {
|
||||
{ NM_IP4_CONFIG_ADDRESSES, demarshal_ip4_address_array, &priv->addresses },
|
||||
{ NM_IP4_CONFIG_NAMESERVERS, demarshal_ip4_array, &priv->nameservers },
|
||||
{ NM_IP4_CONFIG_DOMAINS, demarshal_domains, &priv->domains },
|
||||
{ NM_IP4_CONFIG_ROUTES, demarshal_ip4_routes_array, &priv->routes },
|
||||
{ NM_IP4_CONFIG_ADDRESSES, demarshal_ip4_address_array, &priv->addresses },
|
||||
{ NM_IP4_CONFIG_NAMESERVERS, demarshal_ip4_array, &priv->nameservers },
|
||||
{ NM_IP4_CONFIG_DOMAINS, demarshal_domains, &priv->domains },
|
||||
{ NM_IP4_CONFIG_ROUTES, demarshal_ip4_routes_array, &priv->routes },
|
||||
{ NM_IP4_CONFIG_WINS_SERVERS, demarshal_ip4_array, &priv->wins },
|
||||
{ NULL },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_IP4_CONFIG_H
|
||||
#define NM_IP4_CONFIG_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include "nm-object.h"
|
||||
|
|
@ -57,11 +57,11 @@ GType nm_ip4_config_get_type (void);
|
|||
|
||||
GObject *nm_ip4_config_new (DBusGConnection *connection, const char *object_path);
|
||||
|
||||
const GSList * nm_ip4_config_get_addresses (NMIP4Config *config);
|
||||
const char * nm_ip4_config_get_hostname (NMIP4Config *config); /* DEPRECATED */
|
||||
const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config);
|
||||
const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config);
|
||||
const GSList * nm_ip4_config_get_routes (NMIP4Config *config);
|
||||
const GSList * nm_ip4_config_get_addresses (NMIP4Config *config);
|
||||
const char * nm_ip4_config_get_hostname (NMIP4Config *config); /* DEPRECATED */
|
||||
const GArray * nm_ip4_config_get_nameservers (NMIP4Config *config);
|
||||
const GPtrArray *nm_ip4_config_get_domains (NMIP4Config *config);
|
||||
const GSList * nm_ip4_config_get_routes (NMIP4Config *config);
|
||||
const GArray * nm_ip4_config_get_wins_servers (NMIP4Config *config);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef NM_OBJECT_CACHE_H
|
||||
#define NM_OBJECT_CACHE_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-object.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_OBJECT_H
|
||||
#define NM_OBJECT_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_VPN_CONNECTION_H
|
||||
#define NM_VPN_CONNECTION_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include "nm-active-connection.h"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-vpn-plugin.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-connection.h"
|
||||
|
|
@ -49,8 +50,8 @@ static gboolean impl_vpn_plugin_set_failure (NMVPNPlugin *plugin,
|
|||
|
||||
#include "nm-vpn-plugin-glue.h"
|
||||
|
||||
#define NM_VPN_PLUGIN_CONNECT_TIMER 60000
|
||||
#define NM_VPN_PLUGIN_QUIT_TIMER 20000
|
||||
#define NM_VPN_PLUGIN_CONNECT_TIMER 60
|
||||
#define NM_VPN_PLUGIN_QUIT_TIMER 20
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMVPNPlugin, nm_vpn_plugin, G_TYPE_OBJECT)
|
||||
|
||||
|
|
@ -680,18 +681,18 @@ state_changed (NMVPNPlugin *plugin, NMVPNServiceState state)
|
|||
}
|
||||
|
||||
/* Add a timer to make sure we do not wait indefinitely for the successful connect. */
|
||||
priv->connect_timer = g_timeout_add_full (G_PRIORITY_DEFAULT,
|
||||
NM_VPN_PLUGIN_CONNECT_TIMER,
|
||||
connect_timer_expired,
|
||||
plugin,
|
||||
connect_timer_removed);
|
||||
priv->connect_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
|
||||
NM_VPN_PLUGIN_CONNECT_TIMER,
|
||||
connect_timer_expired,
|
||||
plugin,
|
||||
connect_timer_removed);
|
||||
break;
|
||||
case NM_VPN_SERVICE_STATE_STOPPED:
|
||||
priv->quit_timer = g_timeout_add_full (G_PRIORITY_DEFAULT,
|
||||
NM_VPN_PLUGIN_QUIT_TIMER,
|
||||
quit_timer_expired,
|
||||
plugin,
|
||||
quit_timer_removed);
|
||||
priv->quit_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
|
||||
NM_VPN_PLUGIN_QUIT_TIMER,
|
||||
quit_timer_expired,
|
||||
plugin,
|
||||
quit_timer_removed);
|
||||
break;
|
||||
default:
|
||||
/* Clean up all timers we might have set up. */
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef NM_VPN_PLUGIN_H
|
||||
#define NM_VPN_PLUGIN_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <NetworkManagerVPN.h>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
SUBDIRS=. tests
|
||||
|
||||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/include
|
||||
|
||||
lib_LTLIBRARIES=libnm-util.la
|
||||
|
|
@ -69,24 +71,35 @@ endif
|
|||
|
||||
libnm_util_includedir=$(includedir)/NetworkManager
|
||||
|
||||
noinst_PROGRAMS = test-crypto
|
||||
|
||||
test_crypto_SOURCES = test-crypto.c crypto.c
|
||||
test_crypto_CPPFLAGS = $(GLIB_CFLAGS) -D_GNU_SOURCE
|
||||
test_crypto_LDADD = $(GLIB_LIBS) libnm-util.la
|
||||
###########################################
|
||||
# Crypto test library
|
||||
###########################################
|
||||
|
||||
noinst_LTLIBRARIES = libtest-crypto.la
|
||||
|
||||
libtest_crypto_la_SOURCES = crypto.c
|
||||
|
||||
libtest_crypto_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
libtest_crypto_la_LIBADD = \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
if WITH_GNUTLS
|
||||
test_crypto_SOURCES += crypto_gnutls.c
|
||||
test_crypto_CPPFLAGS += $(LIBGCRYPT_CFLAGS) $(GNUTLS_CFLAGS)
|
||||
test_crypto_LDADD += $(LIBGCRYPT_LIBS) $(GNUTLS_LIBS)
|
||||
libtest_crypto_la_SOURCES += crypto_gnutls.c
|
||||
libtest_crypto_la_CPPFLAGS += $(LIBGCRYPT_CFLAGS) $(GNUTLS_CFLAGS)
|
||||
libtest_crypto_la_LIBADD += $(LIBGCRYPT_LIBS) $(GNUTLS_LIBS)
|
||||
endif
|
||||
|
||||
if WITH_NSS
|
||||
test_crypto_SOURCES += crypto_nss.c
|
||||
test_crypto_CPPFLAGS += $(NSS_CFLAGS)
|
||||
test_crypto_LDADD += $(NSS_LIBS)
|
||||
libtest_crypto_la_SOURCES += crypto_nss.c
|
||||
libtest_crypto_la_CPPFLAGS += $(NSS_CFLAGS)
|
||||
libtest_crypto_la_LIBADD += $(NSS_LIBS)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libnm-util.pc
|
||||
|
||||
|
|
|
|||
|
|
@ -311,9 +311,9 @@ convert_iv (const char *src,
|
|||
GError **error)
|
||||
{
|
||||
int num;
|
||||
int i;
|
||||
char conv[3];
|
||||
char *c;
|
||||
int i;
|
||||
char conv[3];
|
||||
char *c;
|
||||
|
||||
g_return_val_if_fail (src != NULL, NULL);
|
||||
|
||||
|
|
@ -326,16 +326,16 @@ convert_iv (const char *src,
|
|||
}
|
||||
|
||||
num /= 2;
|
||||
c = g_malloc0 (num + 1);
|
||||
if (c == NULL) {
|
||||
c = g_malloc0 (num + 1);
|
||||
if (c == NULL) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_OUT_OF_MEMORY,
|
||||
_("Not enough memory to store the IV."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
conv[2] = '\0';
|
||||
for (i = 0; i < num; i++) {
|
||||
conv[2] = '\0';
|
||||
for (i = 0; i < num; i++) {
|
||||
conv[0] = src[(i * 2)];
|
||||
conv[1] = src[(i * 2) + 1];
|
||||
if (!g_ascii_isxdigit (conv[0]) || !g_ascii_isxdigit (conv[1])) {
|
||||
|
|
@ -345,10 +345,10 @@ convert_iv (const char *src,
|
|||
goto error;
|
||||
}
|
||||
|
||||
c[i] = strtol(conv, NULL, 16);
|
||||
}
|
||||
*out_len = num;
|
||||
return c;
|
||||
c[i] = strtol(conv, NULL, 16);
|
||||
}
|
||||
*out_len = num;
|
||||
return c;
|
||||
|
||||
error:
|
||||
g_free (c);
|
||||
|
|
|
|||
|
|
@ -1512,7 +1512,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
"Use system CA certificates",
|
||||
"Use system CA certificates",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
/* Initialize crypto lbrary. */
|
||||
if (!nm_utils_init (&error)) {
|
||||
|
|
|
|||
|
|
@ -431,15 +431,15 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
* Whether or not the connection should be automatically connected by
|
||||
* NetworkManager when the resources for the connection are available.
|
||||
* %TRUE to automatically activate the connection, %FALSE to require manual
|
||||
* intervention to activate the connection.
|
||||
* intervention to activate the connection. Defaults to %TRUE.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_AUTOCONNECT,
|
||||
g_param_spec_boolean (NM_SETTING_CONNECTION_AUTOCONNECT,
|
||||
"Autoconnect",
|
||||
"Connection autoconnect",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:timestamp:
|
||||
|
|
@ -453,7 +453,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Timestamp",
|
||||
"Connection timestamp",
|
||||
0, G_MAXUINT64, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:read-only:
|
||||
|
|
@ -468,5 +468,5 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Read-Only",
|
||||
"Read-Only",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
|||
NM_GSM_NETWORK_ANY,
|
||||
NM_GSM_NETWORK_PREFER_UMTS_HSPA,
|
||||
NM_GSM_NETWORK_ANY,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BAND,
|
||||
|
|
@ -463,7 +463,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
|||
"Band",
|
||||
"Band",
|
||||
-1, 5, -1, /* FIXME: Use an enum for it */
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PIN,
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Ignore automatic routes",
|
||||
"Ignore automatic routes",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IGNORE_AUTO_DNS,
|
||||
|
|
@ -743,7 +743,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Ignore automatic DNS",
|
||||
"Ignore automatic DNS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP_CLIENT_ID,
|
||||
|
|
@ -767,7 +767,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Never default",
|
||||
"Never make this connection the default IPv4 connection",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
"Ignore DHCPv6 DNS",
|
||||
"Ignore DHCPv6 DNS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IGNORE_ROUTER_ADV,
|
||||
|
|
@ -662,7 +662,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
"Ignore Router Advertisements",
|
||||
"Ignore Router Advertisements",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP_MODE,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ nm_setting_ppp_error_get_type (void)
|
|||
ENUM_ENTRY (NM_SETTING_PPP_ERROR_INVALID_PROPERTY, "InvalidProperty"),
|
||||
/* The specified property was missing and is required. */
|
||||
ENUM_ENTRY (NM_SETTING_PPP_ERROR_MISSING_PROPERTY, "MissingProperty"),
|
||||
/* The 'require-mppe' option is not allowed in conjunction with 'noauth'. */
|
||||
/* The 'require-mppe' option is not allowed in conjunction with the specified authentication. */
|
||||
ENUM_ENTRY (NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED, "RequireMPPENotAllowed"),
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
|
@ -263,18 +263,6 @@ nm_setting_ppp_get_lcp_echo_interval (NMSettingPPP *setting)
|
|||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingPPPPrivate *priv = NM_SETTING_PPP_GET_PRIVATE (setting);
|
||||
|
||||
if (priv->noauth) {
|
||||
if (priv->require_mppe) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_PPP_ERROR,
|
||||
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED,
|
||||
NM_SETTING_PPP_REQUIRE_MPPE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: Do we even want this or can we just let pppd evaluate the options? */
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -438,8 +426,8 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
g_param_spec_boolean (NM_SETTING_PPP_NOAUTH,
|
||||
"NoAuth",
|
||||
"NoAuth",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_EAP,
|
||||
|
|
@ -447,7 +435,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse EAP",
|
||||
"Refuse EAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_PAP,
|
||||
|
|
@ -455,7 +443,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse PAP",
|
||||
"Refuse PAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_CHAP,
|
||||
|
|
@ -463,7 +451,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse CHAP",
|
||||
"Refuse CHAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_MSCHAP,
|
||||
|
|
@ -471,7 +459,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse MSCHAP",
|
||||
"Refuse MSCHAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_MSCHAPV2,
|
||||
|
|
@ -479,7 +467,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse MSCHAPv2",
|
||||
"Refuse MSCHAPv2",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NOBSDCOMP,
|
||||
|
|
@ -487,7 +475,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No BSD compression",
|
||||
"No BSD compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NODEFLATE,
|
||||
|
|
@ -495,7 +483,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No deflate",
|
||||
"No deflate",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NO_VJ_COMP,
|
||||
|
|
@ -503,7 +491,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No VJ compression",
|
||||
"No VJ compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REQUIRE_MPPE,
|
||||
|
|
@ -511,7 +499,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Require MPPE",
|
||||
"Require MPPE",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REQUIRE_MPPE_128,
|
||||
|
|
@ -519,7 +507,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Require MPPE 128",
|
||||
"Require MPPE 128",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT| NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MPPE_STATEFUL,
|
||||
|
|
@ -527,7 +515,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MPPE stateful",
|
||||
"MPPE stateful",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CRTSCTS,
|
||||
|
|
@ -535,7 +523,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"CRTSCTS",
|
||||
"CRTSCTS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BAUD,
|
||||
|
|
@ -543,7 +531,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Baud",
|
||||
"Baud",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MRU,
|
||||
|
|
@ -551,7 +539,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MRU",
|
||||
"MRU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MTU,
|
||||
|
|
@ -559,7 +547,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_FAILURE,
|
||||
|
|
@ -567,7 +555,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo failure",
|
||||
"LCP echo failure",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_INTERVAL,
|
||||
|
|
@ -575,5 +563,5 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo interval",
|
||||
"LCP echo interval",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"Speed",
|
||||
"Speed",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DUPLEX,
|
||||
|
|
@ -308,7 +308,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"AutoNegotiate",
|
||||
"Auto negotiate",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
|
|
@ -324,6 +324,6 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -590,6 +590,13 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME);
|
||||
return FALSE;
|
||||
}
|
||||
if (priv->leap_password && !strlen (priv->leap_password)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
||||
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0)
|
||||
|| (strcmp (priv->key_mgmt, "wpa-eap") == 0)) {
|
||||
|
|
@ -657,6 +664,14 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->psk && !strlen (priv->psk)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
||||
NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_WIRELESS_SECURITY_PSK);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_SECURITY_ERROR,
|
||||
|
|
@ -901,7 +916,7 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
|
|||
"WEP TX key index",
|
||||
"WEP TX key index",
|
||||
0, 3, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_AUTH_ALG,
|
||||
|
|
|
|||
|
|
@ -233,9 +233,6 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
|
|||
if ( !strcmp (key_mgmt, "wpa-psk")
|
||||
|| !strcmp (key_mgmt, "wpa-eap")) {
|
||||
|
||||
if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
|
||||
return FALSE;
|
||||
|
||||
if (!strcmp (key_mgmt, "wpa-psk")) {
|
||||
if ( !(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK)
|
||||
&& !(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK))
|
||||
|
|
@ -726,7 +723,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"Channel",
|
||||
"Channel",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BSSID,
|
||||
|
|
@ -742,7 +739,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"Rate",
|
||||
"Rate",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TX_POWER,
|
||||
|
|
@ -750,7 +747,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"TX Power",
|
||||
"TX Power",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
|
|
@ -774,7 +771,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SEC,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#ifndef NM_SETTING_H
|
||||
#define NM_SETTING_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
|
|
|||
|
|
@ -904,9 +904,6 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
|
||||
return FALSE;
|
||||
|
||||
if (ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
|
||||
if ( (ap_wpa & NM_802_11_AP_SEC_PAIR_TKIP)
|
||||
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
|
||||
|
|
@ -922,9 +919,6 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
|
||||
return FALSE;
|
||||
|
||||
if (ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK) {
|
||||
if ( (ap_rsn & NM_802_11_AP_SEC_PAIR_TKIP)
|
||||
&& (wifi_caps & NM_WIFI_DEVICE_CAP_CIPHER_TKIP))
|
||||
|
|
@ -942,8 +936,6 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_WPA))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
|
||||
return FALSE;
|
||||
if (!(ap_wpa & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
|
||||
return FALSE;
|
||||
/* Ensure at least one WPA cipher is supported */
|
||||
|
|
@ -957,8 +949,6 @@ nm_utils_security_valid (NMUtilsSecurityType type,
|
|||
if (!(wifi_caps & NM_WIFI_DEVICE_CAP_RSN))
|
||||
return FALSE;
|
||||
if (have_ap) {
|
||||
if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY))
|
||||
return FALSE;
|
||||
if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
|
||||
return FALSE;
|
||||
/* Ensure at least one WPA cipher is supported */
|
||||
|
|
|
|||
|
|
@ -1,200 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2007 - 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----";
|
||||
static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----";
|
||||
|
||||
static const char *pem_dsa_key_begin = "-----BEGIN DSA PRIVATE KEY-----";
|
||||
static const char *pem_dsa_key_end = "-----END DSA PRIVATE KEY-----";
|
||||
|
||||
static void
|
||||
dump_key_to_pem (const char *key, gsize key_len, int key_type)
|
||||
{
|
||||
char *b64 = NULL;
|
||||
GString *str = NULL;
|
||||
const char *start_tag;
|
||||
const char *end_tag;
|
||||
char *p;
|
||||
|
||||
switch (key_type) {
|
||||
case NM_CRYPTO_KEY_TYPE_RSA:
|
||||
start_tag = pem_rsa_key_begin;
|
||||
end_tag = pem_rsa_key_end;
|
||||
break;
|
||||
case NM_CRYPTO_KEY_TYPE_DSA:
|
||||
start_tag = pem_dsa_key_begin;
|
||||
end_tag = pem_dsa_key_end;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Unknown key type %d", key_type);
|
||||
return;
|
||||
}
|
||||
|
||||
b64 = g_base64_encode ((const unsigned char *) key, key_len);
|
||||
if (!b64) {
|
||||
g_warning ("Couldn't base64 encode the key.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
str = g_string_new (NULL);
|
||||
if (!str) {
|
||||
g_warning ("Couldn't allocate buffer to write out key.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_string_append (str, start_tag);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
for (p = b64; p < (b64 + strlen (b64)); p += 64) {
|
||||
g_string_append_len (str, p, strnlen (p, 64));
|
||||
g_string_append_c (str, '\n');
|
||||
}
|
||||
|
||||
g_string_append (str, end_tag);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
g_message ("Decrypted private key:\n\n%s", str->str);
|
||||
|
||||
out:
|
||||
g_free (b64);
|
||||
if (str)
|
||||
g_string_free (str, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
usage (const char *prgname)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s cert <file>\n"
|
||||
" %s key <file> <password>\n",
|
||||
prgname, prgname);
|
||||
}
|
||||
|
||||
#define MODE_CERT 1
|
||||
#define MODE_KEY 2
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int mode = 0;
|
||||
const char *file;
|
||||
GError *error = NULL;
|
||||
|
||||
if (argc < 2) {
|
||||
usage (argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp (argv[1], "key")) {
|
||||
if (argc < 4) {
|
||||
usage (argv[0]);
|
||||
return 1;
|
||||
}
|
||||
mode = MODE_KEY;
|
||||
} else if (!strcmp (argv[1], "cert")) {
|
||||
if (argc < 3) {
|
||||
usage (argv[0]);
|
||||
return 1;
|
||||
}
|
||||
mode = MODE_CERT;
|
||||
} else {
|
||||
usage (argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!crypto_init (&error)) {
|
||||
g_warning ("Couldn't initialize crypto library: %d %s.",
|
||||
error->code, error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = argv[2];
|
||||
|
||||
if (mode == MODE_CERT) {
|
||||
GByteArray *array;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
|
||||
array = crypto_load_and_verify_certificate (file, &format, &error);
|
||||
if (!array) {
|
||||
g_warning ("Couldn't read certificate file '%s': %d %s",
|
||||
file, error->code, error->message);
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case NM_CRYPTO_FILE_FORMAT_X509:
|
||||
g_message ("Format: pkcs#1");
|
||||
break;
|
||||
case NM_CRYPTO_FILE_FORMAT_PKCS12:
|
||||
g_message ("Format: pkcs#12");
|
||||
break;
|
||||
default:
|
||||
g_message ("Format: unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
g_byte_array_free (array, TRUE);
|
||||
} else if (mode == MODE_KEY) {
|
||||
NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
const char *password = argv[3];
|
||||
GByteArray *array;
|
||||
|
||||
array = crypto_get_private_key (file, password, &key_type, &format, &error);
|
||||
if (!array) {
|
||||
g_warning ("Couldn't read key file '%s': %d %s",
|
||||
file, error->code, error->message);
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case NM_CRYPTO_FILE_FORMAT_RAW_KEY:
|
||||
g_message ("Original format: pkcs#1\n");
|
||||
dump_key_to_pem ((const char *) array->data, array->len, key_type);
|
||||
break;
|
||||
case NM_CRYPTO_FILE_FORMAT_PKCS12:
|
||||
g_message ("Original format: pkcs#12");
|
||||
break;
|
||||
default:
|
||||
g_message ("Original format: unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
g_byte_array_free (array, TRUE);
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
out:
|
||||
crypto_deinit ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
46
libnm-util/tests/Makefile.am
Normal file
46
libnm-util/tests/Makefile.am
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
SUBDIRS=certs
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util
|
||||
|
||||
noinst_PROGRAMS = test-settings-defaults test-crypto
|
||||
|
||||
test_settings_defaults_SOURCES = \
|
||||
test-settings-defaults.c
|
||||
|
||||
test_settings_defaults_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
test_settings_defaults_LDADD = \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
|
||||
test_crypto_SOURCES = \
|
||||
test-crypto.c
|
||||
|
||||
test_crypto_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
test_crypto_LDADD = \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(top_builddir)/libnm-util/libtest-crypto.la
|
||||
|
||||
|
||||
if WITH_TESTS
|
||||
|
||||
check-local: test-settings-defaults test-crypto
|
||||
$(abs_builddir)/test-settings-defaults
|
||||
$(abs_builddir)/test-crypto \
|
||||
$(top_srcdir)/libnm-util/tests/certs/test_ca_cert.pem \
|
||||
$(top_srcdir)/libnm-util/tests/certs/test_key_and_cert.pem \
|
||||
$(top_srcdir)/libnm-util/tests/certs/test_key_and_cert.pem \
|
||||
"test" \
|
||||
$(top_srcdir)/libnm-util/tests/certs/test-cert.p12 \
|
||||
"test"
|
||||
|
||||
endif
|
||||
|
||||
14
libnm-util/tests/certs/Makefile.am
Normal file
14
libnm-util/tests/certs/Makefile.am
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# test-cert.p12 created with:
|
||||
#
|
||||
# openssl pkcs12 -export \
|
||||
# -in test_key_and_cert.pem \
|
||||
# -inkey test_key_and_cert.pem \
|
||||
# -certfile test_ca_cert.pem \
|
||||
# -name "test-pkcs12" \
|
||||
# -out test-cert.p12
|
||||
|
||||
EXTRA_DIST = \
|
||||
test_ca_cert.pem \
|
||||
test_key_and_cert.pem \
|
||||
test-cert.p12
|
||||
|
||||
BIN
libnm-util/tests/certs/test-cert.p12
Normal file
BIN
libnm-util/tests/certs/test-cert.p12
Normal file
Binary file not shown.
27
libnm-util/tests/certs/test_ca_cert.pem
Normal file
27
libnm-util/tests/certs/test_ca_cert.pem
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIEhjCCA26gAwIBAgIJAOZMXJYmXtbQMA0GCSqGSIb3DQEBBQUAMIGIMQswCQYD
|
||||
VQQGEwJVUzESMBAGA1UECBMJQmVya3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcw
|
||||
FQYDVQQKEw5NeSBDb21wYW55IEx0ZDENMAsGA1UECxMEdGVzdDENMAsGA1UEAxME
|
||||
dGVzdDEcMBoGCSqGSIb3DQEJARYNdGVzdEB0ZXN0LmNvbTAeFw0wOTAyMDIwMjIx
|
||||
NTJaFw0xOTAxMzEwMjIxNTJaMIGIMQswCQYDVQQGEwJVUzESMBAGA1UECBMJQmVy
|
||||
a3NoaXJlMRAwDgYDVQQHEwdOZXdidXJ5MRcwFQYDVQQKEw5NeSBDb21wYW55IEx0
|
||||
ZDENMAsGA1UECxMEdGVzdDENMAsGA1UEAxMEdGVzdDEcMBoGCSqGSIb3DQEJARYN
|
||||
dGVzdEB0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANZz
|
||||
iHfFR6Gqdz5Gq1elSaf7J2tznfialPyMkRoqngSItrM3JWlkfBu3ZIpGSYG8+Z8H
|
||||
JjaKh/zkCCH73HcjADCocm/XtgxlOlccDtBvfDqifb2dBikcmcfh0tX0o4JU9L+z
|
||||
WP7sVcUkJG7C5811lA5pAsLVooJxrZnrta6XstGvFgTSxI2Y4Jowf0syM5b/AHIQ
|
||||
+htsVhSyj1DWM9day3QsEMZl55SCxCLTB6ZIJLF6NmTYwdnzWWTQf4k7kcptZJU8
|
||||
Fqv60b/ATvvUf7S+ZMGLopFIIlmc1Kkn7VTseIKy4ycYuDpyimQy3Yw4flC00vhl
|
||||
hTijH+5dlVOUFrRh0bsCAwEAAaOB8DCB7TAdBgNVHQ4EFgQUUjMuImZ5guVBLo07
|
||||
suXM+r6ZM44wgb0GA1UdIwSBtTCBsoAUUjMuImZ5guVBLo07suXM+r6ZM46hgY6k
|
||||
gYswgYgxCzAJBgNVBAYTAlVTMRIwEAYDVQQIEwlCZXJrc2hpcmUxEDAOBgNVBAcT
|
||||
B05ld2J1cnkxFzAVBgNVBAoTDk15IENvbXBhbnkgTHRkMQ0wCwYDVQQLEwR0ZXN0
|
||||
MQ0wCwYDVQQDEwR0ZXN0MRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRlc3QuY29tggkA
|
||||
5kxcliZe1tAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAZsWzGp9D
|
||||
10NWf8ts3A9mhcEb8oDgKNpCOZF9gqr2usZygJjY9MX2n0n81T8XaWDk1wZLlcDW
|
||||
hzIalCY8rpE57Dj3MEmdCmYr3BrAy6GVlc/MO7ffTHxogl9ouScSYo8ETTtNMKCg
|
||||
zwkDnXjGzmb1e59DIXMVHBBbTmJXJbM8XP9A2azJkVUyE2fSdWksXMP0XklGbW2p
|
||||
DksJ+8G1IWkyRhnINV5GZLLNAT5gBA6sUv/iqQKwk8r2dsweMPtLoLWZPAaZErYh
|
||||
sthGy00Q0GJkmkJpQl8QIlPq5vylNcMUhvc8tmzwk+rDVUj3jTJWqFwMtnHAaNyC
|
||||
FXl9ynWpe5J28w==
|
||||
-----END CERTIFICATE-----
|
||||
119
libnm-util/tests/certs/test_key_and_cert.pem
Normal file
119
libnm-util/tests/certs/test_key_and_cert.pem
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,B29FCA6ECB7C0C48
|
||||
|
||||
KuRV4sEVQkY0r0E+E81Se2qpm54HeboUMIJcMVqAt/HIeYwpjEzmXHUywXgayA5k
|
||||
r5Uvru95vymFz80q/rl6i4Mt3ckEQ3/VHmBI4pPj/JeRbiDhqTyLqpB5zMgbuti+
|
||||
PsEemlbiaCMZFdJk8rJBWADTkirGbXs5ciLwTJyrJXhkBVTqoHtphSWMELxcrnQj
|
||||
5bAXZ+rnApWA7LR3yCY1UE0Nj39Yu8lkzDJtbsSXPJVO//OQiGuQRcY6roAUzeS/
|
||||
amLdIYqoZm3OF83Ro88XZCIDCG6XjgKoqojtekClVIytB6mHWk+IHhI7DgU/pDBj
|
||||
yOskzVRMja9ECnqaVX+bmlmJGZBgcd7+XiebCXNY9IAx/ZQDMbDJDoJusvH6npJR
|
||||
PBgag8QBSzwpFyEP/1LrlyVyggZcGuXDWfUiM2rt2UvLm8QYeT5WGfUI+QwW6JRV
|
||||
xEz2QwRiPsmj0uK2fXLKHbY0Pv79IMLqgesCAUbndWsi94kjAhpJGa/WfKVb8Dpg
|
||||
T+mVa2OT0pgewPWJ3h5f47ag27WDJthsIUHAvNZ03uM23DIqDh6o03/B3/4r1Uab
|
||||
HzsLWhUOzbLihO08qcPk/JqtDVCv579mpgvy7bL2ZsZUzefnmg+ah+1bhLguryZu
|
||||
Zrt1hTu5WTz27UbYwWNtkxWnWcM9sSF9y+KVwumYhIUGTvg3Jds/jmp/Z5ad8tev
|
||||
0RQuWmqnXVD51Y92tOXobJH7JwGbQ4GeRNG/UX7DS9Lvb6rPgmmxvGbXMcjEMapB
|
||||
m5DLjCD7Lz4++sfzhCic3/nL8e8fjoYZmCbL/SpYjGjTrfoNaGYaT0De8MxCSjPf
|
||||
rNT+ldWFD0oAOTmT0uqOFkeIx3vxczSQUyRfzGOLqtb9mAXk8lvdb8Myb5atfe8f
|
||||
FNBL5ocz6Szv2AmKmjZE5P6NKSllyryCYl+H2QU0e3OyY8S9aG2aG8fqeVKaA01S
|
||||
uOOjsK6IKMpkit+VFDP7RWvS8p1FTwTVRdbMZzASW8+D98OHsTlOENtQuuFyvNaN
|
||||
vPHrbHltTkwDlYVab9UpFr/ZRW3cNJrmcl0hyeCJxk5u8B9UwW6yZmd24hxda2xt
|
||||
1QjnxfWlX0i5KTmfWFyPmRYt1WH9rdVaH6wqRbGNbMRT7Lez0E/2+LXjFiiEe0Vh
|
||||
ZuryhyhUXpHY8yyHxFY92XT504Z3wPUaJ1tQxGhdziZ7HcqFT8f4oTNJdBNtzqNw
|
||||
l63gSTaKUkSB14CBOyR84cqpgSMwZvWZb3RQFYY4GSALWwhnn6PWeRhjWAXPms2v
|
||||
tRmfEyDUCyPxDarezvS9kUir3XbvnCkoJOrK/lw4a8ygGBCBqRKOdI0SRUf1Nnjm
|
||||
aZBrKrXHv5vP66fyC7cGMTq35+iiHbE//rRDGPrf9vpmw3ki3FlDMyAXOC5yWDco
|
||||
0n+cNDyHJDdIW3+3nfZvSgPPMwmTdfNO90X3YczSmMTGjnIuhQMf7FMFmMZOSrqD
|
||||
u234vYCjIIlph3aVpbzjOqKg3d4nuP9oouyAgRAr+vShgHRmq0jvsAiGH3Q6RqEj
|
||||
DvkM1NgoloMy5RhKF4hIeaQM/UlgoXrcEx0RGCJHykQcQmVa5cf5EwjrO7b+w2Lg
|
||||
-----END RSA PRIVATE KEY-----
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 1 (0x1)
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
Issuer: C=US, ST=Berkshire, L=Newbury, O=My Company Ltd, OU=test, CN=test/emailAddress=test@test.com
|
||||
Validity
|
||||
Not Before: Feb 2 02:22:25 2009 GMT
|
||||
Not After : Jan 31 02:22:25 2019 GMT
|
||||
Subject: C=US, ST=Berkshire, O=My Company Ltd, OU=test-client, CN=test-client/emailAddress=test-client@test.com
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public Key: (2048 bit)
|
||||
Modulus (2048 bit):
|
||||
00:ce:d2:e9:fb:f4:a4:ce:66:87:cc:8b:2d:d2:c3:
|
||||
b8:fa:be:ea:53:08:95:9e:27:4a:04:78:31:a1:36:
|
||||
d2:e5:42:f5:76:f7:24:71:b8:d3:10:fd:b7:57:86:
|
||||
68:29:02:1b:e9:93:2b:af:c0:7e:3d:58:16:34:10:
|
||||
25:85:7e:28:2d:42:fc:34:7f:d6:4f:0a:e7:b6:b9:
|
||||
40:51:c8:e5:89:60:cd:73:51:63:67:e1:59:36:31:
|
||||
5e:d0:87:4b:5d:97:8a:42:22:d3:42:f2:83:62:79:
|
||||
84:45:5b:d8:20:97:e2:d1:34:23:5e:ec:bf:8a:41:
|
||||
7c:ad:80:50:f3:9b:1c:51:5d:e4:29:1c:c1:c6:7c:
|
||||
a1:00:70:0f:f6:79:77:03:22:f5:4b:ab:76:ca:20:
|
||||
ab:e1:4e:53:6c:86:68:e9:d6:0f:6e:95:4b:b5:b5:
|
||||
cf:d3:6c:d4:73:db:c0:3d:1d:20:20:72:ab:3e:25:
|
||||
bb:3f:cd:5f:2d:77:fd:d7:0b:a8:eb:0c:73:c0:3f:
|
||||
74:27:17:56:cf:31:9a:a9:ed:c1:39:27:c7:aa:e9:
|
||||
77:48:f4:6d:56:89:35:5c:79:5b:f6:2f:8c:9f:93:
|
||||
bc:13:1c:d0:74:5f:30:1b:15:43:71:8e:ff:1a:df:
|
||||
65:65:69:c2:8a:5a:ab:04:4a:80:de:20:29:8d:48:
|
||||
1c:83
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints:
|
||||
CA:FALSE
|
||||
Netscape Comment:
|
||||
OpenSSL Generated Certificate
|
||||
X509v3 Subject Key Identifier:
|
||||
34:E9:5C:D8:FC:C7:AF:F7:5D:F4:13:D3:82:1A:CD:52:0F:4A:BB:0B
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:52:33:2E:22:66:79:82:E5:41:2E:8D:3B:B2:E5:CC:FA:BE:99:33:8E
|
||||
DirName:/C=US/ST=Berkshire/L=Newbury/O=My Company Ltd/OU=test/CN=test/emailAddress=test@test.com
|
||||
serial:E6:4C:5C:96:26:5E:D6:D0
|
||||
|
||||
Signature Algorithm: md5WithRSAEncryption
|
||||
88:c4:dd:c5:4a:a6:8e:1f:36:62:80:31:6b:2b:85:34:0d:6c:
|
||||
a7:dc:e1:5a:3c:dd:74:57:db:59:be:8b:f2:79:40:2d:bd:9b:
|
||||
e1:ab:0e:03:75:20:75:2f:ea:97:f9:d4:7e:15:75:c2:82:f5:
|
||||
b1:37:e4:8b:24:d4:ef:02:3b:19:6a:56:bb:9f:c3:a5:b4:c4:
|
||||
39:a0:64:96:5b:c3:a8:19:74:ec:0b:cf:33:df:f3:12:f3:e2:
|
||||
ab:1d:7d:de:21:64:cd:b1:a0:6f:7a:77:84:d4:62:8a:50:e6:
|
||||
76:5d:af:3a:ef:1a:87:0e:1a:38:c4:f9:0d:2f:14:e0:20:32:
|
||||
4c:2e:70:d2:71:82:d5:e5:c9:13:2c:4e:b4:c8:63:65:1d:48:
|
||||
e8:c3:56:6d:88:84:57:65:13:1e:42:48:b4:03:25:71:4e:12:
|
||||
9d:1a:88:65:d5:71:21:3b:0e:be:37:1c:f0:88:6b:45:0c:0e:
|
||||
6c:e5:60:cb:86:bf:bf:40:30:c4:cf:94:f8:1c:60:d4:1b:df:
|
||||
88:02:7a:45:7e:d1:c6:f3:07:b9:b1:8f:2a:55:2f:be:77:9f:
|
||||
d1:46:64:05:b7:67:c5:b2:ac:8c:42:8f:6a:51:a4:0d:2b:16:
|
||||
a4:d6:39:a5:f8:25:ed:68:25:13:b5:19:ac:6c:e9:ec:ee:03:
|
||||
6b:80:38:6e
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIErjCCA5agAwIBAgIBATANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCVVMx
|
||||
EjAQBgNVBAgTCUJlcmtzaGlyZTEQMA4GA1UEBxMHTmV3YnVyeTEXMBUGA1UEChMO
|
||||
TXkgQ29tcGFueSBMdGQxDTALBgNVBAsTBHRlc3QxDTALBgNVBAMTBHRlc3QxHDAa
|
||||
BgkqhkiG9w0BCQEWDXRlc3RAdGVzdC5jb20wHhcNMDkwMjAyMDIyMjI1WhcNMTkw
|
||||
MTMxMDIyMjI1WjCBizELMAkGA1UEBhMCVVMxEjAQBgNVBAgTCUJlcmtzaGlyZTEX
|
||||
MBUGA1UEChMOTXkgQ29tcGFueSBMdGQxFDASBgNVBAsTC3Rlc3QtY2xpZW50MRQw
|
||||
EgYDVQQDEwt0ZXN0LWNsaWVudDEjMCEGCSqGSIb3DQEJARYUdGVzdC1jbGllbnRA
|
||||
dGVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDO0un79KTO
|
||||
ZofMiy3Sw7j6vupTCJWeJ0oEeDGhNtLlQvV29yRxuNMQ/bdXhmgpAhvpkyuvwH49
|
||||
WBY0ECWFfigtQvw0f9ZPCue2uUBRyOWJYM1zUWNn4Vk2MV7Qh0tdl4pCItNC8oNi
|
||||
eYRFW9ggl+LRNCNe7L+KQXytgFDzmxxRXeQpHMHGfKEAcA/2eXcDIvVLq3bKIKvh
|
||||
TlNshmjp1g9ulUu1tc/TbNRz28A9HSAgcqs+Jbs/zV8td/3XC6jrDHPAP3QnF1bP
|
||||
MZqp7cE5J8eq6XdI9G1WiTVceVv2L4yfk7wTHNB0XzAbFUNxjv8a32VlacKKWqsE
|
||||
SoDeICmNSByDAgMBAAGjggEcMIIBGDAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQf
|
||||
Fh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUNOlc2PzH
|
||||
r/dd9BPTghrNUg9Kuwswgb0GA1UdIwSBtTCBsoAUUjMuImZ5guVBLo07suXM+r6Z
|
||||
M46hgY6kgYswgYgxCzAJBgNVBAYTAlVTMRIwEAYDVQQIEwlCZXJrc2hpcmUxEDAO
|
||||
BgNVBAcTB05ld2J1cnkxFzAVBgNVBAoTDk15IENvbXBhbnkgTHRkMQ0wCwYDVQQL
|
||||
EwR0ZXN0MQ0wCwYDVQQDEwR0ZXN0MRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRlc3Qu
|
||||
Y29tggkA5kxcliZe1tAwDQYJKoZIhvcNAQEEBQADggEBAIjE3cVKpo4fNmKAMWsr
|
||||
hTQNbKfc4Vo83XRX21m+i/J5QC29m+GrDgN1IHUv6pf51H4VdcKC9bE35Isk1O8C
|
||||
OxlqVrufw6W0xDmgZJZbw6gZdOwLzzPf8xLz4qsdfd4hZM2xoG96d4TUYopQ5nZd
|
||||
rzrvGocOGjjE+Q0vFOAgMkwucNJxgtXlyRMsTrTIY2UdSOjDVm2IhFdlEx5CSLQD
|
||||
JXFOEp0aiGXVcSE7Dr43HPCIa0UMDmzlYMuGv79AMMTPlPgcYNQb34gCekV+0cbz
|
||||
B7mxjypVL753n9FGZAW3Z8WyrIxCj2pRpA0rFqTWOaX4Je1oJRO1Gaxs6ezuA2uA
|
||||
OG4=
|
||||
-----END CERTIFICATE-----
|
||||
260
libnm-util/tests/test-crypto.c
Normal file
260
libnm-util/tests/test-crypto.c
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2007 - 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include "crypto.h"
|
||||
|
||||
#if 0
|
||||
static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----";
|
||||
static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----";
|
||||
|
||||
static const char *pem_dsa_key_begin = "-----BEGIN DSA PRIVATE KEY-----";
|
||||
static const char *pem_dsa_key_end = "-----END DSA PRIVATE KEY-----";
|
||||
|
||||
static void
|
||||
dump_key_to_pem (const char *key, gsize key_len, int key_type)
|
||||
{
|
||||
char *b64 = NULL;
|
||||
GString *str = NULL;
|
||||
const char *start_tag;
|
||||
const char *end_tag;
|
||||
char *p;
|
||||
|
||||
switch (key_type) {
|
||||
case NM_CRYPTO_KEY_TYPE_RSA:
|
||||
start_tag = pem_rsa_key_begin;
|
||||
end_tag = pem_rsa_key_end;
|
||||
break;
|
||||
case NM_CRYPTO_KEY_TYPE_DSA:
|
||||
start_tag = pem_dsa_key_begin;
|
||||
end_tag = pem_dsa_key_end;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Unknown key type %d", key_type);
|
||||
return;
|
||||
}
|
||||
|
||||
b64 = g_base64_encode ((const unsigned char *) key, key_len);
|
||||
if (!b64) {
|
||||
g_warning ("Couldn't base64 encode the key.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
str = g_string_new (NULL);
|
||||
if (!str) {
|
||||
g_warning ("Couldn't allocate buffer to write out key.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_string_append (str, start_tag);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
for (p = b64; p < (b64 + strlen (b64)); p += 64) {
|
||||
g_string_append_len (str, p, strnlen (p, 64));
|
||||
g_string_append_c (str, '\n');
|
||||
}
|
||||
|
||||
g_string_append (str, end_tag);
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
g_message ("Decrypted private key:\n\n%s", str->str);
|
||||
|
||||
out:
|
||||
g_free (b64);
|
||||
if (str)
|
||||
g_string_free (str, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_load_cert (const char *path, const char *desc)
|
||||
{
|
||||
GByteArray *array;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
GError *error = NULL;
|
||||
|
||||
array = crypto_load_and_verify_certificate (path, &format, &error);
|
||||
ASSERT (array != NULL, desc,
|
||||
"couldn't read certificate file '%s': %d %s",
|
||||
path, error->code, error->message);
|
||||
|
||||
ASSERT (format == NM_CRYPTO_FILE_FORMAT_X509, desc,
|
||||
"%s: unexpected certificate format (expected %d, got %d)",
|
||||
path, NM_CRYPTO_FILE_FORMAT_X509, format);
|
||||
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_load_private_key (const char *path,
|
||||
const char *password,
|
||||
gboolean expect_fail,
|
||||
const char *desc)
|
||||
{
|
||||
NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
GByteArray *array;
|
||||
GError *error = NULL;
|
||||
|
||||
array = crypto_get_private_key (path, password, &key_type, &format, &error);
|
||||
if (expect_fail) {
|
||||
ASSERT (array == NULL, desc,
|
||||
"unexpected success reading private key file '%s' with "
|
||||
"invalid password",
|
||||
path);
|
||||
|
||||
ASSERT (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN, desc,
|
||||
"unexpected success determining private key file '%s' "
|
||||
"format with invalid password (expected %d, got %d)",
|
||||
path, NM_CRYPTO_FILE_FORMAT_UNKNOWN, format);
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (array != NULL, desc,
|
||||
"couldn't read private key file '%s': %d %s",
|
||||
path, error->code, error->message);
|
||||
|
||||
ASSERT (format == NM_CRYPTO_FILE_FORMAT_RAW_KEY, desc,
|
||||
"%s: unexpected private key file format (expected %d, got %d)",
|
||||
path, NM_CRYPTO_FILE_FORMAT_RAW_KEY, format);
|
||||
|
||||
ASSERT (key_type == NM_CRYPTO_KEY_TYPE_RSA, desc,
|
||||
"%s: unexpected private key type (expected %d, got %d)",
|
||||
path, NM_CRYPTO_KEY_TYPE_RSA, format);
|
||||
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_load_pkcs12 (const char *path,
|
||||
const char *password,
|
||||
gboolean expect_fail,
|
||||
const char *desc)
|
||||
{
|
||||
NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN;
|
||||
GByteArray *array;
|
||||
GError *error = NULL;
|
||||
|
||||
array = crypto_get_private_key (path, password, &key_type, &format, &error);
|
||||
if (expect_fail) {
|
||||
ASSERT (array == NULL, desc,
|
||||
"unexpected success reading PKCS#12 private key file "
|
||||
"'%s' with invalid password",
|
||||
path);
|
||||
|
||||
/* PKCS#12 file format can be determined even if the password
|
||||
* is wrong; check that.
|
||||
*/
|
||||
ASSERT (format == NM_CRYPTO_FILE_FORMAT_UNKNOWN, desc,
|
||||
"unexpected success determining PKCS#12 private key "
|
||||
"'%s' file format with invalid password (expected %d, "
|
||||
"got %d)",
|
||||
path, NM_CRYPTO_FILE_FORMAT_UNKNOWN, format);
|
||||
ASSERT (key_type == NM_CRYPTO_KEY_TYPE_UNKNOWN, desc,
|
||||
"unexpected success determining PKCS#12 private key "
|
||||
"'%s' type with invalid password (expected %d, got %d)",
|
||||
path, NM_CRYPTO_KEY_TYPE_UNKNOWN, key_type);
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (array != NULL, desc,
|
||||
"couldn't read PKCS#12 private key file '%s': %d %s",
|
||||
path, error->code, error->message);
|
||||
|
||||
ASSERT (format == NM_CRYPTO_FILE_FORMAT_PKCS12, desc,
|
||||
"%s: unexpected PKCS#12 private key file format (expected %d, got %d)",
|
||||
path, NM_CRYPTO_FILE_FORMAT_RAW_KEY, format);
|
||||
|
||||
ASSERT (key_type == NM_CRYPTO_KEY_TYPE_ENCRYPTED, desc,
|
||||
"%s: unexpected PKCS#12 private key type (expected %d, got %d)",
|
||||
path, NM_CRYPTO_KEY_TYPE_ENCRYPTED, format);
|
||||
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_is_pkcs12 (const char *path, gboolean expect_fail, const char *desc)
|
||||
{
|
||||
gboolean is_pkcs12;
|
||||
|
||||
is_pkcs12 = crypto_is_pkcs12_file (path);
|
||||
if (expect_fail) {
|
||||
ASSERT (is_pkcs12 == FALSE, desc,
|
||||
"unexpected success reading non-PKCS#12 file '%s'",
|
||||
path);
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (is_pkcs12 == TRUE, desc, "couldn't read PKCS#12 file '%s'", path);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *progname;
|
||||
const char *ca_cert;
|
||||
const char *client_cert;
|
||||
const char *priv_key;
|
||||
const char *priv_key_password;
|
||||
const char *pk12;
|
||||
const char *pk12_password;
|
||||
|
||||
ASSERT (argc == 7, "test-crypto",
|
||||
"wrong number of arguments (expected ca-cert, client-cert, "
|
||||
"private-key, private-key-password, pkcs12-cert, pkcs12-password)");
|
||||
|
||||
if (!crypto_init (&error))
|
||||
FAIL ("crypto-init", "failed to initialize crypto: %s", error->message);
|
||||
|
||||
ca_cert = argv[1];
|
||||
client_cert = argv[2];
|
||||
priv_key = argv[3];
|
||||
priv_key_password = argv[4];
|
||||
pk12 = argv[5];
|
||||
pk12_password = argv[6];
|
||||
|
||||
test_load_cert (ca_cert, "ca-cert");
|
||||
test_load_cert (client_cert, "client-cert");
|
||||
test_load_private_key (priv_key, priv_key_password, FALSE, "private-key");
|
||||
test_load_private_key (priv_key, "blahblahblah", TRUE, "private-key-bad-password");
|
||||
test_load_pkcs12 (pk12, pk12_password, FALSE, "pkcs12-private-key");
|
||||
test_load_pkcs12 (pk12, "blahblahblah", TRUE, "pkcs12-private-key-bad-password");
|
||||
test_is_pkcs12 (pk12, FALSE, "is-pkcs12");
|
||||
test_is_pkcs12 (priv_key, TRUE, "is-pkcs12-not-pkcs12");
|
||||
|
||||
crypto_deinit ();
|
||||
|
||||
progname = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", progname);
|
||||
g_free (progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
135
libnm-util/tests/test-settings-defaults.c
Normal file
135
libnm-util/tests/test-settings-defaults.c
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
*
|
||||
* 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, 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) 2008 Red Hat, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-setting-cdma.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-gsm.h"
|
||||
#include "nm-setting-ip4-config.h"
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
#include "nm-setting-pppoe.h"
|
||||
#include "nm-setting-serial.h"
|
||||
#include "nm-setting-vpn.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
|
||||
|
||||
static void
|
||||
test_defaults (GType type, const char *name)
|
||||
{
|
||||
GParamSpec **property_specs;
|
||||
guint n_property_specs;
|
||||
GObject *setting;
|
||||
int i;
|
||||
|
||||
setting = g_object_new (type, NULL);
|
||||
|
||||
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
|
||||
ASSERT (property_specs != NULL,
|
||||
name, "couldn't find property specs for object of type '%s'",
|
||||
g_type_name (G_OBJECT_TYPE (setting)));
|
||||
|
||||
for (i = 0; i < n_property_specs; i++) {
|
||||
GParamSpec *prop_spec = property_specs[i];
|
||||
GValue value = { 0, };
|
||||
GValue defvalue = { 0, };
|
||||
char *actual, *expected;
|
||||
gboolean ok = FALSE;
|
||||
|
||||
/* Ignore non-fundamental types since they won't really have
|
||||
* defaults.
|
||||
*/
|
||||
if (!G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
continue;
|
||||
|
||||
g_value_init (&value, prop_spec->value_type);
|
||||
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
|
||||
|
||||
g_value_init (&defvalue, prop_spec->value_type);
|
||||
g_param_value_set_default (prop_spec, &defvalue);
|
||||
|
||||
actual = g_strdup_value_contents (&value);
|
||||
expected = g_strdup_value_contents (&defvalue);
|
||||
|
||||
if (!strcmp (prop_spec->name, NM_SETTING_NAME)) {
|
||||
/* 'name' is always the setting name, not the default value */
|
||||
ok = !strcmp (nm_setting_get_name (NM_SETTING (setting)), name);
|
||||
g_free (expected);
|
||||
expected = g_strdup (name);
|
||||
} else
|
||||
ok = g_param_value_defaults (prop_spec, &value);
|
||||
|
||||
ASSERT (ok,
|
||||
name, "property '%s' value '%s' not the expected default value '%s'",
|
||||
prop_spec->name, actual, expected);
|
||||
|
||||
g_free (actual);
|
||||
g_free (expected);
|
||||
g_value_unset (&value);
|
||||
g_value_unset (&defvalue);
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
g_object_unref (setting);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
DBusGConnection *bus;
|
||||
char *basename;
|
||||
|
||||
g_type_init ();
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
|
||||
/* The tests */
|
||||
test_defaults (NM_TYPE_SETTING_CONNECTION, NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_802_1X, NM_SETTING_802_1X_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_CDMA, NM_SETTING_CDMA_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_GSM, NM_SETTING_GSM_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_IP4_CONFIG, NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
// test_defaults (NM_TYPE_SETTING_IP6_CONFIG, NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_PPP, NM_SETTING_PPP_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_PPPOE, NM_SETTING_PPPOE_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_SERIAL, NM_SETTING_SERIAL_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_VPN, NM_SETTING_VPN_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRED, NM_SETTING_WIRED_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRELESS, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRELESS_SECURITY, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
|
||||
basename = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", basename);
|
||||
g_free (basename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
10
po/el.po
10
po/el.po
|
|
@ -8,9 +8,10 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: NetworkManager.HEAD\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2008-12-07 22:30+0000\n"
|
||||
"PO-Revision-Date: 2008-12-07 01:52+0200\n"
|
||||
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug."
|
||||
"cgi?product=NetworkManager&component=general\n"
|
||||
"POT-Creation-Date: 2008-12-07 22:31+0000\n"
|
||||
"PO-Revision-Date: 2008-12-18 16:53+0100\n"
|
||||
"Last-Translator: Jennie Petoumenou <epetoumenou@gmail.com>\n"
|
||||
"Language-Team: Greek <team@gnome.gr>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
|
@ -308,7 +309,7 @@ msgstr "σφάλμα κατά την αναμονή για δεδομένα στ
|
|||
#, c-format
|
||||
msgid "Invalid option. Please use --help to see a list of valid options.\n"
|
||||
msgstr ""
|
||||
"Άκυρη επιλογή. Παρακαλώ χρησιμοποιείστε --help για να δείτε τη λίστα των "
|
||||
"Άκυρη επιλογή. Παρακαλώ χρησιμοποιήστε --help για να δείτε τη λίστα των "
|
||||
"έγκυρων επιλογών.\n"
|
||||
|
||||
#: ../src/dhcp-manager/nm-dhcp-dhclient.c:88
|
||||
|
|
@ -338,3 +339,4 @@ msgstr "Οι κάτωθι εξυπηρετητές ονομάτων ίσως ν
|
|||
#, c-format
|
||||
msgid "Auto %s"
|
||||
msgstr "Αυτόματο %s"
|
||||
|
||||
|
|
|
|||
193
po/pt_BR.po
193
po/pt_BR.po
|
|
@ -10,54 +10,48 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: NetworkManager\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2008-10-22 21:13-0400\n"
|
||||
"PO-Revision-Date: 2008-10-04 23:43-0300\n"
|
||||
"Last-Translator: Fabrício Godoy <skarllot@gmail.com>\n"
|
||||
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager&component=general\n"
|
||||
"POT-Creation-Date: 2008-11-13 21:19+0000\n"
|
||||
"PO-Revision-Date: 2008-12-04 17:34-0300\n"
|
||||
"Last-Translator: Henrique P Machado <zehrique@gmail.com>\n"
|
||||
"Language-Team: Brazilian Portuguese <gnome-l10n-br@listas.cipsga.org.br>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:193 ../src/nm-netlink-monitor.c:474
|
||||
#: ../src/nm-netlink-monitor.c:195
|
||||
#: ../src/nm-netlink-monitor.c:476
|
||||
#, c-format
|
||||
msgid "error processing netlink message: %s"
|
||||
msgstr "erro ao processar mensagem do netlink: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:250
|
||||
#: ../src/nm-netlink-monitor.c:252
|
||||
#, c-format
|
||||
msgid "unable to allocate netlink handle for monitoring link status: %s"
|
||||
msgstr ""
|
||||
"não foi possível alocar o manipulador do netlink para monitoração de status "
|
||||
"do link: %s"
|
||||
msgstr "não foi possível alocar o manipulador do netlink para monitoração de status do link: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:260
|
||||
#: ../src/nm-netlink-monitor.c:262
|
||||
#, c-format
|
||||
msgid "unable to connect to netlink for monitoring link status: %s"
|
||||
msgstr ""
|
||||
"não foi possível conectar ao netlink para monitoração de status do link: %s"
|
||||
msgstr "não foi possível conectar ao netlink para monitoração de status do link: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:268
|
||||
#: ../src/nm-netlink-monitor.c:270
|
||||
#, c-format
|
||||
msgid "unable to join netlink group for monitoring link status: %s"
|
||||
msgstr ""
|
||||
"não foi possível associar-se ao grupo do netlink para monitoração de status "
|
||||
"do link: %s"
|
||||
msgstr "não foi possível associar-se ao grupo do netlink para monitoração de status do link: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:276
|
||||
#: ../src/nm-netlink-monitor.c:278
|
||||
#, c-format
|
||||
msgid "unable to allocate netlink link cache for monitoring link status: %s"
|
||||
msgstr ""
|
||||
"não foi possível alocar o cache de link do netlink para monitoração de "
|
||||
"status do link: %s"
|
||||
msgstr "não foi possível alocar o cache de link do netlink para monitoração de status do link: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:439
|
||||
#: ../src/nm-netlink-monitor.c:441
|
||||
#, c-format
|
||||
msgid "error updating link cache: %s"
|
||||
msgstr "erro ao atualizar o cache de link: %s"
|
||||
|
||||
#: ../src/nm-netlink-monitor.c:497
|
||||
#: ../src/nm-netlink-monitor.c:499
|
||||
#, c-format
|
||||
msgid "error occurred while waiting for data on socket"
|
||||
msgstr "ocorreu um erro ao esperar pelos dados da conexão"
|
||||
|
|
@ -65,14 +59,13 @@ msgstr "ocorreu um erro ao esperar pelos dados da conexão"
|
|||
#: ../src/NetworkManager.c:252
|
||||
#, c-format
|
||||
msgid "Invalid option. Please use --help to see a list of valid options.\n"
|
||||
msgstr ""
|
||||
"Opção inválida. Por favor, use --help para ver uma lista de opções válidas.\n"
|
||||
msgstr "Opção inválida. Por favor, use --help para ver uma lista de opções válidas.\n"
|
||||
|
||||
#: ../src/dhcp-manager/nm-dhcp-dhclient.c:89
|
||||
#: ../src/dhcp-manager/nm-dhcp-dhclient.c:88
|
||||
msgid "# Created by NetworkManager\n"
|
||||
msgstr "# Criado pelo NetworkManager\n"
|
||||
|
||||
#: ../src/dhcp-manager/nm-dhcp-dhclient.c:95
|
||||
#: ../src/dhcp-manager/nm-dhcp-dhclient.c:94
|
||||
#, c-format
|
||||
msgid ""
|
||||
"# Merged from %s\n"
|
||||
|
|
@ -83,126 +76,135 @@ msgstr ""
|
|||
|
||||
#: ../src/named-manager/nm-named-manager.c:256
|
||||
msgid "NOTE: the libc resolver may not support more than 3 nameservers."
|
||||
msgstr ""
|
||||
"NOTA: o resolvedor da libc não tem suporte a mais do que 3 servidores de "
|
||||
"nomes."
|
||||
msgstr "NOTA: o resolvedor da libc não tem suporte a mais do que 3 servidores de nomes."
|
||||
|
||||
#: ../src/named-manager/nm-named-manager.c:258
|
||||
msgid "The nameservers listed below may not be recognized."
|
||||
msgstr "Os servidores de nomes listados abaixo podem não ser reconhecidos."
|
||||
|
||||
#: ../system-settings/src/main.c:366
|
||||
#: ../system-settings/src/main.c:376
|
||||
#, c-format
|
||||
msgid "Auto %s"
|
||||
msgstr "Auto %s"
|
||||
|
||||
#: ../libnm-util/crypto.c:125
|
||||
#: ../libnm-util/crypto.c:120
|
||||
#, c-format
|
||||
msgid "PEM key file had no end tag '%s'."
|
||||
msgstr "A chave do arquivo PEM não tinha a marca de finalização \"%s\"."
|
||||
|
||||
#: ../libnm-util/crypto.c:135
|
||||
#: ../libnm-util/crypto.c:130
|
||||
#, c-format
|
||||
msgid "Doesn't look like a PEM private key file."
|
||||
msgstr "Não se parece com um arquivo de chave privada PEM."
|
||||
|
||||
#: ../libnm-util/crypto.c:143
|
||||
#: ../libnm-util/crypto.c:138
|
||||
#, c-format
|
||||
msgid "Not enough memory to store PEM file data."
|
||||
msgstr "Memória insuficiente para armazenar os dados do arquivo PEM."
|
||||
|
||||
#: ../libnm-util/crypto.c:159
|
||||
#: ../libnm-util/crypto.c:154
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: Proc-Type was not first tag."
|
||||
msgstr "Arquivo PEM defeituoso: Proc-Type não era a primeira marca."
|
||||
|
||||
#: ../libnm-util/crypto.c:167
|
||||
#: ../libnm-util/crypto.c:162
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: unknown Proc-Type tag '%s'."
|
||||
msgstr "Arquivo PEM defeituoso: marca Proc-Type desconhecida: \"%s\"."
|
||||
|
||||
#: ../libnm-util/crypto.c:177
|
||||
#: ../libnm-util/crypto.c:172
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: DEK-Info was not the second tag."
|
||||
msgstr "Arquivo PEM defeituoso: DEK-Info não era a segunda marca."
|
||||
|
||||
#: ../libnm-util/crypto.c:188
|
||||
#: ../libnm-util/crypto.c:183
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: no IV found in DEK-Info tag."
|
||||
msgstr "Arquivo PEM defeituoso: nenhum IV localizado na marca DEK-Info."
|
||||
|
||||
#: ../libnm-util/crypto.c:195
|
||||
#: ../libnm-util/crypto.c:190
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: invalid format of IV in DEK-Info tag."
|
||||
msgstr "Arquivo PEM defeituoso: formato inválido do IV na marca DEK-Info."
|
||||
|
||||
#: ../libnm-util/crypto.c:208
|
||||
#: ../libnm-util/crypto.c:203
|
||||
#, c-format
|
||||
msgid "Malformed PEM file: unknown private key cipher '%s'."
|
||||
msgstr "Arquivo PEM defeituoso: cifra de chave privada desconhecida \"%s\"."
|
||||
|
||||
#: ../libnm-util/crypto.c:227
|
||||
#: ../libnm-util/crypto.c:222
|
||||
#, c-format
|
||||
msgid "Could not decode private key."
|
||||
msgstr "Não foi possível decodificar chave privada."
|
||||
|
||||
#: ../libnm-util/crypto.c:271
|
||||
#: ../libnm-util/crypto.c:267
|
||||
#, c-format
|
||||
msgid "PEM certificate '%s' had no end tag '%s'."
|
||||
msgstr "Certificado PEM \"%s\" não tinha a marca de finalização \"%s\"."
|
||||
|
||||
#: ../libnm-util/crypto.c:281
|
||||
#: ../libnm-util/crypto.c:277
|
||||
#, c-format
|
||||
msgid "Failed to decode certificate."
|
||||
msgstr "Falha ao decodificar o certificado."
|
||||
|
||||
#: ../libnm-util/crypto.c:290 ../libnm-util/crypto.c:298
|
||||
#: ../libnm-util/crypto.c:286
|
||||
#, c-format
|
||||
msgid "Not enough memory to store certificate data."
|
||||
msgstr "Memória insuficiente para armazenar os dados do certificado."
|
||||
|
||||
#: ../libnm-util/crypto.c:328
|
||||
#: ../libnm-util/crypto.c:294
|
||||
#, c-format
|
||||
msgid "Not enough memory to store file data."
|
||||
msgstr "Memória insuficiente para armazenar dados no arquivo."
|
||||
|
||||
#: ../libnm-util/crypto.c:324
|
||||
#, c-format
|
||||
msgid "IV must be an even number of bytes in length."
|
||||
msgstr "O tamanho do IV deve ser um número par de bytes."
|
||||
|
||||
#: ../libnm-util/crypto.c:337
|
||||
#: ../libnm-util/crypto.c:333
|
||||
#, c-format
|
||||
msgid "Not enough memory to store the IV."
|
||||
msgstr "Memória insuficiente para armazenar o IV."
|
||||
|
||||
#: ../libnm-util/crypto.c:348
|
||||
#: ../libnm-util/crypto.c:344
|
||||
#, c-format
|
||||
msgid "IV contains non-hexadecimal digits."
|
||||
msgstr "IV contém dígitos não-hexadecimais."
|
||||
|
||||
#: ../libnm-util/crypto.c:386 ../libnm-util/crypto_gnutls.c:143
|
||||
#: ../libnm-util/crypto_nss.c:157
|
||||
#: ../libnm-util/crypto.c:382
|
||||
#: ../libnm-util/crypto_gnutls.c:143
|
||||
#: ../libnm-util/crypto_nss.c:169
|
||||
#, c-format
|
||||
msgid "Private key cipher '%s' was unknown."
|
||||
msgstr "Cifra da chave privada \"%s\" não foi reconhecida."
|
||||
msgstr "A cifra da chave privada \"%s\" era desconhecida."
|
||||
|
||||
#: ../libnm-util/crypto.c:395
|
||||
#: ../libnm-util/crypto.c:391
|
||||
#, c-format
|
||||
msgid "Not enough memory to decrypt private key."
|
||||
msgstr "Memória insuficiente para descriptografar a chave privada."
|
||||
|
||||
#: ../libnm-util/crypto.c:513
|
||||
#: ../libnm-util/crypto.c:511
|
||||
#, c-format
|
||||
msgid "Unable to determine private key type."
|
||||
msgstr "Não foi possível determinar o tipo da chave privada."
|
||||
|
||||
#: ../libnm-util/crypto.c:530
|
||||
#, c-format
|
||||
msgid "Not enough memory to store decrypted private key."
|
||||
msgstr ""
|
||||
"Memória insuficiente para armazenar a chave privada de descriptografia."
|
||||
msgstr "Memória insuficiente para armazenar a chave privada de descriptografia."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:45
|
||||
#: ../libnm-util/crypto_gnutls.c:46
|
||||
msgid "Failed to initialize the crypto engine."
|
||||
msgstr "Falha ao iniciar o motor de criptografia."
|
||||
msgstr "Falha ao inicializar o motor de criptografia."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:89
|
||||
#: ../libnm-util/crypto_gnutls.c:90
|
||||
#, c-format
|
||||
msgid "Failed to initialize the MD5 engine: %s / %s."
|
||||
msgstr "Falha ao iniciar o motor MD5: %s / %s."
|
||||
msgstr "Falha ao inicializar o motor MD5: %s / %s."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:152 ../libnm-util/crypto_nss.c:166
|
||||
#: ../libnm-util/crypto_gnutls.c:152
|
||||
#: ../libnm-util/crypto_nss.c:178
|
||||
#, c-format
|
||||
msgid "Not enough memory for decrypted key buffer."
|
||||
msgstr "Memória insuficiente para o buffer da chave descriptografada."
|
||||
|
|
@ -210,7 +212,7 @@ msgstr "Memória insuficiente para o buffer da chave descriptografada."
|
|||
#: ../libnm-util/crypto_gnutls.c:160
|
||||
#, c-format
|
||||
msgid "Failed to initialize the decryption cipher context: %s / %s."
|
||||
msgstr "Falha ao iniciar o contexto da cifra de descriptografia: %s / %s."
|
||||
msgstr "Falha ao inicializar o contexto da cifra de descriptografia: %s / %s."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:169
|
||||
#, c-format
|
||||
|
|
@ -227,60 +229,101 @@ msgstr "Falha ao definir IV para descriptografia: %s / %s."
|
|||
msgid "Failed to decrypt the private key: %s / %s."
|
||||
msgstr "Falha ao descriptografar a chave privada: %s / %s."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:225
|
||||
#: ../libnm-util/crypto_gnutls.c:200
|
||||
#, c-format
|
||||
msgid "Failed to decrypt the private key."
|
||||
msgstr "Falha ao descriptografar a chave privada."
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:235
|
||||
#, c-format
|
||||
msgid "Error initializing certificate data: %s"
|
||||
msgstr "Erro ao iniciar os dados do certificado: %s"
|
||||
msgstr "Erro ao inicializar os dados do certificado: %s"
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:237
|
||||
#: ../libnm-util/crypto_gnutls.c:257
|
||||
#, c-format
|
||||
msgid "Couldn't decode certificate: %s"
|
||||
msgstr "Não foi possível decodificar o certificado: %s"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:52
|
||||
#: ../libnm-util/crypto_gnutls.c:281
|
||||
#, c-format
|
||||
msgid "Couldn't initialize PKCS#12 decoder: %s"
|
||||
msgstr "Não foi possível inicializar o decodificador PKCS#12: %s"
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:294
|
||||
#, c-format
|
||||
msgid "Couldn't decode PKCS#12 file: %s"
|
||||
msgstr "Não foi possível decodificar o arquivo PKCS#12: %s"
|
||||
|
||||
#: ../libnm-util/crypto_gnutls.c:306
|
||||
#, c-format
|
||||
msgid "Couldn't verify PKCS#12 file: %s"
|
||||
msgstr "Não foi possível verificar o arquivo PKCS#12: %s"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:57
|
||||
#, c-format
|
||||
msgid "Failed to initialize the crypto engine: %d."
|
||||
msgstr "Falha ao iniciar o motor de criptografia: %d."
|
||||
msgstr "Falha ao inicializar o motor de criptografia: %d."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:98
|
||||
#: ../libnm-util/crypto_nss.c:111
|
||||
#, c-format
|
||||
msgid "Failed to initialize the MD5 context: %d."
|
||||
msgstr "Falha ao iniciar o contexto MD5: %d."
|
||||
msgstr "Falha ao inicializar o contexto MD5: %d."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:174
|
||||
#: ../libnm-util/crypto_nss.c:186
|
||||
#, c-format
|
||||
msgid "Failed to initialize the decryption cipher slot."
|
||||
msgstr "Falha ao iniciar o espaço de cifra de descriptografia."
|
||||
msgstr "Falha ao inicializar o espaço de cifra de descriptografia."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:184
|
||||
#: ../libnm-util/crypto_nss.c:196
|
||||
#, c-format
|
||||
msgid "Failed to set symmetric key for decryption."
|
||||
msgstr "Falha ao definir chave simétrica para descriptografia."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:194
|
||||
#: ../libnm-util/crypto_nss.c:206
|
||||
#, c-format
|
||||
msgid "Failed to set IV for decryption."
|
||||
msgstr "Falha ao definir IV para descriptografia."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:202
|
||||
#: ../libnm-util/crypto_nss.c:214
|
||||
#, c-format
|
||||
msgid "Failed to initialize the decryption context."
|
||||
msgstr "Falha ao iniciar o contexto de descriptografia."
|
||||
msgstr "Falha ao inicializar o contexto de descriptografia."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:215
|
||||
#: ../libnm-util/crypto_nss.c:227
|
||||
#, c-format
|
||||
msgid "Failed to decrypt the private key: %d."
|
||||
msgstr "Falha ao descriptografar a chave privada: %d."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:227
|
||||
#: ../libnm-util/crypto_nss.c:239
|
||||
#, c-format
|
||||
msgid "Failed to finalize decryption of the private key: %d."
|
||||
msgstr "Falha ao finalizar a descriptografia da chave privada: %d."
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:271
|
||||
#: ../libnm-util/crypto_nss.c:284
|
||||
#, c-format
|
||||
msgid "Couldn't decode certificate: %d"
|
||||
msgstr "Não foi possível decodificar o certificado: %d"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:317
|
||||
#, c-format
|
||||
msgid "Couldn't convert password to UCS2: %d"
|
||||
msgstr "Não foi possível converter senha para o formato UCS2: %d"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:345
|
||||
#, c-format
|
||||
msgid "Couldn't initialize PKCS#12 decoder: %d"
|
||||
msgstr "Não foi possível inicializar o decodificador PKCS#12: %d"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:354
|
||||
#, c-format
|
||||
msgid "Couldn't decode PKCS#12 file: %d"
|
||||
msgstr "Não foi possível decodificar o arquivo PKCS#12: %d"
|
||||
|
||||
#: ../libnm-util/crypto_nss.c:363
|
||||
#, c-format
|
||||
msgid "Couldn't verify PKCS#12 file: %d"
|
||||
msgstr "Não foi possível verificar o arquivo PKCS#12: %d"
|
||||
|
||||
#~ msgid "Not enough memory to create private key decryption key."
|
||||
#~ msgstr "Memória insuficiente para descriptografar a chave privada."
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ SUBDIRS= \
|
|||
supplicant-manager \
|
||||
ppp-manager \
|
||||
backends \
|
||||
dnsmasq-manager
|
||||
dnsmasq-manager \
|
||||
. \
|
||||
tests
|
||||
|
||||
INCLUDES = -I${top_srcdir} \
|
||||
-I${top_srcdir}/include \
|
||||
|
|
@ -18,6 +20,32 @@ INCLUDES = -I${top_srcdir} \
|
|||
-I${top_srcdir}/libnm-util \
|
||||
-I${top_srcdir}/callouts
|
||||
|
||||
###########################################
|
||||
# DHCP test library
|
||||
###########################################
|
||||
|
||||
noinst_LTLIBRARIES = libtest-dhcp.la
|
||||
|
||||
libtest_dhcp_la_SOURCES = \
|
||||
nm-ip4-config.c \
|
||||
nm-dbus-manager.c
|
||||
|
||||
libtest_dhcp_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(LIBNL_CFLAGS)
|
||||
|
||||
libtest_dhcp_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(LIBNL_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
|
||||
|
||||
###########################################
|
||||
# NetworkManager
|
||||
###########################################
|
||||
|
||||
sbin_PROGRAMS = NetworkManager
|
||||
|
||||
NetworkManager_SOURCES = \
|
||||
|
|
@ -139,19 +167,19 @@ NetworkManager_CPPFLAGS = \
|
|||
-DARP_DEBUG
|
||||
|
||||
NetworkManager_LDADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(HAL_LIBS) \
|
||||
$(LIBNL_LIBS) \
|
||||
$(top_builddir)/marshallers/libmarshallers.la \
|
||||
./named-manager/libnamed-manager.la \
|
||||
./vpn-manager/libvpn-manager.la \
|
||||
./dhcp-manager/libdhcp-manager.la \
|
||||
./supplicant-manager/libsupplicant-manager.la \
|
||||
./dnsmasq-manager/libdnsmasq-manager.la \
|
||||
./ppp-manager/libppp-manager.la \
|
||||
./backends/libnmbackend.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
$(DBUS_LIBS) \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(HAL_LIBS) \
|
||||
$(LIBNL_LIBS) \
|
||||
$(top_builddir)/marshallers/libmarshallers.la \
|
||||
./named-manager/libnamed-manager.la \
|
||||
./vpn-manager/libvpn-manager.la \
|
||||
./dhcp-manager/libdhcp-manager.la \
|
||||
./supplicant-manager/libsupplicant-manager.la \
|
||||
./dnsmasq-manager/libdnsmasq-manager.la \
|
||||
./ppp-manager/libppp-manager.la \
|
||||
./backends/libnmbackend.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
|
||||
NetworkManager_LDFLAGS = -rdynamic
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
<allow send_destination="org.freedesktop.NetworkManager"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager"/>
|
||||
|
||||
<allow own="org.freedesktop.NetworkManager.PPP"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.PPP"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
</policy>
|
||||
<policy at_console="true">
|
||||
<allow send_destination="org.freedesktop.NetworkManager"/>
|
||||
|
|
@ -20,9 +19,8 @@
|
|||
<deny send_destination="org.freedesktop.NetworkManager"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager"/>
|
||||
|
||||
<deny own="org.freedesktop.NetworkManager.PPP"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.PPP"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager"
|
||||
send_interface="org.freedesktop.NetworkManager.PPP"/>
|
||||
</policy>
|
||||
|
||||
<limit name="max_replies_per_connection">512</limit>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#define NM_ACCESS_POINT_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib-object.h>
|
||||
#include <time.h>
|
||||
#include "NetworkManager.h"
|
||||
|
|
|
|||
|
|
@ -860,19 +860,33 @@ static void
|
|||
device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
|
||||
{
|
||||
NMPolicy *policy = (NMPolicy *) user_data;
|
||||
GSList *iter = policy->dev_signal_ids;
|
||||
GSList *iter;
|
||||
|
||||
/* Clear any idle callbacks for this device */
|
||||
iter = policy->pending_activation_checks;
|
||||
while (iter) {
|
||||
ActivateData *data = (ActivateData *) iter->data;
|
||||
GSList *next = g_slist_next (iter);
|
||||
|
||||
if (data->device == device) {
|
||||
g_source_remove (data->id);
|
||||
g_object_unref (data->device);
|
||||
g_free (data);
|
||||
policy->pending_activation_checks = g_slist_delete_link (policy->pending_activation_checks, iter);
|
||||
}
|
||||
iter = next;
|
||||
}
|
||||
|
||||
/* Clear any signal handlers for this device */
|
||||
iter = policy->dev_signal_ids;
|
||||
while (iter) {
|
||||
DeviceSignalID *data = (DeviceSignalID *) iter->data;
|
||||
GSList *next = g_slist_next (iter);
|
||||
|
||||
if (data->device == device) {
|
||||
policy->dev_signal_ids = g_slist_remove_link (policy->dev_signal_ids, iter);
|
||||
|
||||
g_signal_handler_disconnect (data->device, data->id);
|
||||
g_free (data);
|
||||
g_slist_free (iter);
|
||||
policy->dev_signal_ids = g_slist_delete_link (policy->dev_signal_ids, iter);
|
||||
}
|
||||
iter = next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,20 +133,6 @@ nm_print_device_capabilities (NMDevice *dev)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
struct nl_addr *
|
||||
nm_utils_ip4_addr_to_nl_addr (guint32 ip4_addr)
|
||||
{
|
||||
struct nl_addr * nla = NULL;
|
||||
|
||||
if (!(nla = nl_addr_alloc (sizeof (in_addr_t))))
|
||||
return NULL;
|
||||
nl_addr_set_family (nla, AF_INET);
|
||||
nl_addr_set_binary_addr (nla, &ip4_addr, sizeof (guint32));
|
||||
|
||||
return nla;
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_utils_ip4_netmask_to_prefix
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ int nm_spawn_process (const char *args);
|
|||
|
||||
void nm_print_device_capabilities (NMDevice *dev);
|
||||
|
||||
struct nl_addr *nm_utils_ip4_addr_to_nl_addr (guint32 ip4_addr);
|
||||
|
||||
char *nm_utils_hexstr2bin (const char *hex, size_t len);
|
||||
|
||||
char *nm_ether_ntop (const struct ether_addr *mac);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -288,3 +290,133 @@ out:
|
|||
g_ptr_array_free (dhclient_argv, TRUE);
|
||||
return success;
|
||||
}
|
||||
|
||||
static const char **
|
||||
process_rfc3442_route (const char **octets, NMIP4Route **out_route)
|
||||
{
|
||||
const char **o = octets;
|
||||
int addr_len = 0, i = 0;
|
||||
long int tmp;
|
||||
NMIP4Route *route;
|
||||
char *next_hop;
|
||||
struct in_addr tmp_addr;
|
||||
|
||||
if (!*o)
|
||||
return o; /* no prefix */
|
||||
|
||||
tmp = strtol (*o, NULL, 10);
|
||||
if (tmp < 0 || tmp > 32) /* 32 == max IP4 prefix length */
|
||||
return o;
|
||||
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_prefix (route, (guint32) tmp);
|
||||
o++;
|
||||
|
||||
if (tmp > 0)
|
||||
addr_len = ((tmp - 1) / 8) + 1;
|
||||
|
||||
/* ensure there's at least the address + next hop left */
|
||||
if (g_strv_length ((char **) o) < addr_len + 4)
|
||||
goto error;
|
||||
|
||||
if (tmp) {
|
||||
const char *addr[4] = { "0", "0", "0", "0" };
|
||||
char *str_addr;
|
||||
|
||||
for (i = 0; i < addr_len; i++)
|
||||
addr[i] = *o++;
|
||||
|
||||
str_addr = g_strjoin (".", addr[0], addr[1], addr[2], addr[3], NULL);
|
||||
if (inet_pton (AF_INET, str_addr, &tmp_addr) <= 0) {
|
||||
g_free (str_addr);
|
||||
goto error;
|
||||
}
|
||||
tmp_addr.s_addr &= nm_utils_ip4_prefix_to_netmask ((guint32) tmp);
|
||||
nm_ip4_route_set_dest (route, tmp_addr.s_addr);
|
||||
}
|
||||
|
||||
/* Handle next hop */
|
||||
next_hop = g_strjoin (".", o[0], o[1], o[2], o[3], NULL);
|
||||
if (inet_pton (AF_INET, next_hop, &tmp_addr) <= 0) {
|
||||
g_free (next_hop);
|
||||
goto error;
|
||||
}
|
||||
nm_ip4_route_set_next_hop (route, tmp_addr.s_addr);
|
||||
g_free (next_hop);
|
||||
|
||||
*out_route = route;
|
||||
return o + 4; /* advance to past the next hop */
|
||||
|
||||
error:
|
||||
nm_ip4_route_unref (route);
|
||||
return o;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_process_classless_routes (GHashTable *options,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr)
|
||||
{
|
||||
const char *str;
|
||||
char **octets, **o;
|
||||
gboolean have_routes = FALSE;
|
||||
NMIP4Route *route = NULL;
|
||||
|
||||
/* dhclient doesn't have actual support for rfc3442 classless static routes
|
||||
* upstream. Thus, people resort to defining the option in dhclient.conf
|
||||
* and using arbitrary formats like so:
|
||||
*
|
||||
* option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
|
||||
*
|
||||
* See https://lists.isc.org/pipermail/dhcp-users/2008-December/007629.html
|
||||
*/
|
||||
|
||||
str = g_hash_table_lookup (options, "new_rfc3442_classless_static_routes");
|
||||
/* Microsoft version; same as rfc3442 but with a different option # (249) */
|
||||
if (!str)
|
||||
str = g_hash_table_lookup (options, "new_ms_classless_static_routes");
|
||||
|
||||
if (!str || !strlen (str))
|
||||
return FALSE;
|
||||
|
||||
o = octets = g_strsplit (str, " ", 0);
|
||||
if (g_strv_length (octets) < 5) {
|
||||
nm_warning ("Ignoring invalid classless static routes '%s'", str);
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (*o) {
|
||||
route = NULL;
|
||||
o = (char **) process_rfc3442_route ((const char **) o, &route);
|
||||
if (!route) {
|
||||
nm_warning ("Ignoring invalid classless static routes");
|
||||
break;
|
||||
}
|
||||
|
||||
have_routes = TRUE;
|
||||
if (nm_ip4_route_get_prefix (route) == 0) {
|
||||
/* gateway passed as classless static route */
|
||||
*gwaddr = nm_ip4_route_get_next_hop (route);
|
||||
nm_ip4_route_unref (route);
|
||||
} else {
|
||||
char addr[INET_ADDRSTRLEN + 1];
|
||||
char nh[INET_ADDRSTRLEN + 1];
|
||||
struct in_addr tmp;
|
||||
|
||||
/* normal route */
|
||||
nm_ip4_config_take_route (ip4_config, route);
|
||||
|
||||
tmp.s_addr = nm_ip4_route_get_dest (route);
|
||||
inet_ntop (AF_INET, &tmp, addr, sizeof (addr));
|
||||
tmp.s_addr = nm_ip4_route_get_next_hop (route);
|
||||
inet_ntop (AF_INET, &tmp, nh, sizeof (nh));
|
||||
nm_info (" classless static route %s/%d gw %s",
|
||||
addr, nm_ip4_route_get_prefix (route), nh);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
g_strfreev (octets);
|
||||
return have_routes;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
@ -118,3 +120,80 @@ out:
|
|||
g_ptr_array_free (argv, TRUE);
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_process_classless_routes (GHashTable *options,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr)
|
||||
{
|
||||
const char *str;
|
||||
char **routes, **r;
|
||||
gboolean have_routes = FALSE;
|
||||
|
||||
/* Classless static routes over-ride any static routes and routers
|
||||
* provided. We should also check for MS classless static routes as
|
||||
* they implemented the draft RFC using their own code.
|
||||
*/
|
||||
str = g_hash_table_lookup (options, "new_classless_static_routes");
|
||||
if (!str)
|
||||
str = g_hash_table_lookup (options, "new_ms_classless_static_routes");
|
||||
|
||||
if (!str || !strlen (str))
|
||||
return FALSE;
|
||||
|
||||
routes = g_strsplit (str, " ", 0);
|
||||
if (g_strv_length (routes) == 0)
|
||||
goto out;
|
||||
|
||||
if ((g_strv_length (routes) % 2) != 0) {
|
||||
nm_info (" classless static routes provided, but invalid");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (r = routes; *r; r += 2) {
|
||||
char *slash;
|
||||
NMIP4Route *route;
|
||||
int rt_cidr = 32;
|
||||
struct in_addr rt_addr;
|
||||
struct in_addr rt_route;
|
||||
|
||||
slash = strchr(*r, '/');
|
||||
if (slash) {
|
||||
*slash = '\0';
|
||||
errno = 0;
|
||||
rt_cidr = strtol (slash + 1, NULL, 10);
|
||||
if ((errno == EINVAL) || (errno == ERANGE)) {
|
||||
nm_warning ("DHCP provided invalid classless static route cidr: '%s'", slash + 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (inet_pton (AF_INET, *r, &rt_addr) <= 0) {
|
||||
nm_warning ("DHCP provided invalid classless static route address: '%s'", *r);
|
||||
continue;
|
||||
}
|
||||
if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) {
|
||||
nm_warning ("DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
have_routes = TRUE;
|
||||
if (rt_cidr == 0 && rt_addr.s_addr == 0) {
|
||||
/* FIXME: how to handle multiple routers? */
|
||||
*gwaddr = rt_addr.s_addr;
|
||||
} else {
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_dest (route, (guint32) rt_addr.s_addr);
|
||||
nm_ip4_route_set_prefix (route, rt_cidr);
|
||||
nm_ip4_route_set_next_hop (route, (guint32) rt_route.s_addr);
|
||||
|
||||
|
||||
nm_ip4_config_take_route (ip4_config, route);
|
||||
nm_info (" classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
g_strfreev (routes);
|
||||
return have_routes;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "nm-utils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#define NM_DHCP_CLIENT_DBUS_SERVICE "org.freedesktop.nm_dhcp_client"
|
||||
#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
|
||||
|
|
@ -603,9 +604,9 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
|
|||
timeout = NM_DHCP_TIMEOUT;
|
||||
|
||||
/* Set up a timeout on the transaction to kill it after the timeout */
|
||||
device->timeout_id = g_timeout_add (timeout * 1000,
|
||||
nm_dhcp_manager_handle_timeout,
|
||||
device);
|
||||
device->timeout_id = g_timeout_add_seconds (timeout,
|
||||
nm_dhcp_manager_handle_timeout,
|
||||
device);
|
||||
|
||||
nm_dhcp_client_start (device, s_ip4);
|
||||
device->watch_id = g_child_watch_add (device->pid,
|
||||
|
|
@ -719,6 +720,209 @@ nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager,
|
|||
nm_dhcp_manager_cancel_transaction_real (device);
|
||||
}
|
||||
|
||||
static void
|
||||
process_classful_routes (GHashTable *options, NMIP4Config *ip4_config)
|
||||
{
|
||||
const char *str;
|
||||
char **searches, **s;
|
||||
|
||||
str = g_hash_table_lookup (options, "new_static_routes");
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
searches = g_strsplit (str, " ", 0);
|
||||
if ((g_strv_length (searches) % 2)) {
|
||||
nm_info (" static routes provided, but invalid");
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (s = searches; *s; s += 2) {
|
||||
NMIP4Route *route;
|
||||
struct in_addr rt_addr;
|
||||
struct in_addr rt_route;
|
||||
|
||||
if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
|
||||
nm_warning ("DHCP provided invalid static route address: '%s'", *s);
|
||||
continue;
|
||||
}
|
||||
if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) {
|
||||
nm_warning ("DHCP provided invalid static route gateway: '%s'", *(s + 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
// FIXME: ensure the IP addresse and route are sane
|
||||
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_dest (route, (guint32) rt_addr.s_addr);
|
||||
nm_ip4_route_set_prefix (route, 32); /* 255.255.255.255 */
|
||||
nm_ip4_route_set_next_hop (route, (guint32) rt_route.s_addr);
|
||||
|
||||
nm_ip4_config_take_route (ip4_config, route);
|
||||
nm_info (" static route %s gw %s", *s, *(s + 1));
|
||||
}
|
||||
|
||||
out:
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
/* Given a table of DHCP options from the client, convert into an IP4Config */
|
||||
NMIP4Config *
|
||||
nm_dhcp_manager_options_to_ip4_config (const char *iface, GHashTable *options)
|
||||
{
|
||||
NMIP4Config *ip4_config = NULL;
|
||||
struct in_addr tmp_addr;
|
||||
NMIP4Address *addr = NULL;
|
||||
char *str = NULL;
|
||||
guint32 gwaddr = 0;
|
||||
gboolean have_classless = FALSE;
|
||||
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
g_return_val_if_fail (options != NULL, NULL);
|
||||
|
||||
ip4_config = nm_ip4_config_new ();
|
||||
if (!ip4_config) {
|
||||
nm_warning ("%s: couldn't allocate memory for an IP4Config!", iface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addr = nm_ip4_address_new ();
|
||||
if (!addr) {
|
||||
nm_warning ("%s: couldn't allocate memory for an IP4 Address!", iface);
|
||||
goto error;
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (options, "new_ip_address");
|
||||
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
|
||||
nm_ip4_address_set_address (addr, tmp_addr.s_addr);
|
||||
nm_info (" address %s", str);
|
||||
} else
|
||||
goto error;
|
||||
|
||||
str = g_hash_table_lookup (options, "new_subnet_mask");
|
||||
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
|
||||
nm_ip4_address_set_prefix (addr, nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr));
|
||||
nm_info (" prefix %d (%s)", nm_ip4_address_get_prefix (addr), str);
|
||||
}
|
||||
|
||||
/* Routes: if the server returns classless static routes, we MUST ignore
|
||||
* the 'static_routes' option.
|
||||
*/
|
||||
have_classless = nm_dhcp_client_process_classless_routes (options, ip4_config, &gwaddr);
|
||||
if (!have_classless) {
|
||||
gwaddr = 0; /* Ensure client code doesn't lie */
|
||||
process_classful_routes (options, ip4_config);
|
||||
}
|
||||
|
||||
if (gwaddr) {
|
||||
char buf[INET_ADDRSTRLEN + 1];
|
||||
|
||||
inet_ntop (AF_INET, &gwaddr, buf, sizeof (buf));
|
||||
nm_info (" gateway %s", buf);
|
||||
nm_ip4_address_set_gateway (addr, gwaddr);
|
||||
} else {
|
||||
/* If the gateway wasn't provided as a classless static route with a
|
||||
* subnet length of 0, try to find it using the old-style 'routers' option.
|
||||
*/
|
||||
str = g_hash_table_lookup (options, "new_routers");
|
||||
if (str) {
|
||||
char **routers = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = routers; *s; s++) {
|
||||
/* FIXME: how to handle multiple routers? */
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_address_set_gateway (addr, tmp_addr.s_addr);
|
||||
nm_info (" gateway %s", *s);
|
||||
break;
|
||||
} else
|
||||
nm_warning ("Ignoring invalid gateway '%s'", *s);
|
||||
}
|
||||
g_strfreev (routers);
|
||||
}
|
||||
}
|
||||
|
||||
nm_ip4_config_take_address (ip4_config, addr);
|
||||
addr = NULL;
|
||||
|
||||
str = g_hash_table_lookup (options, "new_host_name");
|
||||
if (str)
|
||||
nm_info (" hostname '%s'", str);
|
||||
|
||||
str = g_hash_table_lookup (options, "new_domain_name_servers");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_config_add_nameserver (ip4_config, tmp_addr.s_addr);
|
||||
nm_info (" nameserver '%s'", *s);
|
||||
} else
|
||||
nm_warning ("Ignoring invalid nameserver '%s'", *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (options, "new_domain_name");
|
||||
if (str) {
|
||||
char **domains = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = domains; *s; s++) {
|
||||
nm_info (" domain name '%s'", *s);
|
||||
nm_ip4_config_add_domain (ip4_config, *s);
|
||||
}
|
||||
g_strfreev (domains);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (options, "new_domain_search");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
nm_info (" domain search '%s'", *s);
|
||||
nm_ip4_config_add_search (ip4_config, *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (options, "new_netbios_name_servers");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_config_add_wins (ip4_config, tmp_addr.s_addr);
|
||||
nm_info (" wins '%s'", *s);
|
||||
} else
|
||||
nm_warning ("Ignoring invalid WINS server '%s'", *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (options, "new_interface_mtu");
|
||||
if (str) {
|
||||
int int_mtu;
|
||||
|
||||
errno = 0;
|
||||
int_mtu = strtol (str, NULL, 10);
|
||||
if ((errno == EINVAL) || (errno == ERANGE))
|
||||
goto error;
|
||||
|
||||
if (int_mtu)
|
||||
nm_ip4_config_set_mtu (ip4_config, int_mtu);
|
||||
}
|
||||
|
||||
return ip4_config;
|
||||
|
||||
error:
|
||||
if (addr)
|
||||
nm_ip4_address_unref (addr);
|
||||
g_object_unref (ip4_config);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_dhcp_manager_get_ip4_config
|
||||
|
|
@ -732,10 +936,6 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
|
|||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
NMDHCPDevice *device;
|
||||
NMIP4Config *ip4_config = NULL;
|
||||
struct in_addr tmp_addr;
|
||||
NMIP4Address *addr = NULL;
|
||||
char *str = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DHCP_MANAGER (manager), NULL);
|
||||
g_return_val_if_fail (iface != NULL, NULL);
|
||||
|
|
@ -753,179 +953,23 @@ nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ip4_config = nm_ip4_config_new ();
|
||||
if (!ip4_config) {
|
||||
nm_warning ("%s: couldn't allocate memory for an IP4Config!", device->iface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addr = nm_ip4_address_new ();
|
||||
if (!addr) {
|
||||
nm_warning ("%s: couldn't allocate memory for an IP4 Address!", device->iface);
|
||||
goto error;
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_ip_address");
|
||||
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
|
||||
nm_ip4_address_set_address (addr, tmp_addr.s_addr);
|
||||
nm_info (" address %s", str);
|
||||
} else
|
||||
goto error;
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_subnet_mask");
|
||||
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
|
||||
nm_ip4_address_set_prefix (addr, nm_utils_ip4_netmask_to_prefix (tmp_addr.s_addr));
|
||||
nm_info (" prefix %d (%s)", nm_ip4_address_get_prefix (addr), str);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_routers");
|
||||
if (str) {
|
||||
char **routers = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = routers; *s; s++) {
|
||||
/* FIXME: how to handle multiple routers? */
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_address_set_gateway (addr, tmp_addr.s_addr);
|
||||
nm_info (" gateway %s", *s);
|
||||
break;
|
||||
} else
|
||||
nm_warning ("Ignoring invalid gateway '%s'", *s);
|
||||
}
|
||||
g_strfreev (routers);
|
||||
}
|
||||
|
||||
nm_ip4_config_take_address (ip4_config, addr);
|
||||
addr = NULL;
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_host_name");
|
||||
if (str)
|
||||
nm_info (" hostname '%s'", str);
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_domain_name_servers");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_config_add_nameserver (ip4_config, tmp_addr.s_addr);
|
||||
nm_info (" nameserver '%s'", *s);
|
||||
} else
|
||||
nm_warning ("Ignoring invalid nameserver '%s'", *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_domain_name");
|
||||
if (str) {
|
||||
char **domains = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = domains; *s; s++) {
|
||||
nm_info (" domain name '%s'", *s);
|
||||
nm_ip4_config_add_domain (ip4_config, *s);
|
||||
}
|
||||
g_strfreev (domains);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_domain_search");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
nm_info (" domain search '%s'", *s);
|
||||
nm_ip4_config_add_search (ip4_config, *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_netbios_name_servers");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s++) {
|
||||
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
|
||||
nm_ip4_config_add_wins (ip4_config, tmp_addr.s_addr);
|
||||
nm_info (" wins '%s'", *s);
|
||||
} else
|
||||
nm_warning ("Ignoring invalid WINS server '%s'", *s);
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_static_routes");
|
||||
if (str) {
|
||||
char **searches = g_strsplit (str, " ", 0);
|
||||
|
||||
if ((g_strv_length (searches) % 2) == 0) {
|
||||
char **s;
|
||||
|
||||
for (s = searches; *s; s += 2) {
|
||||
NMIP4Route *route;
|
||||
struct in_addr rt_addr;
|
||||
struct in_addr rt_route;
|
||||
|
||||
if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
|
||||
nm_warning ("DHCP provided invalid static route address: '%s'", *s);
|
||||
continue;
|
||||
}
|
||||
if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) {
|
||||
nm_warning ("DHCP provided invalid static route gateway: '%s'", *(s + 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
// FIXME: ensure the IP addresse and route are sane
|
||||
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_dest (route, (guint32) rt_addr.s_addr);
|
||||
nm_ip4_route_set_prefix (route, 32); /* 255.255.255.255 */
|
||||
nm_ip4_route_set_next_hop (route, (guint32) rt_route.s_addr);
|
||||
|
||||
nm_ip4_config_take_route (ip4_config, route);
|
||||
nm_info (" static route %s gw %s", *s, *(s + 1));
|
||||
}
|
||||
} else {
|
||||
nm_info (" static routes provided, but invalid");
|
||||
}
|
||||
g_strfreev (searches);
|
||||
}
|
||||
|
||||
str = g_hash_table_lookup (device->options, "new_interface_mtu");
|
||||
if (str) {
|
||||
int int_mtu;
|
||||
|
||||
errno = 0;
|
||||
int_mtu = strtol (str, NULL, 10);
|
||||
if ((errno == EINVAL) || (errno == ERANGE))
|
||||
goto error;
|
||||
|
||||
if (int_mtu)
|
||||
nm_ip4_config_set_mtu (ip4_config, int_mtu);
|
||||
}
|
||||
|
||||
return ip4_config;
|
||||
|
||||
error:
|
||||
if (addr)
|
||||
g_free (addr);
|
||||
|
||||
g_object_unref (ip4_config);
|
||||
|
||||
return NULL;
|
||||
return nm_dhcp_manager_options_to_ip4_config (iface, device->options);
|
||||
}
|
||||
|
||||
#define NEW_TAG "new_"
|
||||
#define OLD_TAG "old_"
|
||||
|
||||
typedef struct {
|
||||
GHFunc func;
|
||||
gpointer user_data;
|
||||
} Dhcp4ForeachInfo;
|
||||
|
||||
static void
|
||||
copy_dhcp4_config_option (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
iterate_dhcp4_config_option (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDHCP4Config *config = NM_DHCP4_CONFIG (user_data);
|
||||
Dhcp4ForeachInfo *info = (Dhcp4ForeachInfo *) user_data;
|
||||
char *tmp_key = NULL;
|
||||
const char **p;
|
||||
static const char *filter_options[] = {
|
||||
|
|
@ -946,21 +990,23 @@ copy_dhcp4_config_option (gpointer key,
|
|||
else
|
||||
tmp_key = g_strdup ((const char *) key);
|
||||
|
||||
nm_dhcp4_config_add_option (config, tmp_key, (const char *) value);
|
||||
(*info->func) ((gpointer) tmp_key, value, info->user_data);
|
||||
g_free (tmp_key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_manager_set_dhcp4_config (NMDHCPManager *self,
|
||||
const char *iface,
|
||||
NMDHCP4Config *config)
|
||||
nm_dhcp_manager_foreach_dhcp4_option (NMDHCPManager *self,
|
||||
const char *iface,
|
||||
GHFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDHCPManagerPrivate *priv;
|
||||
NMDHCPDevice *device;
|
||||
Dhcp4ForeachInfo info = { NULL, NULL };
|
||||
|
||||
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), FALSE);
|
||||
g_return_val_if_fail (iface != NULL, FALSE);
|
||||
g_return_val_if_fail (config != NULL, FALSE);
|
||||
g_return_val_if_fail (func != NULL, FALSE);
|
||||
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
|
|
@ -975,8 +1021,9 @@ nm_dhcp_manager_set_dhcp4_config (NMDHCPManager *self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
nm_dhcp4_config_reset (config);
|
||||
g_hash_table_foreach (device->options, copy_dhcp4_config_option, config);
|
||||
info.func = func;
|
||||
info.user_data = user_data;
|
||||
g_hash_table_foreach (device->options, iterate_dhcp4_config_option, &info);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_DHCP_MANAGER_H
|
||||
#define NM_DHCP_MANAGER_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
|
@ -96,13 +96,21 @@ void nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager,
|
|||
NMIP4Config * nm_dhcp_manager_get_ip4_config (NMDHCPManager *manager, const char *iface);
|
||||
NMDHCPState nm_dhcp_manager_get_state_for_device (NMDHCPManager *manager, const char *iface);
|
||||
|
||||
gboolean nm_dhcp_manager_set_dhcp4_config (NMDHCPManager *manager,
|
||||
gboolean nm_dhcp_manager_foreach_dhcp4_option (NMDHCPManager *self,
|
||||
const char *iface,
|
||||
NMDHCP4Config *config);
|
||||
|
||||
gboolean nm_dhcp_manager_process_signal (NMDHCPManager *manager, DBusMessage *message);
|
||||
GHFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
/* The following are implemented by the DHCP client backends */
|
||||
gboolean nm_dhcp_client_start (NMDHCPDevice *device, NMSettingIP4Config *s_ip4);
|
||||
void nm_dhcp_client_stop (const char *iface, pid_t pid);
|
||||
|
||||
gboolean nm_dhcp_client_process_classless_routes (GHashTable *options,
|
||||
NMIP4Config *ip4_config,
|
||||
guint32 *gwaddr);
|
||||
|
||||
/* Test functions */
|
||||
NMIP4Config *nm_dhcp_manager_options_to_ip4_config (const char *iface,
|
||||
GHashTable *options);
|
||||
|
||||
#endif /* NM_DHCP_MANAGER_H */
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "nm-dnsmasq-manager.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
typedef struct {
|
||||
char *iface;
|
||||
|
|
@ -450,7 +451,7 @@ nm_dnsmasq_manager_stop (NMDnsMasqManager *manager)
|
|||
|
||||
if (priv->pid) {
|
||||
if (kill (priv->pid, SIGTERM) == 0)
|
||||
g_timeout_add (2000, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
g_timeout_add_seconds (2, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
else {
|
||||
kill (priv->pid, SIGKILL);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef NM_DNSMASQ_MANAGER_H
|
||||
#define NM_DNSMASQ_MANAGER_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "nm-ip4-config.h"
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ free_get_secrets_info (gpointer data)
|
|||
}
|
||||
|
||||
static void
|
||||
update_one_setting (const char* key,
|
||||
update_one_setting (const char* setting_name,
|
||||
GHashTable *setting_hash,
|
||||
NMConnection *connection,
|
||||
GSList **updated)
|
||||
|
|
@ -415,7 +415,7 @@ update_one_setting (const char* key,
|
|||
* yes, replace the setting object in the connection. If not, just try
|
||||
* updating the secrets.
|
||||
*/
|
||||
type = nm_connection_lookup_setting_type (key);
|
||||
type = nm_connection_lookup_setting_type (setting_name);
|
||||
if (type == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ update_one_setting (const char* key,
|
|||
if (setting)
|
||||
nm_connection_add_setting (connection, setting);
|
||||
else {
|
||||
if (!nm_connection_update_secrets (connection, key, setting_hash, &error)) {
|
||||
if (!nm_connection_update_secrets (connection, setting_name, setting_hash, &error)) {
|
||||
nm_warning ("Failed to update connection secrets: %d %s",
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(none)");
|
||||
|
|
@ -451,7 +451,7 @@ update_one_setting (const char* key,
|
|||
}
|
||||
}
|
||||
|
||||
*updated = g_slist_append (*updated, (gpointer) key);
|
||||
*updated = g_slist_append (*updated, (gpointer) setting_name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef NM_ACTIVATION_REQUEST_H
|
||||
#define NM_ACTIVATION_REQUEST_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-connection.h"
|
||||
#include "nm-active-connection.h"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "NetworkManager.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-marshal.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
|
@ -158,7 +159,7 @@ static void
|
|||
start_reconnection_timeout (NMDBusManager *self)
|
||||
{
|
||||
/* Schedule timeout for reconnection attempts */
|
||||
g_timeout_add (3000, nm_dbus_manager_reconnect, self);
|
||||
g_timeout_add_seconds (3, nm_dbus_manager_reconnect, self);
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <net/if.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-device-interface.h"
|
||||
#include "nm-device-private.h"
|
||||
|
|
@ -991,7 +992,7 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
|||
|
||||
/* Start the link timeout so we allow some time for reauthentication */
|
||||
if (!priv->link_timeout_id)
|
||||
priv->link_timeout_id = g_timeout_add (15000, link_timeout_cb, dev);
|
||||
priv->link_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1156,7 +1157,7 @@ supplicant_interface_init (NMDeviceEthernet *self)
|
|||
self);
|
||||
|
||||
/* Set up a timeout on the connection attempt to fail it after 25 seconds */
|
||||
priv->supplicant.con_timeout_id = g_timeout_add (25000, supplicant_connection_timeout_cb, self);
|
||||
priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-device-interface.h"
|
||||
|
|
@ -910,7 +911,7 @@ real_bring_up (NMDevice *dev)
|
|||
NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
|
||||
priv->periodic_source_id = g_timeout_add (6000, nm_device_wifi_periodic_update, self);
|
||||
priv->periodic_source_id = g_timeout_add_seconds (6, nm_device_wifi_periodic_update, self);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1717,9 +1718,9 @@ schedule_scan (NMDeviceWifi *self, gboolean backoff)
|
|||
|| (nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED))
|
||||
factor = 1;
|
||||
|
||||
priv->pending_scan_id = g_timeout_add (priv->scan_interval * 1000,
|
||||
request_wireless_scan,
|
||||
self);
|
||||
priv->pending_scan_id = g_timeout_add_seconds (priv->scan_interval,
|
||||
request_wireless_scan,
|
||||
self);
|
||||
|
||||
priv->scheduled_scan_time = now.tv_sec + priv->scan_interval;
|
||||
if (backoff && (priv->scan_interval < (SCAN_INTERVAL_MAX / factor))) {
|
||||
|
|
@ -2274,8 +2275,8 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
|||
* while to scan.
|
||||
*/
|
||||
if (!priv->link_timeout_id) {
|
||||
priv->link_timeout_id = g_timeout_add (priv->scanning ? 30000 : 15000,
|
||||
link_timeout_cb, self);
|
||||
priv->link_timeout_id = g_timeout_add_seconds (priv->scanning ? 30 : 15,
|
||||
link_timeout_cb, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2573,7 +2574,7 @@ start_supplicant_connection_timeout (NMDeviceWifi *self)
|
|||
priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
|
||||
/* Set up a timeout on the connection attempt to fail it after 25 seconds */
|
||||
id = g_timeout_add (25000, supplicant_connection_timeout_cb, self);
|
||||
id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
|
||||
if (id <= 0) {
|
||||
nm_warning ("Activation (%s/wireless): couldn't start supplicant "
|
||||
"timeout timer.",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-device-interface.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-private.h"
|
||||
|
|
@ -204,7 +205,7 @@ constructor (GType type,
|
|||
* system settings service a chance to figure out whether the device is
|
||||
* managed or not.
|
||||
*/
|
||||
priv->start_timer = g_timeout_add (4000, device_start, dev);
|
||||
priv->start_timer = g_timeout_add_seconds (4, device_start, dev);
|
||||
|
||||
priv->initialized = TRUE;
|
||||
return object;
|
||||
|
|
@ -830,7 +831,7 @@ aipd_exec (NMDevice *self, GError **error)
|
|||
priv->aipd_watch = g_child_watch_add (priv->aipd_pid, aipd_watch_cb, self);
|
||||
|
||||
/* Start a timeout to bound the address attempt */
|
||||
priv->aipd_timeout = g_timeout_add (20000, aipd_timeout_cb, self);
|
||||
priv->aipd_timeout = g_timeout_add_seconds (20, aipd_timeout_cb, self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1019,6 +1020,14 @@ nm_device_new_ip4_shared_config (NMDevice *self, NMDeviceStateReason *reason)
|
|||
return config;
|
||||
}
|
||||
|
||||
static void
|
||||
dhcp4_add_option_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
nm_dhcp4_config_add_option (NM_DHCP4_CONFIG (user_data),
|
||||
(const char *) key,
|
||||
(const char *) value);
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage4_get_ip4_config (NMDevice *self,
|
||||
NMIP4Config **config,
|
||||
|
|
@ -1047,7 +1056,12 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||
if (*config) {
|
||||
nm_utils_merge_ip4_config (*config, s_ip4);
|
||||
|
||||
nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, ip_iface, priv->dhcp4_config);
|
||||
nm_dhcp4_config_reset (priv->dhcp4_config);
|
||||
nm_dhcp_manager_foreach_dhcp4_option (priv->dhcp_manager,
|
||||
ip_iface,
|
||||
dhcp4_add_option_cb,
|
||||
priv->dhcp4_config);
|
||||
|
||||
/* Notify of new DHCP4 config */
|
||||
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
|
||||
} else
|
||||
|
|
@ -1756,9 +1770,13 @@ handle_dhcp_lease_change (NMDevice *device)
|
|||
|
||||
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
|
||||
|
||||
if (nm_device_set_ip4_config (device, config, &reason))
|
||||
nm_dhcp_manager_set_dhcp4_config (priv->dhcp_manager, ip_iface, priv->dhcp4_config);
|
||||
else {
|
||||
if (nm_device_set_ip4_config (device, config, &reason)) {
|
||||
nm_dhcp4_config_reset (priv->dhcp4_config);
|
||||
nm_dhcp_manager_foreach_dhcp4_option (priv->dhcp_manager,
|
||||
ip_iface,
|
||||
dhcp4_add_option_cb,
|
||||
priv->dhcp4_config);
|
||||
} else {
|
||||
nm_warning ("Failed to update IP4 config in response to DHCP event.");
|
||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef NM_DHCP4_CONFIG_H
|
||||
#define NM_DHCP4_CONFIG_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-gsm-device.h"
|
||||
#include "nm-device-interface.h"
|
||||
#include "nm-device-private.h"
|
||||
|
|
@ -66,10 +67,21 @@ enum {
|
|||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* Various possible init sequences */
|
||||
const gchar *modem_init_sequences[] = {
|
||||
"ATZ E0 V1 X4 &C1 +FCLASS=0",
|
||||
"ATZ E0 V1 &C1",
|
||||
"AT&F E0 V1 X4 &C1 +FCLASS=0",
|
||||
"AT&F E0 V1 &C1",
|
||||
"AT&F E0 V1",
|
||||
"\rAT&F E0 V1 X4 &C1 +CREG=0 +FCLASS=0", /* USBModem by MobileStream for Palm */
|
||||
NULL
|
||||
};
|
||||
|
||||
static void enter_pin (NMGsmDevice *device, NMGsmSecret secret_type, gboolean retry);
|
||||
static void manual_registration (NMGsmDevice *device);
|
||||
static void automatic_registration (NMGsmDevice *device);
|
||||
static void init_modem (NMSerialDevice *device, gpointer user_data);
|
||||
static void init_modem (NMSerialDevice *device);
|
||||
|
||||
NMGsmDevice *
|
||||
nm_gsm_device_new (const char *udi,
|
||||
|
|
@ -354,7 +366,7 @@ schedule_automatic_registration_again (NMGsmDevice *self)
|
|||
if (priv->pending_id)
|
||||
g_source_remove (priv->pending_id);
|
||||
|
||||
priv->pending_id = g_timeout_add (1000, automatic_registration_again, self);
|
||||
priv->pending_id = g_timeout_add_seconds (1, automatic_registration_again, self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -496,13 +508,14 @@ init_full_done (NMSerialDevice *device,
|
|||
static void
|
||||
init_modem_full (NMGsmDevice *device)
|
||||
{
|
||||
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
|
||||
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
||||
|
||||
/* Send E0 too because some devices turn echo back on after CPIN which
|
||||
* just breaks stuff since echo-ed commands are interpreted as replies.
|
||||
* rh #456770
|
||||
*/
|
||||
modem_wait_for_reply (device, "ATZ E0 V1 X4 &C1 +FCLASS=0", 10, responses, responses, init_full_done, NULL);
|
||||
modem_wait_for_reply (device, modem_init_sequences[priv->init_tries], 10, responses, responses, init_full_done, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -647,7 +660,6 @@ init_done (NMSerialDevice *device,
|
|||
|
||||
switch (reply_index) {
|
||||
case 0:
|
||||
priv->init_tries = 0;
|
||||
check_pin (NM_GSM_DEVICE (device));
|
||||
break;
|
||||
case -1:
|
||||
|
|
@ -657,35 +669,27 @@ init_done (NMSerialDevice *device,
|
|||
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
|
||||
break;
|
||||
default:
|
||||
switch (priv->init_tries) {
|
||||
case 0:
|
||||
nm_warning ("Trying alternate modem initialization");
|
||||
init_modem (device, "ATZ E0 V1 &C1");
|
||||
break;
|
||||
case 1:
|
||||
nm_warning ("Trying second alternate modem initialization");
|
||||
init_modem (device, "AT&F E0 V1");
|
||||
break;
|
||||
default:
|
||||
priv->init_tries++;
|
||||
if (modem_init_sequences[priv->init_tries] != NULL) {
|
||||
nm_warning ("Trying alternate modem initialization (%d)",
|
||||
priv->init_tries);
|
||||
init_modem (device);
|
||||
} else {
|
||||
nm_warning ("Modem initialization failed");
|
||||
nm_device_state_changed (NM_DEVICE (device),
|
||||
NM_DEVICE_STATE_FAILED,
|
||||
NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED);
|
||||
break;
|
||||
}
|
||||
priv->init_tries++;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_modem (NMSerialDevice *device, gpointer user_data)
|
||||
init_modem (NMSerialDevice *device)
|
||||
{
|
||||
NMGsmDevicePrivate *priv = NM_GSM_DEVICE_GET_PRIVATE (device);
|
||||
const char *responses[] = { "OK", "ERROR", "ERR", NULL };
|
||||
const char *init_string = user_data;
|
||||
|
||||
if (!init_string)
|
||||
init_string = "ATZ E0 V1 X4 &C1 +FCLASS=0";
|
||||
const char *init_string = modem_init_sequences[priv->init_tries];
|
||||
|
||||
modem_wait_for_reply (NM_GSM_DEVICE (device), init_string, 10, responses, responses, init_done, NULL);
|
||||
}
|
||||
|
|
@ -706,7 +710,7 @@ real_act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||
|
||||
NM_GSM_DEVICE_GET_PRIVATE (device)->init_tries = 0;
|
||||
|
||||
id = nm_serial_device_flash (serial_device, 100, init_modem, NULL);
|
||||
id = nm_serial_device_flash (serial_device, 100, (NMSerialFlashFn) init_modem, NULL);
|
||||
if (!id)
|
||||
*reason = NM_DEVICE_STATE_REASON_UNKNOWN;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-hal-manager.h"
|
||||
#include "nm-marshal.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
|
@ -500,7 +501,7 @@ killswitch_getpower_done (gpointer user_data)
|
|||
killswitch_poll_cleanup (self);
|
||||
|
||||
/* Schedule next poll */
|
||||
priv->killswitch_poll_id = g_timeout_add (RFKILL_POLL_FREQUENCY * 1000,
|
||||
priv->killswitch_poll_id = g_timeout_add_seconds (RFKILL_POLL_FREQUENCY,
|
||||
poll_killswitches,
|
||||
self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_HAL_MANAGER_H
|
||||
#define NM_HAL_MANAGER_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
|
|
|||
|
|
@ -74,6 +74,20 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static struct nl_addr *
|
||||
nm_utils_ip4_addr_to_nl_addr (guint32 ip4_addr)
|
||||
{
|
||||
struct nl_addr * nla = NULL;
|
||||
|
||||
if (!(nla = nl_addr_alloc (sizeof (in_addr_t))))
|
||||
return NULL;
|
||||
nl_addr_set_family (nla, AF_INET);
|
||||
nl_addr_set_binary_addr (nla, &ip4_addr, sizeof (guint32));
|
||||
|
||||
return nla;
|
||||
}
|
||||
|
||||
|
||||
NMIP4Config *
|
||||
nm_ip4_config_new (void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef NM_IP4_CONFIG_H
|
||||
#define NM_IP4_CONFIG_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "nm-setting-ip4-config.h"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-manager.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
|
@ -95,7 +96,7 @@ static void system_settings_properties_changed_cb (DBusGProxy *proxy,
|
|||
GHashTable *properties,
|
||||
gpointer user_data);
|
||||
|
||||
#define SSD_POKE_INTERVAL 120000
|
||||
#define SSD_POKE_INTERVAL 120
|
||||
|
||||
typedef struct {
|
||||
DBusGMethodInvocation *context;
|
||||
|
|
@ -1389,7 +1390,7 @@ poke_system_settings_daemon_cb (gpointer user_data)
|
|||
|
||||
out:
|
||||
/* Reschedule the poke */
|
||||
priv->poke_id = g_timeout_add (SSD_POKE_INTERVAL, poke_system_settings_daemon_cb, (gpointer) manager);
|
||||
priv->poke_id = g_timeout_add_seconds (SSD_POKE_INTERVAL, poke_system_settings_daemon_cb, (gpointer) manager);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -2134,7 +2135,7 @@ impl_manager_activate_connection (NMManager *manager,
|
|||
info->scope = scope;
|
||||
info->connection_path = g_strdup (connection_path);
|
||||
info->specific_object_path = g_strdup (real_sop);
|
||||
info->timeout_id = g_timeout_add (5000, wait_for_connection_expired, manager);
|
||||
info->timeout_id = g_timeout_add_seconds (5, wait_for_connection_expired, manager);
|
||||
|
||||
// FIXME: should probably be per-device, not global to the manager
|
||||
NM_MANAGER_GET_PRIVATE (manager)->pending_connection_info = info;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_MANAGER_H
|
||||
#define NM_MANAGER_H 1
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include "nm-device.h"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-serial-device.h"
|
||||
#include "nm-device-interface.h"
|
||||
#include "nm-device-private.h"
|
||||
|
|
@ -285,11 +286,11 @@ nm_serial_device_add_timeout (NMSerialDevice *self, guint timeout)
|
|||
g_source_remove (priv->timeout_id);
|
||||
}
|
||||
|
||||
priv->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
|
||||
timeout * 1000,
|
||||
nm_serial_device_timed_out,
|
||||
self,
|
||||
nm_serial_device_timeout_removed);
|
||||
priv->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
|
||||
timeout,
|
||||
nm_serial_device_timed_out,
|
||||
self,
|
||||
nm_serial_device_timeout_removed);
|
||||
if (G_UNLIKELY (priv->timeout_id == 0))
|
||||
nm_warning ("Registering serial device time out failed.");
|
||||
}
|
||||
|
|
@ -415,6 +416,7 @@ nm_serial_device_open (NMSerialDevice *device,
|
|||
}
|
||||
|
||||
priv->channel = g_io_channel_unix_new (priv->fd);
|
||||
g_io_channel_set_encoding (priv->channel, NULL, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <linux/if_ppp.h>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-ppp-manager.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
|
|
@ -65,7 +66,7 @@ static gboolean impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
#include "nm-ppp-manager-glue.h"
|
||||
|
||||
#define NM_PPPD_PLUGIN PLUGINDIR "/nm-pppd-plugin.so"
|
||||
#define NM_PPP_WAIT_PPPD 15000 /* 10 seconds */
|
||||
#define NM_PPP_WAIT_PPPD 15 /* 15 seconds */
|
||||
#define PPP_MANAGER_SECRET_TRIES "ppp-manager-secret-tries"
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -135,12 +136,11 @@ constructor (GType type,
|
|||
GObject *object;
|
||||
NMPPPManagerPrivate *priv;
|
||||
DBusGConnection *connection;
|
||||
static gboolean name_requested = FALSE;
|
||||
static guint32 counter = 0;
|
||||
|
||||
object = G_OBJECT_CLASS (nm_ppp_manager_parent_class)->constructor (type,
|
||||
n_construct_params,
|
||||
construct_params);
|
||||
n_construct_params,
|
||||
construct_params);
|
||||
if (!object)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -150,36 +150,8 @@ constructor (GType type,
|
|||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
connection = nm_dbus_manager_get_connection (priv->dbus_manager);
|
||||
|
||||
/* Only need to request bus name the first time */
|
||||
if (!name_requested) {
|
||||
DBusGProxy *proxy;
|
||||
gboolean success;
|
||||
guint request_name_result;
|
||||
GError *err = NULL;
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (connection,
|
||||
"org.freedesktop.DBus",
|
||||
"/org/freedesktop/DBus",
|
||||
"org.freedesktop.DBus");
|
||||
success = dbus_g_proxy_call (proxy, "RequestName", &err,
|
||||
G_TYPE_STRING, NM_DBUS_SERVICE_PPP,
|
||||
G_TYPE_UINT, 0,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &request_name_result,
|
||||
G_TYPE_INVALID);
|
||||
g_object_unref (proxy);
|
||||
|
||||
if (!success) {
|
||||
nm_warning ("Failed to acquire PPP manager service: %s", err->message);
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name_requested = TRUE;
|
||||
}
|
||||
|
||||
priv->dbus_path = g_strdup_printf (NM_DBUS_PATH "/PPP/%d", counter++);
|
||||
dbus_g_connection_register_g_object (connection, priv->dbus_path, object);
|
||||
|
||||
|
|
@ -342,7 +314,7 @@ monitor_stats (NMPPPManager *manager)
|
|||
|
||||
priv->monitor_fd = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
if (priv->monitor_fd > 0)
|
||||
priv->monitor_id = g_timeout_add (5000, monitor_cb, manager);
|
||||
priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager);
|
||||
else
|
||||
nm_warning ("Could not open pppd monitor: %s", strerror (errno));
|
||||
}
|
||||
|
|
@ -465,6 +437,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMConnection *connection;
|
||||
NMSettingPPP *s_ppp;
|
||||
NMIP4Config *config;
|
||||
NMIP4Address *addr;
|
||||
GValue *val;
|
||||
|
|
@ -528,6 +501,15 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
g_assert (connection);
|
||||
g_object_set_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES, NULL);
|
||||
|
||||
/* Merge in custom MTU */
|
||||
s_ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
|
||||
if (s_ppp) {
|
||||
guint32 mtu = nm_setting_ppp_get_mtu (s_ppp);
|
||||
|
||||
if (mtu)
|
||||
nm_ip4_config_set_mtu (config, mtu);
|
||||
}
|
||||
|
||||
/* Push the IP4 config up to the device */
|
||||
g_signal_emit (manager, signals[IP4_CONFIG], 0, priv->ip_iface, config);
|
||||
|
||||
|
|
@ -793,8 +775,12 @@ create_pppd_cmd_line (NMPPPManager *self,
|
|||
if (nm_setting_ppp_get_baud (setting))
|
||||
nm_cmd_line_add_int (cmd, nm_setting_ppp_get_baud (setting));
|
||||
|
||||
if (nm_setting_ppp_get_noauth (setting))
|
||||
nm_cmd_line_add_string (cmd, "noauth");
|
||||
/* 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))
|
||||
|
|
@ -944,7 +930,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
|
|||
nm_debug ("ppp 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 (NM_PPP_WAIT_PPPD, pppd_timed_out, manager);
|
||||
priv->ppp_timeout_handler = g_timeout_add_seconds (NM_PPP_WAIT_PPPD, pppd_timed_out, manager);
|
||||
priv->act_req = g_object_ref (req);
|
||||
|
||||
out:
|
||||
|
|
@ -1043,7 +1029,7 @@ nm_ppp_manager_stop (NMPPPManager *manager)
|
|||
|
||||
if (priv->pid) {
|
||||
if (kill (priv->pid, SIGTERM) == 0)
|
||||
g_timeout_add (2000, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
g_timeout_add_seconds (2, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
else {
|
||||
kill (priv->pid, SIGKILL);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_PPP_MANAGER_H
|
||||
#define NM_PPP_MANAGER_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "nm-ppp-status.h"
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-pppd-plugin.h"
|
||||
#include "nm-ppp-status.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
@ -319,10 +320,7 @@ plugin_init (void)
|
|||
/* NM passes in the object path of the corresponding PPPManager
|
||||
* object as the 'ipparam' argument to pppd.
|
||||
*/
|
||||
proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE_PPP,
|
||||
ipparam,
|
||||
NM_DBUS_INTERFACE_PPP);
|
||||
proxy = dbus_g_proxy_new_for_name (bus, NM_DBUS_SERVICE, ipparam, NM_DBUS_INTERFACE_PPP);
|
||||
|
||||
dbus_g_connection_unref (bus);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* Copyright (C) 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#define NM_DBUS_SERVICE_PPP "org.freedesktop.NetworkManager.PPP"
|
||||
#define NM_DBUS_INTERFACE_PPP "org.freedesktop.NetworkManager.PPP"
|
||||
|
||||
#define NM_PPP_IP4_CONFIG_INTERFACE "interface"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-call-store.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface"
|
||||
#define WPAS_DBUS_IFACE_BSSID WPAS_DBUS_INTERFACE ".BSSID"
|
||||
|
|
@ -579,7 +580,7 @@ wpas_iface_query_scan_results (DBusGProxy *proxy, gpointer user_data)
|
|||
return;
|
||||
|
||||
/* Only fetch scan results every 4s max, but initially do it right away */
|
||||
priv->scan_results_timeout = g_timeout_add (priv->last_scan ? 4000 : 0,
|
||||
priv->scan_results_timeout = g_timeout_add_seconds (priv->last_scan ? 4 : 0,
|
||||
request_scan_results,
|
||||
user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-marshal.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#define SUPPLICANT_POKE_INTERVAL 120000
|
||||
#define SUPPLICANT_POKE_INTERVAL 120
|
||||
|
||||
typedef struct {
|
||||
NMDBusManager * dbus_mgr;
|
||||
|
|
@ -106,7 +107,7 @@ poke_supplicant_cb (gpointer user_data)
|
|||
|
||||
out:
|
||||
/* Reschedule the poke */
|
||||
priv->poke_id = g_timeout_add (SUPPLICANT_POKE_INTERVAL,
|
||||
priv->poke_id = g_timeout_add_seconds (SUPPLICANT_POKE_INTERVAL,
|
||||
poke_supplicant_cb,
|
||||
(gpointer) self);
|
||||
|
||||
|
|
|
|||
31
src/tests/Makefile.am
Normal file
31
src/tests/Makefile.am
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
INCLUDES = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_srcdir)/src/dhcp-manager \
|
||||
-I$(top_builddir)/marshallers \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src
|
||||
|
||||
noinst_PROGRAMS = test-dhcp-options
|
||||
|
||||
test_dhcp_options_SOURCES = \
|
||||
test-dhcp-options.c
|
||||
|
||||
test_dhcp_options_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
test_dhcp_options_LDADD = \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/src/dhcp-manager/libdhcp-manager.la \
|
||||
$(top_builddir)/src/libtest-dhcp.la
|
||||
|
||||
if WITH_TESTS
|
||||
|
||||
check-local: test-dhcp-options
|
||||
$(abs_builddir)/test-dhcp-options
|
||||
|
||||
endif
|
||||
|
||||
549
src/tests/test-dhcp-options.c
Normal file
549
src/tests/test-dhcp-options.c
Normal file
|
|
@ -0,0 +1,549 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* nm-dhcp-manager.c - Handle the DHCP daemon for NetworkManager
|
||||
*
|
||||
* 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, 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) 2008 Red Hat, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-dhcp-manager.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *value;
|
||||
} Option;
|
||||
|
||||
static GHashTable *
|
||||
fill_table (Option *test_options, GHashTable *table)
|
||||
{
|
||||
Option *opt;
|
||||
|
||||
if (!table)
|
||||
table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
for (opt = test_options; opt->name; opt++)
|
||||
g_hash_table_insert (table, (gpointer) opt->name, (gpointer) opt->value);
|
||||
return table;
|
||||
}
|
||||
|
||||
static Option generic_options[] = {
|
||||
{ "new_subnet_mask", "255.255.255.0" },
|
||||
{ "new_ip_address", "192.168.1.106" },
|
||||
{ "new_network_number", "192.168.1.0" },
|
||||
{ "interface", "eth0" },
|
||||
{ "reason", "BOUND" },
|
||||
{ "new_expiry", "1232324877" },
|
||||
{ "new_dhcp_lease_time", "3600" },
|
||||
{ "new_dhcp_server_identifier", "192.168.1.1" },
|
||||
{ "new_routers", "192.168.1.1" },
|
||||
{ "new_domain_name_servers", "216.254.95.2 216.231.41.2" },
|
||||
{ "new_dhcp_message_type", "5" },
|
||||
{ "new_broadcast_address", "192.168.1.255" },
|
||||
{ "new_domain_search", "foobar.com blah.foobar.com" },
|
||||
{ "new_host_name", "nmreallywhipsthe" },
|
||||
{ "new_domain_name", "lamasass.com" },
|
||||
{ "new_interface_mtu", "987" },
|
||||
{ "new_static_routes", "10.1.1.5 10.1.1.1 100.99.88.56 10.1.1.1" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_generic_options (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Address *addr;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_addr = "192.168.1.106";
|
||||
const char *expected_gw = "192.168.1.1";
|
||||
const char *expected_dns1 = "216.254.95.2";
|
||||
const char *expected_dns2 = "216.231.41.2";
|
||||
const char *expected_search1 = "foobar.com";
|
||||
const char *expected_search2 = "blah.foobar.com";
|
||||
const char *expected_route1_dest = "10.1.1.5";
|
||||
const char *expected_route1_gw = "10.1.1.1";
|
||||
const char *expected_route2_dest = "100.99.88.56";
|
||||
const char *expected_route2_gw = "10.1.1.1";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-generic", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 address */
|
||||
ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
|
||||
"dhcp-generic", "unexpected number of IP addresses");
|
||||
addr = nm_ip4_config_get_address (ip4_config, 0);
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_addr, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected IP address");
|
||||
ASSERT (nm_ip4_address_get_address (addr) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected IP address");
|
||||
|
||||
ASSERT (nm_ip4_address_get_prefix (addr) == 24,
|
||||
"dhcp-generic", "unexpected IP address prefix length");
|
||||
|
||||
/* Gateway */
|
||||
ASSERT (inet_pton (AF_INET, expected_gw, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected IP gateway");
|
||||
ASSERT (nm_ip4_address_get_gateway (addr) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected IP gateway");
|
||||
|
||||
ASSERT (nm_ip4_config_get_ptp_address (ip4_config) == 0,
|
||||
"dhcp-generic", "unexpected PTP address");
|
||||
|
||||
ASSERT (nm_ip4_config_get_num_wins (ip4_config) == 0,
|
||||
"dhcp-generic", "unexpected number of WINS servers");
|
||||
|
||||
ASSERT (nm_ip4_config_get_mtu (ip4_config) == 987,
|
||||
"dhcp-generic", "unexpected MTU");
|
||||
|
||||
/* Domain searches */
|
||||
ASSERT (nm_ip4_config_get_num_searches (ip4_config) == 2,
|
||||
"dhcp-generic", "unexpected number of domain searches");
|
||||
ASSERT (strcmp (nm_ip4_config_get_search (ip4_config, 0), expected_search1) == 0,
|
||||
"dhcp-generic", "unexpected domain search #1");
|
||||
ASSERT (strcmp (nm_ip4_config_get_search (ip4_config, 1), expected_search2) == 0,
|
||||
"dhcp-generic", "unexpected domain search #2");
|
||||
|
||||
/* DNS servers */
|
||||
ASSERT (nm_ip4_config_get_num_nameservers (ip4_config) == 2,
|
||||
"dhcp-generic", "unexpected number of domain name servers");
|
||||
ASSERT (inet_pton (AF_INET, expected_dns1, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected DNS server address #1");
|
||||
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 0) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected domain name server #1");
|
||||
ASSERT (inet_pton (AF_INET, expected_dns2, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected DNS server address #2");
|
||||
ASSERT (nm_ip4_config_get_nameserver (ip4_config, 1) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected domain name server #2");
|
||||
|
||||
/* Routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
|
||||
"dhcp-generic", "unexpected number of routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 32,
|
||||
"dhcp-generic", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-generic", "unexpected route #1 metric");
|
||||
|
||||
/* Route #2 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 1);
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected route destination #2");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected route #2 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
|
||||
"dhcp-generic", "couldn't convert expected route next hop #2");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-generic", "unexpected route #2 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 32,
|
||||
"dhcp-generic", "unexpected route #2 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-generic", "unexpected route #2 metric");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option wins_options[] = {
|
||||
{ "new_netbios_name_servers", "63.12.199.5 150.4.88.120" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_wins_options (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Address *addr;
|
||||
struct in_addr tmp;
|
||||
const char *expected_wins1 = "63.12.199.5";
|
||||
const char *expected_wins2 = "150.4.88.120";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (wins_options, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-wins", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 address */
|
||||
ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
|
||||
"dhcp-wins", "unexpected number of IP addresses");
|
||||
addr = nm_ip4_config_get_address (ip4_config, 0);
|
||||
|
||||
ASSERT (nm_ip4_config_get_num_wins (ip4_config) == 2,
|
||||
"dhcp-wins", "unexpected number of WINS servers");
|
||||
ASSERT (inet_pton (AF_INET, expected_wins1, &tmp) > 0,
|
||||
"dhcp-wins", "couldn't convert expected WINS server address #1");
|
||||
ASSERT (nm_ip4_config_get_wins (ip4_config, 0) == tmp.s_addr,
|
||||
"dhcp-wins", "unexpected WINS server #1");
|
||||
ASSERT (inet_pton (AF_INET, expected_wins2, &tmp) > 0,
|
||||
"dhcp-wins", "couldn't convert expected WINS server address #1");
|
||||
ASSERT (nm_ip4_config_get_wins (ip4_config, 1) == tmp.s_addr,
|
||||
"dhcp-wins", "unexpected WINS server #1");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option classless_routes_options[] = {
|
||||
/* For dhclient */
|
||||
{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 8 10 10 17 66 41" },
|
||||
/* For dhcpcd */
|
||||
{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_classless_static_routes (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
const char *expected_route1_gw = "192.168.1.1";
|
||||
const char *expected_route2_dest = "10.0.0.0";
|
||||
const char *expected_route2_gw = "10.17.66.41";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (classless_routes_options, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-rfc3442", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
|
||||
"dhcp-rfc3442", "unexpected number of IP routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 24,
|
||||
"dhcp-rfc3442", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442", "unexpected route #1 metric");
|
||||
|
||||
/* Route #2 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 1);
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442", "couldn't convert expected route destination #2");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442", "unexpected route #2 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442", "couldn't convert expected route next hop #2");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442", "unexpected route #2 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 8,
|
||||
"dhcp-rfc3442", "unexpected route #2 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442", "unexpected route #2 metric");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option invalid_classless_routes1[] = {
|
||||
/* For dhclient */
|
||||
{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 45 10 17 66 41" },
|
||||
/* For dhcpcd */
|
||||
{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.adfadf/44 10.17.66.41" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_invalid_classless_routes1 (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
const char *expected_route1_gw = "192.168.1.1";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (invalid_classless_routes1, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-rfc3442-invalid-1", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
"dhcp-rfc3442-invalid-1", "unexpected number of IP routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-1", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-1", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-1", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-1", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 24,
|
||||
"dhcp-rfc3442-invalid-1", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442-invalid-1", "unexpected route #1 metric");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option invalid_classless_routes2[] = {
|
||||
/* For dhclient */
|
||||
{ "new_rfc3442_classless_static_routes", "45 10 17 66 41 24 192 168 10 192 168 1 1" },
|
||||
/* For dhcpcd */
|
||||
{ "new_classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_invalid_classless_routes2 (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_route1_dest = "10.1.1.5";
|
||||
const char *expected_route1_gw = "10.1.1.1";
|
||||
const char *expected_route2_dest = "100.99.88.56";
|
||||
const char *expected_route2_gw = "10.1.1.1";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (invalid_classless_routes2, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-rfc3442-invalid-2", "failed to parse DHCP4 options");
|
||||
|
||||
/* Test falling back to old-style static routes if the classless static
|
||||
* routes are invalid.
|
||||
*/
|
||||
|
||||
/* Routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected number of routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-2", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-2", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 32,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #1 metric");
|
||||
|
||||
/* Route #2 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 1);
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-2", "couldn't convert expected route destination #2");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #2 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-2", "couldn't convert expected route next hop #2");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #2 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 32,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #2 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442-invalid-2", "unexpected route #2 metric");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option invalid_classless_routes3[] = {
|
||||
/* For dhclient */
|
||||
{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" },
|
||||
/* For dhcpcd */
|
||||
{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 128/32 10.17.66.41" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_invalid_classless_routes3 (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
const char *expected_route1_gw = "192.168.1.1";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (invalid_classless_routes3, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-rfc3442-invalid-3", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
"dhcp-rfc3442-invalid-3", "unexpected number of IP routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-3", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-3", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442-invalid-3", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-invalid-3", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 24,
|
||||
"dhcp-rfc3442-invalid-3", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442-invalid-3", "unexpected route #1 metric");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
static Option gw_in_classless_routes[] = {
|
||||
/* For dhclient */
|
||||
{ "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 0 192 2 3 4" },
|
||||
/* For dhcpcd */
|
||||
{ "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
test_gateway_in_classless_routes (void)
|
||||
{
|
||||
GHashTable *options;
|
||||
NMIP4Config *ip4_config;
|
||||
NMIP4Address *addr;
|
||||
NMIP4Route *route;
|
||||
struct in_addr tmp;
|
||||
const char *expected_route1_dest = "192.168.10.0";
|
||||
const char *expected_route1_gw = "192.168.1.1";
|
||||
const char *expected_gateway = "192.2.3.4";
|
||||
|
||||
options = fill_table (generic_options, NULL);
|
||||
options = fill_table (gw_in_classless_routes, options);
|
||||
|
||||
ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options);
|
||||
ASSERT (ip4_config != NULL,
|
||||
"dhcp-rfc3442-gateway", "failed to parse DHCP4 options");
|
||||
|
||||
/* IP4 routes */
|
||||
ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1,
|
||||
"dhcp-rfc3442-gateway", "unexpected number of IP routes");
|
||||
|
||||
/* Route #1 */
|
||||
route = nm_ip4_config_get_route (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0,
|
||||
"dhcp-rfc3442-gateway", "couldn't convert expected route destination #1");
|
||||
ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-gateway", "unexpected route #1 destination");
|
||||
|
||||
ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0,
|
||||
"dhcp-rfc3442-gateway", "couldn't convert expected route next hop #1");
|
||||
ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr,
|
||||
"dhcp-rfc3442-gateway", "unexpected route #1 next hop");
|
||||
|
||||
ASSERT (nm_ip4_route_get_prefix (route) == 24,
|
||||
"dhcp-rfc3442-gateway", "unexpected route #1 prefix");
|
||||
ASSERT (nm_ip4_route_get_metric (route) == 0,
|
||||
"dhcp-rfc3442-gateway", "unexpected route #1 metric");
|
||||
|
||||
/* Address */
|
||||
ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1,
|
||||
"dhcp-rfc3442-gateway", "unexpected number of IP addresses");
|
||||
addr = nm_ip4_config_get_address (ip4_config, 0);
|
||||
ASSERT (inet_pton (AF_INET, expected_gateway, &tmp) > 0,
|
||||
"dhcp-rfc3442-gateway", "couldn't convert expected IP gateway");
|
||||
ASSERT (nm_ip4_address_get_gateway (addr) == tmp.s_addr,
|
||||
"dhcp-rfc3442-gateway", "unexpected IP gateway");
|
||||
|
||||
g_hash_table_destroy (options);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
DBusGConnection *bus;
|
||||
char *basename;
|
||||
|
||||
g_type_init ();
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
|
||||
/* The tests */
|
||||
test_generic_options ();
|
||||
test_wins_options ();
|
||||
test_classless_static_routes ();
|
||||
test_invalid_classless_routes1 ();
|
||||
test_invalid_classless_routes2 ();
|
||||
test_invalid_classless_routes3 ();
|
||||
test_gateway_in_classless_routes ();
|
||||
|
||||
basename = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", basename);
|
||||
g_free (basename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-named-manager.h"
|
||||
#include "nm-netlink.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "nm-vpn-connection-glue.h"
|
||||
|
||||
|
|
@ -570,7 +571,7 @@ nm_vpn_connection_connect_cb (DBusGProxy *proxy, GError *err, gpointer user_data
|
|||
NM_VPN_CONNECTION_STATE_REASON_NONE);
|
||||
|
||||
/* 40 second timeout waiting for IP config signal from VPN service */
|
||||
priv->ipconfig_timeout = g_timeout_add (40000, nm_vpn_connection_ip_config_timeout, connection);
|
||||
priv->ipconfig_timeout = g_timeout_add_seconds (40, nm_vpn_connection_ip_config_timeout, connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_VPN_CONNECTION_H
|
||||
#define NM_VPN_CONNECTION_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "NetworkManagerVPN.h"
|
||||
#include "nm-device.h"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_VPN_MANAGER_H
|
||||
#define NM_VPN_MANAGER_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-vpn-connection.h"
|
||||
#include "nm-activation-request.h"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
G_DEFINE_TYPE (NMVPNService, nm_vpn_service, G_TYPE_OBJECT)
|
||||
|
||||
|
|
@ -66,6 +67,10 @@ find_service_file (const char *name)
|
|||
char *path;
|
||||
gboolean found = FALSE;
|
||||
|
||||
/* only parse filenames that end with .name */
|
||||
if (!g_str_has_suffix (fn, ".name"))
|
||||
continue;
|
||||
|
||||
key_file = g_key_file_new ();
|
||||
path = g_build_filename (VPN_NAME_FILES_DIR, fn, NULL);
|
||||
|
||||
|
|
@ -249,7 +254,7 @@ nm_vpn_service_daemon_exec (NMVPNService *service, GError **error)
|
|||
nm_vpn_service_get_name (service), priv->dbus_service, priv->pid);
|
||||
|
||||
priv->service_child_watch = g_child_watch_add (priv->pid, vpn_service_watch_cb, service);
|
||||
priv->service_start_timeout = g_timeout_add (5000, nm_vpn_service_timeout, service);
|
||||
priv->service_start_timeout = g_timeout_add_seconds (5, nm_vpn_service_timeout, service);
|
||||
} else {
|
||||
nm_warning ("VPN service '%s': could not launch the VPN service. error: (%d) %s.",
|
||||
nm_vpn_service_get_name (service), spawn_error->code, spawn_error->message);
|
||||
|
|
@ -291,7 +296,7 @@ connection_vpn_state_changed (NMVPNConnection *connection,
|
|||
|
||||
if (priv->connections == NULL) {
|
||||
/* schedule a timeout (10 seconds) to destroy the service */
|
||||
g_timeout_add (10000, destroy_service, user_data);
|
||||
g_timeout_add_seconds (10, destroy_service, user_data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -436,7 +441,7 @@ finalize (GObject *object)
|
|||
|
||||
if (priv->pid) {
|
||||
if (kill (priv->pid, SIGTERM) == 0)
|
||||
g_timeout_add (2000, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
g_timeout_add_seconds (2, ensure_killed, GINT_TO_POINTER (priv->pid));
|
||||
else {
|
||||
kill (priv->pid, SIGKILL);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef NM_VPN_SERVICE_H
|
||||
#define NM_VPN_SERVICE_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-device.h"
|
||||
#include "nm-vpn-connection.h"
|
||||
|
|
|
|||
|
|
@ -242,7 +242,8 @@ NMIfcfgConnection *
|
|||
nm_ifcfg_connection_new (const char *filename,
|
||||
DBusGConnection *g_connection,
|
||||
NMSystemConfigHalManager *hal_mgr,
|
||||
GError **error)
|
||||
GError **error,
|
||||
gboolean *ignore_error)
|
||||
{
|
||||
GObject *object;
|
||||
NMIfcfgConnectionPrivate *priv;
|
||||
|
|
@ -254,7 +255,7 @@ nm_ifcfg_connection_new (const char *filename,
|
|||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
wrapped = connection_from_file (filename, &unmanaged, &keyfile, error);
|
||||
wrapped = connection_from_file (filename, &unmanaged, &keyfile, error, ignore_error);
|
||||
if (!wrapped)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ GType nm_ifcfg_connection_get_type (void);
|
|||
NMIfcfgConnection *nm_ifcfg_connection_new (const char *filename,
|
||||
DBusGConnection *g_connection,
|
||||
NMSystemConfigHalManager *hal_mgr,
|
||||
GError **error);
|
||||
GError **error,
|
||||
gboolean *ignore_error);
|
||||
|
||||
const char *nm_ifcfg_connection_get_filename (NMIfcfgConnection *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -160,10 +160,11 @@ read_one_connection (SCPluginIfcfg *plugin, const char *filename)
|
|||
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
||||
NMIfcfgConnection *connection;
|
||||
GError *error = NULL;
|
||||
gboolean ignore_error = FALSE;
|
||||
|
||||
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "parsing %s ... ", filename);
|
||||
|
||||
connection = nm_ifcfg_connection_new (filename, priv->g_connection, priv->hal_mgr, &error);
|
||||
connection = nm_ifcfg_connection_new (filename, priv->g_connection, priv->hal_mgr, &error, &ignore_error);
|
||||
if (connection) {
|
||||
NMConnection *wrapped;
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -198,8 +199,10 @@ read_one_connection (SCPluginIfcfg *plugin, const char *filename)
|
|||
g_signal_connect (G_OBJECT (connection), "ifcfg-changed",
|
||||
G_CALLBACK (connection_ifcfg_changed), plugin);
|
||||
} else {
|
||||
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " error: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
if (!ignore_error) {
|
||||
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " error: %s",
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
}
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +287,7 @@ connection_changed_handler (SCPluginIfcfg *plugin,
|
|||
NMIfcfgConnection *tmp;
|
||||
GError *error = NULL;
|
||||
GHashTable *settings;
|
||||
gboolean new_unmanaged, old_unmanaged;
|
||||
gboolean new_unmanaged, old_unmanaged, ignore_error = FALSE;
|
||||
|
||||
g_return_if_fail (plugin != NULL);
|
||||
g_return_if_fail (path != NULL);
|
||||
|
|
@ -294,12 +297,16 @@ connection_changed_handler (SCPluginIfcfg *plugin,
|
|||
|
||||
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "updating %s", path);
|
||||
|
||||
tmp = (NMIfcfgConnection *) nm_ifcfg_connection_new (path, priv->g_connection, priv->hal_mgr, &error);
|
||||
tmp = (NMIfcfgConnection *) nm_ifcfg_connection_new (path, priv->g_connection,
|
||||
priv->hal_mgr,
|
||||
&error,
|
||||
&ignore_error);
|
||||
if (!tmp) {
|
||||
/* couldn't read connection; remove it */
|
||||
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error: %s",
|
||||
error->message ? error->message : "(unknown)");
|
||||
/* errors reading connection; remove it */
|
||||
if (!ignore_error) {
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " error: %s",
|
||||
error->message ? error->message : "(unknown)");
|
||||
}
|
||||
g_error_free (error);
|
||||
|
||||
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "removed %s.", path);
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ get_one_ip4_addr (shvarFile *ifcfg,
|
|||
g_return_if_fail (ifcfg != NULL);
|
||||
g_return_if_fail (tag != NULL);
|
||||
g_return_if_fail (out_addr != NULL);
|
||||
g_return_if_fail (*out_addr == 0);
|
||||
g_return_if_fail (error != NULL);
|
||||
g_return_if_fail (*error == NULL);
|
||||
|
||||
|
|
@ -222,11 +223,13 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
|
|||
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
|
||||
addr = nm_ip4_address_new ();
|
||||
|
||||
tmp = 0;
|
||||
get_one_ip4_addr (ifcfg, "IPADDR", &tmp, error);
|
||||
if (*error)
|
||||
goto error;
|
||||
nm_ip4_address_set_address (addr, tmp);
|
||||
|
||||
tmp = 0;
|
||||
get_one_ip4_addr (ifcfg, "GATEWAY", &tmp, error);
|
||||
if (*error)
|
||||
goto error;
|
||||
|
|
@ -236,6 +239,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
|
|||
if (!nm_ip4_address_get_gateway (addr)) {
|
||||
network_ifcfg = svNewFile (SYSCONFDIR "/sysconfig/network");
|
||||
if (network_ifcfg) {
|
||||
tmp = 0;
|
||||
get_one_ip4_addr (network_ifcfg, "GATEWAY", &tmp, error);
|
||||
svCloseFile (network_ifcfg);
|
||||
if (*error)
|
||||
|
|
@ -262,6 +266,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
|
|||
|
||||
/* Fall back to NETMASK if no PREFIX was specified */
|
||||
if (!nm_ip4_address_get_prefix (addr)) {
|
||||
netmask = 0;
|
||||
get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error);
|
||||
if (*error)
|
||||
goto error;
|
||||
|
|
@ -933,7 +938,8 @@ NMConnection *
|
|||
connection_from_file (const char *filename,
|
||||
gboolean *ignored,
|
||||
char **keyfile,
|
||||
GError **error)
|
||||
GError **error,
|
||||
gboolean *ignore_error)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -978,6 +984,7 @@ connection_from_file (const char *filename,
|
|||
}
|
||||
|
||||
if (!strcmp (device, "lo")) {
|
||||
*ignore_error = TRUE;
|
||||
g_set_error (error, ifcfg_plugin_error_quark (), 0,
|
||||
"Ignoring loopback device config.");
|
||||
g_free (device);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
NMConnection *connection_from_file (const char *filename,
|
||||
gboolean *ignored,
|
||||
char **keyfile,
|
||||
GError **error);
|
||||
GError **error,
|
||||
gboolean *ignore_error);
|
||||
|
||||
#endif /* __READER_H__ */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include <gmodule.h>
|
||||
#include <glib-object.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gslist.h>
|
||||
#include <glib.h>
|
||||
#include <nm-setting-connection.h>
|
||||
|
||||
#include "interface_parser.h"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
SUBDIRS=io tests
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/system-settings/src \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_srcdir)/libnm-glib \
|
||||
-I$(top_srcdir)/system-settings/plugins/keyfile/io
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-settings-plugin-keyfile.la
|
||||
|
||||
|
|
@ -5,11 +13,7 @@ libnm_settings_plugin_keyfile_la_SOURCES = \
|
|||
nm-keyfile-connection.c \
|
||||
nm-keyfile-connection.h \
|
||||
plugin.c \
|
||||
plugin.h \
|
||||
reader.c \
|
||||
reader.h \
|
||||
writer.c \
|
||||
writer.h
|
||||
plugin.h
|
||||
|
||||
keyfiledir=$(sysconfdir)/NetworkManager/system-connections
|
||||
|
||||
|
|
@ -19,10 +23,6 @@ libnm_settings_plugin_keyfile_la_CPPFLAGS = \
|
|||
$(DBUS_CFLAGS) \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-I${top_srcdir}/system-settings/src \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I${top_srcdir}/libnm-glib \
|
||||
-DKEYFILE_DIR=\""$(keyfiledir)"\"
|
||||
|
||||
libnm_settings_plugin_keyfile_la_LDFLAGS = -module -avoid-version
|
||||
|
|
@ -31,7 +31,8 @@ libnm_settings_plugin_keyfile_la_LIBADD = \
|
|||
$(GMODULE_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(top_builddir)/libnm-glib/libnm_glib.la
|
||||
$(top_builddir)/libnm-glib/libnm_glib.la \
|
||||
$(top_builddir)/system-settings/plugins/keyfile/io/libkeyfile-io.la
|
||||
|
||||
if NO_GIO
|
||||
libnm_settings_plugin_keyfile_la_LIBADD += \
|
||||
|
|
|
|||
20
system-settings/plugins/keyfile/io/Makefile.am
Normal file
20
system-settings/plugins/keyfile/io/Makefile.am
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
INCLUDES = \
|
||||
-I$(top_srcdir)/system-settings/src \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util \
|
||||
-I$(top_srcdir)/libnm-glib
|
||||
|
||||
noinst_LTLIBRARIES = libkeyfile-io.la
|
||||
|
||||
libkeyfile_io_la_SOURCES = \
|
||||
reader.h \
|
||||
reader.c \
|
||||
writer.h \
|
||||
writer.c
|
||||
|
||||
libkeyfile_io_la_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
libkeyfile_io_la_LIBADD = $(GTHREAD_LIBS)
|
||||
|
||||
|
|
@ -29,7 +29,10 @@
|
|||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-wireless.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
@ -43,36 +46,12 @@ read_array_of_uint (GKeyFile *file,
|
|||
GArray *array = NULL;
|
||||
gsize length;
|
||||
int i;
|
||||
gint *tmp;
|
||||
|
||||
if (NM_IS_SETTING_IP4_CONFIG (setting) && !strcmp (key, NM_SETTING_IP4_CONFIG_DNS)) {
|
||||
char **list, **iter;
|
||||
int ret;
|
||||
|
||||
list = g_key_file_get_string_list (file, nm_setting_get_name (setting), key, &length, NULL);
|
||||
if (!list || !g_strv_length (list))
|
||||
return TRUE;
|
||||
|
||||
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
|
||||
for (iter = list; *iter; iter++) {
|
||||
struct in_addr addr;
|
||||
|
||||
ret = inet_pton (AF_INET, *iter, &addr);
|
||||
if (ret <= 0) {
|
||||
g_warning ("%s: ignoring invalid DNS server address '%s'", __func__, *iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_array_append_val (array, addr.s_addr);
|
||||
}
|
||||
} else {
|
||||
gint *tmp;
|
||||
|
||||
tmp = g_key_file_get_integer_list (file, nm_setting_get_name (setting), key, &length, NULL);
|
||||
|
||||
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
|
||||
for (i = 0; i < length; i++)
|
||||
g_array_append_val (array, tmp[i]);
|
||||
}
|
||||
tmp = g_key_file_get_integer_list (file, nm_setting_get_name (setting), key, &length, NULL);
|
||||
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
|
||||
for (i = 0; i < length; i++)
|
||||
g_array_append_val (array, tmp[i]);
|
||||
|
||||
if (array) {
|
||||
g_object_set (setting, key, array, NULL);
|
||||
|
|
@ -181,6 +160,25 @@ next:
|
|||
return addresses;
|
||||
}
|
||||
|
||||
static void
|
||||
ip4_addr_parser (NMSetting *setting, const char *key, GKeyFile *keyfile)
|
||||
{
|
||||
GPtrArray *addresses;
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
|
||||
addresses = read_addresses (keyfile, setting_name, key);
|
||||
|
||||
/* Work around for previous syntax */
|
||||
if (!addresses && !strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
|
||||
addresses = read_addresses (keyfile, setting_name, "address");
|
||||
|
||||
if (addresses) {
|
||||
g_object_set (setting, key, addresses, NULL);
|
||||
g_ptr_array_foreach (addresses, free_one_address, NULL);
|
||||
g_ptr_array_free (addresses, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
free_one_route (gpointer data, gpointer user_data)
|
||||
{
|
||||
|
|
@ -236,7 +234,7 @@ read_routes (GKeyFile *file,
|
|||
} else if (j == 3) {
|
||||
guint32 metric = 0;
|
||||
|
||||
/* prefix */
|
||||
/* metric */
|
||||
if (!get_one_int (*iter, G_MAXUINT32, key_name, &metric)) {
|
||||
g_array_free (route, TRUE);
|
||||
goto next;
|
||||
|
|
@ -268,48 +266,110 @@ next:
|
|||
return routes;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
read_array_of_array_of_uint (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key)
|
||||
static void
|
||||
ip4_route_parser (NMSetting *setting, const char *key, GKeyFile *keyfile)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
const char *setting_name;
|
||||
GPtrArray *routes;
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
|
||||
/* Only handle IPv4 addresses and routes for now */
|
||||
if (!NM_IS_SETTING_IP4_CONFIG (setting))
|
||||
return FALSE;
|
||||
routes = read_routes (keyfile, setting_name, key);
|
||||
if (routes) {
|
||||
g_object_set (setting, key, routes, NULL);
|
||||
g_ptr_array_foreach (routes, free_one_route, NULL);
|
||||
g_ptr_array_free (routes, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
setting_name = nm_setting_get_name (setting);
|
||||
static void
|
||||
ip4_dns_parser (NMSetting *setting, const char *key, GKeyFile *keyfile)
|
||||
{
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
GArray *array = NULL;
|
||||
gsize length;
|
||||
char **list, **iter;
|
||||
int ret;
|
||||
|
||||
if (!strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES)) {
|
||||
GPtrArray *addresses;
|
||||
list = g_key_file_get_string_list (keyfile, setting_name, key, &length, NULL);
|
||||
if (!list || !g_strv_length (list))
|
||||
return;
|
||||
|
||||
addresses = read_addresses (file, setting_name, key);
|
||||
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
|
||||
for (iter = list; *iter; iter++) {
|
||||
struct in_addr addr;
|
||||
|
||||
/* Work around for previous syntax */
|
||||
if (!addresses && !strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
|
||||
addresses = read_addresses (file, setting_name, "address");
|
||||
|
||||
if (addresses) {
|
||||
g_object_set (setting, key, addresses, NULL);
|
||||
g_ptr_array_foreach (addresses, free_one_address, NULL);
|
||||
g_ptr_array_free (addresses, TRUE);
|
||||
ret = inet_pton (AF_INET, *iter, &addr);
|
||||
if (ret <= 0) {
|
||||
g_warning ("%s: ignoring invalid DNS server address '%s'", __func__, *iter);
|
||||
continue;
|
||||
}
|
||||
success = TRUE;
|
||||
} else if (!strcmp (key, NM_SETTING_IP4_CONFIG_ROUTES)) {
|
||||
GPtrArray *routes;
|
||||
|
||||
routes = read_routes (file, setting_name, key);
|
||||
if (routes) {
|
||||
g_object_set (setting, key, routes, NULL);
|
||||
g_ptr_array_foreach (routes, free_one_route, NULL);
|
||||
g_ptr_array_free (routes, TRUE);
|
||||
}
|
||||
success = TRUE;
|
||||
g_array_append_val (array, addr.s_addr);
|
||||
}
|
||||
|
||||
return success;
|
||||
if (array) {
|
||||
g_object_set (setting, key, array, NULL);
|
||||
g_array_free (array, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mac_address_parser (NMSetting *setting, const char *key, GKeyFile *keyfile)
|
||||
{
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
struct ether_addr *eth;
|
||||
char *tmp_string = NULL, *p;
|
||||
gint *tmp_list;
|
||||
GByteArray *array = NULL;
|
||||
gsize length;
|
||||
int i;
|
||||
|
||||
p = tmp_string = g_key_file_get_string (keyfile, setting_name, key, NULL);
|
||||
if (tmp_string) {
|
||||
/* Look for enough ':' characters to signify a MAC address */
|
||||
i = 0;
|
||||
while (*p) {
|
||||
if (*p == ':')
|
||||
i++;
|
||||
p++;
|
||||
}
|
||||
if (i == 5) {
|
||||
/* parse as a MAC address */
|
||||
eth = ether_aton (tmp_string);
|
||||
if (eth) {
|
||||
g_free (tmp_string);
|
||||
array = g_byte_array_sized_new (ETH_ALEN);
|
||||
g_byte_array_append (array, eth->ether_addr_octet, ETH_ALEN);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (tmp_string);
|
||||
|
||||
/* Old format; list of ints */
|
||||
tmp_list = g_key_file_get_integer_list (keyfile, setting_name, key, &length, NULL);
|
||||
array = g_byte_array_sized_new (length);
|
||||
for (i = 0; i < length; i++) {
|
||||
int val = tmp_list[i];
|
||||
unsigned char v = (unsigned char) (val & 0xFF);
|
||||
|
||||
if (val < 0 || val > 255) {
|
||||
g_warning ("%s: %s / %s ignoring invalid byte element '%d' (not "
|
||||
" between 0 and 255 inclusive)", __func__, setting_name,
|
||||
key, val);
|
||||
} else
|
||||
g_byte_array_append (array, (const unsigned char *) &v, sizeof (v));
|
||||
}
|
||||
g_free (tmp_list);
|
||||
|
||||
done:
|
||||
if (array->len == ETH_ALEN) {
|
||||
g_object_set (setting, key, array, NULL);
|
||||
} else {
|
||||
g_warning ("%s: ignoring invalid MAC address for %s / %s",
|
||||
__func__, setting_name, key);
|
||||
}
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -337,11 +397,52 @@ read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key)
|
|||
g_strfreev (keys);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
GKeyFile *keyfile;
|
||||
gboolean secrets;
|
||||
} ReadSettingInfo;
|
||||
|
||||
typedef struct {
|
||||
const char *setting_name;
|
||||
const char *key;
|
||||
gboolean check_for_key;
|
||||
void (*parser) (NMSetting *setting, const char *key, GKeyFile *keyfile);
|
||||
} KeyParser;
|
||||
|
||||
/* A table of keys that require further parsing/conversion becuase they are
|
||||
* stored in a format that can't be automatically read using the key's type.
|
||||
* i.e. IP addresses, which are stored in NetworkManager as guint32, but are
|
||||
* stored in keyfiles as strings, eg "10.1.1.2".
|
||||
*/
|
||||
static KeyParser key_parsers[] = {
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_ADDRESSES,
|
||||
FALSE,
|
||||
ip4_addr_parser },
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_ROUTES,
|
||||
FALSE,
|
||||
ip4_route_parser },
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_DNS,
|
||||
FALSE,
|
||||
ip4_dns_parser },
|
||||
{ NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS,
|
||||
TRUE,
|
||||
mac_address_parser },
|
||||
{ NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_MAC_ADDRESS,
|
||||
TRUE,
|
||||
mac_address_parser },
|
||||
{ NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_BSSID,
|
||||
TRUE,
|
||||
mac_address_parser },
|
||||
{ NULL, NULL, FALSE }
|
||||
};
|
||||
|
||||
static void
|
||||
read_one_setting_value (NMSetting *setting,
|
||||
const char *key,
|
||||
|
|
@ -355,6 +456,7 @@ read_one_setting_value (NMSetting *setting,
|
|||
GType type;
|
||||
GError *err = NULL;
|
||||
gboolean check_for_key = TRUE;
|
||||
KeyParser *parser = &key_parsers[0];
|
||||
|
||||
/* Property is not writable */
|
||||
if (!(flags & G_PARAM_WRITABLE))
|
||||
|
|
@ -375,18 +477,38 @@ read_one_setting_value (NMSetting *setting,
|
|||
|
||||
setting_name = nm_setting_get_name (setting);
|
||||
|
||||
/* IPv4 addresses and VPN properties don't have the exact key name */
|
||||
if (NM_IS_SETTING_IP4_CONFIG (setting) && !strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
|
||||
check_for_key = FALSE;
|
||||
else if (NM_IS_SETTING_VPN (setting))
|
||||
/* Look through the list of handlers for non-standard format key values */
|
||||
while (parser->setting_name) {
|
||||
if (!strcmp (parser->setting_name, setting_name) && !strcmp (parser->key, key)) {
|
||||
check_for_key = parser->check_for_key;
|
||||
break;
|
||||
}
|
||||
parser++;
|
||||
}
|
||||
|
||||
/* VPN properties don't have the exact key name */
|
||||
if (NM_IS_SETTING_VPN (setting))
|
||||
check_for_key = FALSE;
|
||||
|
||||
/* Check for the exact key in the GKeyFile if required. Most setting
|
||||
* properties map 1:1 to a key in the GKeyFile, but for those properties
|
||||
* like IP addresses and routes where more than one value is actually
|
||||
* encoded by the setting property, this won't be true.
|
||||
*/
|
||||
if (check_for_key && !g_key_file_has_key (file, setting_name, key, &err)) {
|
||||
/* Key doesn't exist or an error ocurred, thus nothing to do. */
|
||||
if (err) {
|
||||
g_warning ("Error loading setting '%s' value: %s", setting_name, err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* If there's a custom parser for this key, handle that before the generic
|
||||
* parsers below.
|
||||
*/
|
||||
if (parser && parser->setting_name) {
|
||||
(*parser->parser) (setting, key, file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -444,9 +566,11 @@ read_one_setting_value (NMSetting *setting,
|
|||
int val = tmp[i];
|
||||
unsigned char v = (unsigned char) (val & 0xFF);
|
||||
|
||||
if (val < 0 || val > 255)
|
||||
g_warning ("Value out of range for a byte value");
|
||||
else
|
||||
if (val < 0 || val > 255) {
|
||||
g_warning ("%s: %s / %s ignoring invalid byte element '%d' (not "
|
||||
" between 0 and 255 inclusive)", __func__, setting_name,
|
||||
key, val);
|
||||
} else
|
||||
g_byte_array_append (array, (const unsigned char *) &v, sizeof (v));
|
||||
}
|
||||
|
||||
|
|
@ -475,11 +599,6 @@ read_one_setting_value (NMSetting *setting,
|
|||
g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
|
||||
setting_name, key, G_VALUE_TYPE_NAME (value));
|
||||
}
|
||||
} else if (type == DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT) {
|
||||
if (!read_array_of_array_of_uint (file, setting, key)) {
|
||||
g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
|
||||
setting_name, key, G_VALUE_TYPE_NAME (value));
|
||||
}
|
||||
} else {
|
||||
g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'",
|
||||
setting_name, key, G_VALUE_TYPE_NAME (value));
|
||||
|
|
@ -27,9 +27,14 @@
|
|||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-wired.h>
|
||||
#include <nm-setting-wireless.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
#include <nm-utils.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <nm-settings.h>
|
||||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "writer.h"
|
||||
|
|
@ -43,44 +48,53 @@ write_array_of_uint (GKeyFile *file,
|
|||
{
|
||||
GArray *array;
|
||||
int i;
|
||||
int *tmp_array;
|
||||
|
||||
array = (GArray *) g_value_get_boxed (value);
|
||||
if (!array || !array->len)
|
||||
return TRUE;
|
||||
|
||||
if (NM_IS_SETTING_IP4_CONFIG (setting) && !strcmp (key, NM_SETTING_IP4_CONFIG_DNS)) {
|
||||
char **list;
|
||||
tmp_array = g_new (gint, array->len);
|
||||
for (i = 0; i < array->len; i++)
|
||||
tmp_array[i] = g_array_index (array, int, i);
|
||||
|
||||
list = g_new0 (char *, array->len + 1);
|
||||
g_key_file_set_integer_list (file, nm_setting_get_name (setting), key, tmp_array, array->len);
|
||||
g_free (tmp_array);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < array->len; i++) {
|
||||
char buf[INET_ADDRSTRLEN + 1];
|
||||
struct in_addr addr;
|
||||
static void
|
||||
ip4_dns_writer (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value)
|
||||
{
|
||||
GArray *array;
|
||||
char **list;
|
||||
int i, num = 0;
|
||||
|
||||
addr.s_addr = g_array_index (array, guint32, i);
|
||||
if (!inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
|
||||
nm_warning ("%s: error converting IP4 address 0x%X",
|
||||
__func__, ntohl (addr.s_addr));
|
||||
list[i] = NULL;
|
||||
} else {
|
||||
list[i] = g_strdup (buf);
|
||||
}
|
||||
}
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_UINT_ARRAY));
|
||||
|
||||
g_key_file_set_string_list (file, nm_setting_get_name (setting), key, (const char **) list, array->len);
|
||||
g_strfreev (list);
|
||||
} else {
|
||||
int *tmp_array;
|
||||
array = (GArray *) g_value_get_boxed (value);
|
||||
if (!array || !array->len)
|
||||
return;
|
||||
|
||||
tmp_array = g_new (gint, array->len);
|
||||
for (i = 0; i < array->len; i++)
|
||||
tmp_array[i] = g_array_index (array, int, i);
|
||||
list = g_new0 (char *, array->len + 1);
|
||||
|
||||
g_key_file_set_integer_list (file, nm_setting_get_name (setting), key, tmp_array, array->len);
|
||||
g_free (tmp_array);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
char buf[INET_ADDRSTRLEN + 1];
|
||||
struct in_addr addr;
|
||||
|
||||
addr.s_addr = g_array_index (array, guint32, i);
|
||||
if (!inet_ntop (AF_INET, &addr, buf, sizeof (buf))) {
|
||||
nm_warning ("%s: error converting IP4 address 0x%X",
|
||||
__func__, ntohl (addr.s_addr));
|
||||
} else
|
||||
list[num++] = g_strdup (buf);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
g_key_file_set_string_list (file, nm_setting_get_name (setting), key, (const char **) list, num);
|
||||
g_strfreev (list);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -95,7 +109,7 @@ write_ip4_values (GKeyFile *file,
|
|||
char **list = NULL;
|
||||
int i, j;
|
||||
|
||||
list = g_malloc (tuple_len);
|
||||
list = g_new (char *, tuple_len);
|
||||
|
||||
for (i = 0, j = 0; i < array->len; i++, j++) {
|
||||
GArray *tuple = g_ptr_array_index (array, i);
|
||||
|
|
@ -103,7 +117,7 @@ write_ip4_values (GKeyFile *file,
|
|||
char *key_name;
|
||||
int k;
|
||||
|
||||
memset (list, 0, tuple_len);
|
||||
memset (list, 0, tuple_len * sizeof (char *));
|
||||
|
||||
for (k = 0; k < tuple_len; k++) {
|
||||
if (k == addr1_pos || k == addr2_pos) {
|
||||
|
|
@ -138,28 +152,64 @@ write_ip4_values (GKeyFile *file,
|
|||
g_free (list);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
write_array_of_array_of_uint (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value)
|
||||
static void
|
||||
ip4_addr_writer (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value)
|
||||
{
|
||||
GPtrArray *array;
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
|
||||
/* Only handle IPv4 addresses and routes for now */
|
||||
if (!NM_IS_SETTING_IP4_CONFIG (setting))
|
||||
return FALSE;
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT));
|
||||
|
||||
array = (GPtrArray *) g_value_get_boxed (value);
|
||||
if (!array || !array->len)
|
||||
return TRUE;
|
||||
if (array && array->len)
|
||||
write_ip4_values (file, setting_name, key, array, 3, 0, 2);
|
||||
}
|
||||
|
||||
if (!strcmp (key, NM_SETTING_IP4_CONFIG_ADDRESSES))
|
||||
write_ip4_values (file, nm_setting_get_name (setting), key, array, 3, 0, 2);
|
||||
else if (!strcmp (key, NM_SETTING_IP4_CONFIG_ROUTES))
|
||||
write_ip4_values (file, nm_setting_get_name (setting), key, array, 4, 0, 2);
|
||||
static void
|
||||
ip4_route_writer (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value)
|
||||
{
|
||||
GPtrArray *array;
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
|
||||
return TRUE;
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT));
|
||||
|
||||
array = (GPtrArray *) g_value_get_boxed (value);
|
||||
if (array && array->len)
|
||||
write_ip4_values (file, setting_name, key, array, 4, 0, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
mac_address_writer (GKeyFile *file,
|
||||
NMSetting *setting,
|
||||
const char *key,
|
||||
const GValue *value)
|
||||
{
|
||||
GByteArray *array;
|
||||
const char *setting_name = nm_setting_get_name (setting);
|
||||
char *mac;
|
||||
struct ether_addr tmp;
|
||||
|
||||
g_return_if_fail (G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY));
|
||||
|
||||
array = (GByteArray *) g_value_get_boxed (value);
|
||||
if (!array)
|
||||
return;
|
||||
|
||||
if (array->len != ETH_ALEN) {
|
||||
nm_warning ("%s: invalid %s / %s MAC address length %d",
|
||||
__func__, setting_name, key, array->len);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy (tmp.ether_addr_octet, array->data, ETH_ALEN);
|
||||
mac = ether_ntoa (&tmp);
|
||||
g_key_file_set_string (file, setting_name, key, mac);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -201,6 +251,39 @@ write_hash_of_string (GKeyFile *file,
|
|||
g_hash_table_foreach (hash, write_hash_of_string_helper, &info);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *setting_name;
|
||||
const char *key;
|
||||
void (*writer) (GKeyFile *keyfile, NMSetting *setting, const char *key, const GValue *value);
|
||||
} KeyWriter;
|
||||
|
||||
/* A table of keys that require further parsing/conversion becuase they are
|
||||
* stored in a format that can't be automatically read using the key's type.
|
||||
* i.e. IP addresses, which are stored in NetworkManager as guint32, but are
|
||||
* stored in keyfiles as strings, eg "10.1.1.2".
|
||||
*/
|
||||
static KeyWriter key_writers[] = {
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_ADDRESSES,
|
||||
ip4_addr_writer },
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_ROUTES,
|
||||
ip4_route_writer },
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_DNS,
|
||||
ip4_dns_writer },
|
||||
{ NM_SETTING_WIRED_SETTING_NAME,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS,
|
||||
mac_address_writer },
|
||||
{ NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_MAC_ADDRESS,
|
||||
mac_address_writer },
|
||||
{ NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_BSSID,
|
||||
mac_address_writer },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
write_setting_value (NMSetting *setting,
|
||||
const char *key,
|
||||
|
|
@ -211,6 +294,7 @@ write_setting_value (NMSetting *setting,
|
|||
GKeyFile *file = (GKeyFile *) user_data;
|
||||
const char *setting_name;
|
||||
GType type;
|
||||
KeyWriter *writer = &key_writers[0];
|
||||
|
||||
type = G_VALUE_TYPE (value);
|
||||
|
||||
|
|
@ -225,6 +309,15 @@ write_setting_value (NMSetting *setting,
|
|||
|
||||
setting_name = nm_setting_get_name (setting);
|
||||
|
||||
/* Look through the list of handlers for non-standard format key values */
|
||||
while (writer->setting_name) {
|
||||
if (!strcmp (writer->setting_name, setting_name) && !strcmp (writer->key, key)) {
|
||||
(*writer->writer) (file, setting, key, value);
|
||||
return;
|
||||
}
|
||||
writer++;
|
||||
}
|
||||
|
||||
if (type == G_TYPE_STRING) {
|
||||
const char *str;
|
||||
|
||||
|
|
@ -260,7 +353,7 @@ write_setting_value (NMSetting *setting,
|
|||
g_key_file_set_integer_list (file, setting_name, key, tmp_array, array->len);
|
||||
g_free (tmp_array);
|
||||
}
|
||||
} else if (type == dbus_g_type_get_collection ("GSList", G_TYPE_STRING)) {
|
||||
} else if (type == DBUS_TYPE_G_LIST_OF_STRING) {
|
||||
GSList *list;
|
||||
GSList *iter;
|
||||
|
||||
|
|
@ -276,18 +369,13 @@ write_setting_value (NMSetting *setting,
|
|||
g_key_file_set_string_list (file, setting_name, key, (const gchar **const) array, i);
|
||||
g_free (array);
|
||||
}
|
||||
} else if (type == dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) {
|
||||
} else if (type == DBUS_TYPE_G_MAP_OF_STRING) {
|
||||
write_hash_of_string (file, setting, key, value);
|
||||
} else if (type == DBUS_TYPE_G_UINT_ARRAY) {
|
||||
if (!write_array_of_uint (file, setting, key, value)) {
|
||||
g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'",
|
||||
setting_name, key, g_type_name (type));
|
||||
}
|
||||
} else if (type == DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT) {
|
||||
if (!write_array_of_array_of_uint (file, setting, key, value)) {
|
||||
g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'",
|
||||
setting_name, key, g_type_name (type));
|
||||
}
|
||||
} else {
|
||||
g_warning ("Unhandled setting property type (write) '%s/%s' : '%s'",
|
||||
setting_name, key, g_type_name (type));
|
||||
|
|
@ -315,7 +403,12 @@ writer_id_to_filename (const char *id)
|
|||
}
|
||||
|
||||
gboolean
|
||||
write_connection (NMConnection *connection, char **out_path, GError **error)
|
||||
write_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
GKeyFile *key_file;
|
||||
|
|
@ -323,6 +416,7 @@ write_connection (NMConnection *connection, char **out_path, GError **error)
|
|||
gsize len;
|
||||
gboolean success = FALSE;
|
||||
char *filename, *path;
|
||||
int err;
|
||||
|
||||
if (out_path)
|
||||
g_return_val_if_fail (*out_path == NULL, FALSE);
|
||||
|
|
@ -338,18 +432,27 @@ write_connection (NMConnection *connection, char **out_path, GError **error)
|
|||
goto out;
|
||||
|
||||
filename = writer_id_to_filename (nm_setting_connection_get_id (s_con));
|
||||
path = g_build_filename (KEYFILE_DIR, filename, NULL);
|
||||
path = g_build_filename (keyfile_dir, filename, NULL);
|
||||
g_free (filename);
|
||||
|
||||
g_file_set_contents (path, data, len, error);
|
||||
chmod (path, S_IRUSR | S_IWUSR);
|
||||
if (chown (path, 0, 0) < 0) {
|
||||
g_warning ("Error chowning '%s': %d", path, errno);
|
||||
if (chown (path, owner_uid, owner_grp) < 0) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
|
||||
"%s.%d: error chowning '%s': %d", __FILE__, __LINE__,
|
||||
path, errno);
|
||||
unlink (path);
|
||||
} else {
|
||||
if (out_path)
|
||||
*out_path = g_strdup (path);
|
||||
success = TRUE;
|
||||
err = chmod (path, S_IRUSR | S_IWUSR);
|
||||
if (err > 0) {
|
||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INTERNAL_ERROR,
|
||||
"%s.%d: error setting permissions on '%s': %d", __FILE__,
|
||||
__LINE__, path, errno);
|
||||
unlink (path);
|
||||
} else {
|
||||
if (out_path)
|
||||
*out_path = g_strdup (path);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
|
|
@ -25,7 +25,12 @@
|
|||
#include <glib.h>
|
||||
#include <nm-connection.h>
|
||||
|
||||
gboolean write_connection (NMConnection *connection, char **out_path, GError **error);
|
||||
gboolean write_connection (NMConnection *connection,
|
||||
const char *keyfile_dir,
|
||||
uid_t owner_uid,
|
||||
pid_t owner_grp,
|
||||
char **out_path,
|
||||
GError **error);
|
||||
|
||||
char *writer_id_to_filename (const char *id);
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ update (NMExportedConnection *exported,
|
|||
connection = nm_exported_connection_get_connection (exported);
|
||||
success = nm_connection_replace_settings (connection, new_settings, error);
|
||||
if (success) {
|
||||
success = write_connection (connection, &filename, error);
|
||||
success = write_connection (connection, KEYFILE_DIR, 0, 0, &filename, error);
|
||||
if (success && filename && strcmp (priv->filename, filename)) {
|
||||
/* Update the filename if it changed */
|
||||
g_free (priv->filename);
|
||||
|
|
@ -294,7 +294,7 @@ constructor (GType type,
|
|||
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
|
||||
g_free (uuid);
|
||||
|
||||
if (!write_connection (wrapped, NULL, &error)) {
|
||||
if (!write_connection (wrapped, KEYFILE_DIR, 0, 0, NULL, &error)) {
|
||||
g_warning ("Couldn't update connection %s with a UUID: (%d) %s",
|
||||
nm_setting_connection_get_id (s_con), error ? error->code : 0,
|
||||
error ? error->message : "unknown");
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue