mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 14:30:09 +01:00
all: merge branch 'danw/gdbus-bgo622927'
Port the remaining parts of src/ to gdbus. (Note that most of the individual commits on this branch do not compile; they are split up for ease of comprehension, but all depend on each other.) https://bugzilla.gnome.org/show_bug.cgi?id=622927
This commit is contained in:
commit
3cf736b9e0
113 changed files with 2434 additions and 2713 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -31,7 +31,6 @@ cscope.*out
|
|||
valgrind-*.log
|
||||
test-*.log
|
||||
test-*.trs
|
||||
*-glue.h
|
||||
|
||||
/ABOUT-NLS
|
||||
/COPYING
|
||||
|
|
@ -156,6 +155,8 @@ test-*.trs
|
|||
/libnm-core/tests/test-setting-8021x
|
||||
/libnm-core/tests/test-setting-dcb
|
||||
|
||||
/libnm-glib/nm-secret-agent-glue.h
|
||||
/libnm-glib/nm-vpn-plugin-glue.h
|
||||
/libnm-glib/libnm-glib-test
|
||||
/libnm-glib/tests/test-nm-client
|
||||
/libnm-glib/tests/test-remote-settings-client
|
||||
|
|
@ -246,6 +247,7 @@ test-*.trs
|
|||
/src/rdisc/tests/test-rdisc-fake
|
||||
/src/rdisc/tests/test-rdisc-linux
|
||||
/src/settings/plugins/ibft/tests/test-ibft
|
||||
/src/settings/plugins/ifcfg-rh/nmdbus-ifcfg-rh.[ch]
|
||||
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
|
||||
/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils
|
||||
/src/settings/plugins/ifnet/tests/test-ifnet
|
||||
|
|
|
|||
14
Makefile.am
14
Makefile.am
|
|
@ -6,8 +6,6 @@ SUBDIRS = \
|
|||
introspection \
|
||||
libnm-core \
|
||||
libnm \
|
||||
libnm-util \
|
||||
libnm-glib \
|
||||
src \
|
||||
callouts \
|
||||
clients \
|
||||
|
|
@ -15,9 +13,17 @@ SUBDIRS = \
|
|||
policy \
|
||||
data \
|
||||
po \
|
||||
docs \
|
||||
man \
|
||||
examples \
|
||||
examples
|
||||
|
||||
if WITH_LEGACY_LIBRARIES
|
||||
SUBDIRS += \
|
||||
libnm-util \
|
||||
libnm-glib
|
||||
endif
|
||||
|
||||
SUBDIRS += \
|
||||
docs \
|
||||
vapi
|
||||
|
||||
@GNOME_CODE_COVERAGE_RULES@
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ AM_CPPFLAGS = \
|
|||
-I${top_srcdir}/libnm-core \
|
||||
-I${top_builddir}/libnm-core \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DNETWORKMANAGER_COMPILATION \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
-DNMCONFDIR=\"$(nmconfdir)\" \
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ AM_CPPFLAGS = \
|
|||
-DNETWORKMANAGER_COMPILATION \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
-DSRCDIR=\"$(abs_srcdir)\" \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
test-dispatcher-envp
|
||||
|
|
@ -23,8 +22,7 @@ test_dispatcher_envp_SOURCES = \
|
|||
test_dispatcher_envp_LDADD = \
|
||||
$(top_builddir)/libnm/libnm.la \
|
||||
$(top_builddir)/callouts/libtest-dispatcher-envp.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS)
|
||||
$(GLIB_LIBS)
|
||||
|
||||
###########################################
|
||||
|
||||
|
|
|
|||
30
configure.ac
30
configure.ac
|
|
@ -268,25 +268,6 @@ dnl
|
|||
AC_CHECK_LIB([dl], [dladdr], LIBDL="-ldl", LIBDL="")
|
||||
AC_SUBST(LIBDL)
|
||||
|
||||
dnl
|
||||
dnl Checks for dbus-glib
|
||||
dnl
|
||||
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.94)
|
||||
|
||||
AC_CHECK_LIB([dbus-glib-1], [dbus_g_method_invocation_get_g_connection], ac_have_gmi_get_con="1", ac_have_gmi_get_con="0")
|
||||
AC_DEFINE_UNQUOTED(HAVE_DBUS_GLIB_GMI_GET_CONNECTION, $ac_have_gmi_get_con, [Define if you have a dbus-glib with dbus_g_method_invocation_get_g_connection()])
|
||||
|
||||
dnl
|
||||
dnl Only dbus-glib >= 0.100 can use private dbus connections
|
||||
dnl
|
||||
PKG_CHECK_MODULES(DBUS_GLIB_100, [dbus-glib-1 >= 0.100], [have_dbus_glib_100=yes],[have_dbus_glib_100=no])
|
||||
if (test "${have_dbus_glib_100}" = "yes"); then
|
||||
AC_DEFINE(HAVE_DBUS_GLIB_100, 1, [Define if you have dbus-glib >= 0.100])
|
||||
else
|
||||
AC_DEFINE(HAVE_DBUS_GLIB_100, 0, [Define if you have dbus-glib >= 0.100])
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_DBUS_GLIB_100, test "${have_dbus_glib_100}" = "yes")
|
||||
|
||||
PKG_CHECK_MODULES(GLIB, [gio-unix-2.0 >= 2.37.6 gmodule-2.0],
|
||||
[AC_SUBST(LOG_DRIVER, '$(top_srcdir)/build-aux/tap-driver.sh'),
|
||||
AC_SUBST(AM_TESTS_FD_REDIRECT, '--tap')],
|
||||
|
|
@ -302,6 +283,16 @@ GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32 -DGLIB_V
|
|||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
|
||||
AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--without-libnm-glib], [don't build legacy libraries]))
|
||||
if test "$with_libnm_glib" != "no"; then
|
||||
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.94, :,
|
||||
[AC_MSG_FAILURE([$DBUS_PKG_ERRORS
|
||||
|
||||
Configure with --without-libnm-glib if you do not need the legacy libraries])])
|
||||
with_libnm_glib=yes
|
||||
fi
|
||||
AM_CONDITIONAL(WITH_LEGACY_LIBRARIES, test "$with_libnm_glib" != "no")
|
||||
|
||||
PKG_CHECK_MODULES(GUDEV, gudev-1.0 >= 165)
|
||||
|
||||
GOBJECT_INTROSPECTION_CHECK([0.9.6])
|
||||
|
|
@ -1154,6 +1145,7 @@ echo " ppp: $enable_ppp"
|
|||
echo " modemmanager-1: $with_modem_manager_1"
|
||||
echo " concheck: $enable_concheck"
|
||||
echo " libteamdctl: $enable_teamdctl"
|
||||
echo " libnm-glib: $with_libnm_glib"
|
||||
echo " nmtui: $build_nmtui"
|
||||
echo
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,7 @@
|
|||
SUBDIRS = libnm-glib libnm-util libnm api
|
||||
SUBDIRS = libnm api
|
||||
|
||||
if WITH_LEGACY_LIBRARIES
|
||||
SUBDIRS += \
|
||||
libnm-util \
|
||||
libnm-glib
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
EXTRA_DIST = \
|
||||
gsystem-local-alloc.h \
|
||||
nm-dbus-compat.h \
|
||||
nm-dbus-glib-types.h \
|
||||
nm-default.h \
|
||||
nm-glib.h \
|
||||
nm-gvaluearray-compat.h \
|
||||
nm-test-utils.h \
|
||||
nm-macros-internal.h
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
|
||||
static inline void
|
||||
__g_type_ensure (GType type)
|
||||
{
|
||||
|
|
@ -258,4 +255,23 @@ _g_key_file_save_to_file (GKeyFile *key_file,
|
|||
#endif
|
||||
|
||||
|
||||
#if GLIB_CHECK_VERSION (2, 36, 0)
|
||||
#define g_credentials_get_unix_pid(creds, error) \
|
||||
G_GNUC_EXTENSION ({ \
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
||||
(g_credentials_get_unix_pid) ((creds), (error)); \
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS \
|
||||
})
|
||||
#else
|
||||
#define g_credentials_get_unix_pid(creds, error) \
|
||||
G_GNUC_EXTENSION ({ \
|
||||
struct ucred *native_creds; \
|
||||
\
|
||||
native_creds = g_credentials_get_native ((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \
|
||||
g_assert (native_creds); \
|
||||
native_creds->pid; \
|
||||
})
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __NM_GLIB_H__ */
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@
|
|||
<tp:docstring>Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol.</tp:docstring>
|
||||
</property>
|
||||
<property name="Ssid" type="ay" access="read">
|
||||
<!-- gdbus-codegen assumes that "ay" means "non-UTF-8 string" and
|
||||
won't deal with '\0' bytes correctly.
|
||||
-->
|
||||
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="1"/>
|
||||
<tp:docstring>The Service Set Identifier identifying the access point.</tp:docstring>
|
||||
</property>
|
||||
<property name="Frequency" type="u" access="read">
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
Called by secret Agents to register their ability to provide and save
|
||||
network secrets.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_register"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="identifier" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
Identifies this agent; only one agent in each user session may use the
|
||||
|
|
@ -27,8 +25,6 @@
|
|||
<tp:docstring>
|
||||
Like Register() but indicates agent capabilities to NetworkManager.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_register_with_capabilities"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="identifier" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
See the Register() method's identifier argument.
|
||||
|
|
@ -47,8 +43,6 @@
|
|||
longer handle requests for network secrets. Agents are automatically
|
||||
unregistered when they disconnect from D-Bus.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_agent_manager_unregister"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
</method>
|
||||
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
<annotation name="org.gtk.GDBus.C.Name" value="DeviceWifi"/>
|
||||
|
||||
<method name="GetAccessPoints">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_access_points"/>
|
||||
<arg name="access_points" type="ao" direction="out">
|
||||
<tp:docstring>
|
||||
List of access point object paths.
|
||||
|
|
@ -20,7 +19,6 @@
|
|||
</method>
|
||||
|
||||
<method name="GetAllAccessPoints">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_all_access_points"/>
|
||||
<arg name="access_points" type="ao" direction="out">
|
||||
<tp:docstring>
|
||||
List of access point object paths.
|
||||
|
|
@ -33,8 +31,6 @@
|
|||
</method>
|
||||
|
||||
<method name="RequestScan">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_request_scan"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="options" type="a{sv}" direction="in">
|
||||
<tp:docstring>
|
||||
Options of scan (currently unused argument).
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
|
||||
<interface name="org.freedesktop.NetworkManager.Device.WiMax">
|
||||
<method name="GetNspList">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_nsp_list"/>
|
||||
<arg name="nsps" type="ao" direction="out">
|
||||
<tp:docstring>
|
||||
List of NSP object paths
|
||||
|
|
|
|||
|
|
@ -153,16 +153,12 @@
|
|||
</property>
|
||||
|
||||
<method name="Disconnect">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_disconnect"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Disconnects a device and prevents the device from automatically activating further connections without user intervention.
|
||||
</tp:docstring>
|
||||
</method>
|
||||
|
||||
<method name="Delete">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_delete"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Deletes a software device from NetworkManager and removes the interface from the system.
|
||||
The method returns an error when called for a hardware device.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@
|
|||
</tp:docstring>
|
||||
</property>
|
||||
<property name="Nameservers" type="aay" access="read">
|
||||
<!-- gdbus-codegen assumes that "aay" means "array of non-UTF-8
|
||||
string" and so would make this a char **.
|
||||
-->
|
||||
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="1"/>
|
||||
<tp:docstring>The nameservers in use.</tp:docstring>
|
||||
</property>
|
||||
<property name="Domains" type="as" access="read">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
<tp:docstring>
|
||||
Get the list of network devices.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_devices"/>
|
||||
<arg name="devices" type="ao" direction="out">
|
||||
<tp:docstring>
|
||||
List of object paths of network devices known to the system.
|
||||
|
|
@ -22,7 +21,6 @@
|
|||
interface name. Note that some devices (usually modems) only have an
|
||||
IP interface name when they are connected.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_device_by_ip_iface"/>
|
||||
<arg name="iface" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
Interface name of the device to find.
|
||||
|
|
@ -36,8 +34,6 @@
|
|||
</method>
|
||||
|
||||
<method name="ActivateConnection">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_activate_connection"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Activate a connection using the supplied device.
|
||||
</tp:docstring>
|
||||
|
|
@ -76,8 +72,6 @@
|
|||
</method>
|
||||
|
||||
<method name="AddAndActivateConnection">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_add_and_activate_connection"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Adds a new connection using the given details (if any) as a template
|
||||
(automatically filling in missing settings with the capabilities of the
|
||||
|
|
@ -121,8 +115,6 @@
|
|||
<tp:docstring>
|
||||
Deactivate an active connection.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="active_connection" type="o" direction="in">
|
||||
<tp:docstring>
|
||||
The currently active connection to deactivate.
|
||||
|
|
@ -131,8 +123,6 @@
|
|||
</method>
|
||||
|
||||
<method name="Sleep">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_sleep"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Control the NetworkManager daemon's sleep state. When asleep, all
|
||||
interfaces that it manages are deactivated. When awake, devices are
|
||||
|
|
@ -147,8 +137,6 @@
|
|||
</method>
|
||||
|
||||
<method name="Enable">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_enable"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Control whether overall networking is enabled or disabled. When
|
||||
disabled, all interfaces that NM manages are deactivated. When enabled,
|
||||
|
|
@ -165,8 +153,6 @@
|
|||
</method>
|
||||
|
||||
<method name="GetPermissions">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_permissions"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Returns the permissions a caller has for various authenticated operations
|
||||
that NetworkManager provides, like Enable/Disable networking, changing
|
||||
|
|
@ -193,8 +179,6 @@
|
|||
</signal>
|
||||
|
||||
<method name="SetLogging">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_set_logging"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Set logging verbosity and which operations are logged.
|
||||
</tp:docstring>
|
||||
|
|
@ -223,7 +207,6 @@
|
|||
</method>
|
||||
|
||||
<method name="GetLogging">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_logging"/>
|
||||
<tp:docstring>
|
||||
Get current logging verbosity level and operations domains.
|
||||
</tp:docstring>
|
||||
|
|
@ -240,8 +223,6 @@
|
|||
</method>
|
||||
|
||||
<method name="CheckConnectivity">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_check_connectivity"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<tp:docstring>
|
||||
Re-check the network connectivity state.
|
||||
</tp:docstring>
|
||||
|
|
@ -257,7 +238,6 @@
|
|||
The overall networking state as determined by the NetworkManager daemon,
|
||||
based on the state of network devices under it's management.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_state"/>
|
||||
<arg name="state" type="u" direction="out" tp:type="NM_STATE"/>
|
||||
</method>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,24 +5,19 @@
|
|||
<annotation name="org.gtk.GDBus.C.Name" value="PPP_Manager"/>
|
||||
|
||||
<method name="NeedSecrets">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_need_secrets"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="username" type="s" direction="out"/>
|
||||
<arg name="password" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="SetIp4Config">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_set_ip4_config"/>
|
||||
<arg name="config" type="a{sv}" direction="in"/>
|
||||
</method>
|
||||
|
||||
<method name="SetIp6Config">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_set_ip6_config"/>
|
||||
<arg name="config" type="a{sv}" direction="in"/>
|
||||
</method>
|
||||
|
||||
<method name="SetState">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ppp_manager_set_state"/>
|
||||
<arg name="state" type="u" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
stored in persistent storage or sent to a Secret Agent for storage,
|
||||
depending on the flags associated with each secret.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_update"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="properties" type="a{sa{sv}}" direction="in">
|
||||
<tp:docstring>
|
||||
New connection settings, properties, and (optionally) secrets.
|
||||
|
|
@ -37,8 +35,6 @@
|
|||
reloaded from disk (either automatically on file change or
|
||||
due to an explicit ReloadConnections call).
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_update_unsaved"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="properties" type="a{sa{sv}}" direction="in">
|
||||
<tp:docstring>
|
||||
New connection settings, properties, and (optionally) secrets.
|
||||
|
|
@ -50,8 +46,6 @@
|
|||
<tp:docstring>
|
||||
Delete the connection.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_delete"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
</method>
|
||||
|
||||
<method name="GetSettings">
|
||||
|
|
@ -61,8 +55,6 @@
|
|||
to the network, as those are often protected. Secrets must
|
||||
be requested separately using the GetSecrets() call.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_get_settings"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map">
|
||||
<tp:docstring>
|
||||
The nested settings maps describing this object.
|
||||
|
|
@ -77,8 +69,6 @@
|
|||
the requestor's session will be returned. The user will never
|
||||
be prompted for secrets as a result of this request.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_get_secrets"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="setting_name" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
Name of the setting to return secrets for. If empty, all
|
||||
|
|
@ -97,8 +87,6 @@
|
|||
<tp:docstring>
|
||||
Clear the secrets belonging to this network connection profile.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_clear_secrets"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
</method>
|
||||
|
||||
<method name="Save">
|
||||
|
|
@ -106,8 +94,6 @@
|
|||
Saves a "dirty" connection (that had previously been
|
||||
updated with UpdateUnsaved) to persistent storage.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_connection_save"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
</method>
|
||||
|
||||
<signal name="Updated">
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
<tp:docstring>
|
||||
List the saved network connections known to NetworkManager.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_list_connections"/>
|
||||
<arg name="connections" type="ao" direction="out">
|
||||
<tp:docstring>
|
||||
List of connections.
|
||||
|
|
@ -22,8 +21,6 @@
|
|||
<tp:docstring>
|
||||
Retrieve the object path of a connection, given that connection's UUID.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_get_connection_by_uuid"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="uuid" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
The UUID to find the connection object path for.
|
||||
|
|
@ -43,8 +40,6 @@
|
|||
the network described by the new connection, and (2) the connection
|
||||
is allowed to be started automatically.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="connection" type="a{sa{sv}}" direction="in">
|
||||
<tp:docstring>
|
||||
Connection settings and properties.
|
||||
|
|
@ -69,8 +64,6 @@
|
|||
connection is reloaded from disk (either automatically on file
|
||||
change or due to an explicit ReloadConnections call).
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection_unsaved"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="connection" type="a{sa{sv}}" direction="in">
|
||||
<tp:docstring>
|
||||
Connection settings and properties.
|
||||
|
|
@ -93,8 +86,6 @@
|
|||
harmless.) As with AddConnection(), this operation does not
|
||||
necessarily start the network connection.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_load_connections"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="filenames" type="as" direction="in">
|
||||
<tp:docstring>
|
||||
Array of paths to on-disk connection profiles in directories
|
||||
|
|
@ -125,8 +116,6 @@
|
|||
change, so you only need to use this command if you have set
|
||||
"monitor-connection-files=false" in NetworkManager.conf.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_reload_connections"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="status" type="b" direction="out">
|
||||
<tp:docstring>
|
||||
Success or failure.
|
||||
|
|
@ -138,8 +127,6 @@
|
|||
<tp:docstring>
|
||||
Save the hostname to persistent configuration.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_save_hostname"/>
|
||||
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||
<arg name="hostname" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
The hostname to save to persistent configuration. If blank, the persistent hostname is cleared.
|
||||
|
|
|
|||
|
|
@ -62,9 +62,11 @@ nodist_libnm_util_include_HEADERS = \
|
|||
|
||||
libnm_util_la_private_headers = \
|
||||
crypto.h \
|
||||
nm-dbus-glib-types.h \
|
||||
nm-gvaluearray-compat.h \
|
||||
nm-param-spec-specialized.h \
|
||||
nm-utils-private.h \
|
||||
nm-setting-private.h
|
||||
nm-setting-private.h \
|
||||
nm-utils-private.h
|
||||
|
||||
libnm_util_la_csources = \
|
||||
crypto.c \
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
|
||||
struct _NMParamSpecSpecialized {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <gmodule.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <nm-utils.h>
|
||||
#include "nm-default.h"
|
||||
#include "nm-gvaluearray-compat.h"
|
||||
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-setting-connection.h"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ endif
|
|||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/introspection \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
-I$(top_srcdir)/callouts \
|
||||
|
|
@ -190,7 +191,7 @@ nm_dhcp_client_headers = \
|
|||
dhcp-manager/nm-dhcp-dhcpcd.h \
|
||||
dhcp-manager/nm-dhcp-systemd.h
|
||||
|
||||
nm_sources = \
|
||||
libNetworkManager_la_SOURCES = \
|
||||
$(nm_device_headers) \
|
||||
$(nm_dhcp_client_headers) \
|
||||
devices/nm-device.c \
|
||||
|
|
@ -362,14 +363,14 @@ nm_sources = \
|
|||
|
||||
|
||||
if SUSPEND_RESUME_UPOWER
|
||||
nm_sources += nm-sleep-monitor-upower.c
|
||||
libNetworkManager_la_SOURCES += nm-sleep-monitor-upower.c
|
||||
else
|
||||
# systemd/consolekit suspend/resume used whenever upower is not enabled
|
||||
nm_sources += nm-sleep-monitor-systemd.c
|
||||
libNetworkManager_la_SOURCES += nm-sleep-monitor-systemd.c
|
||||
endif
|
||||
|
||||
if WITH_WEXT
|
||||
nm_sources += \
|
||||
libNetworkManager_la_SOURCES += \
|
||||
platform/wifi/wifi-utils-wext.c \
|
||||
platform/wifi/wifi-utils-wext.h
|
||||
endif
|
||||
|
|
@ -378,45 +379,11 @@ endif
|
|||
GLIB_GENERATED = nm-enum-types.h nm-enum-types.c
|
||||
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM --fhead '\#include <nm-core-enum-types.h>\n'
|
||||
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
|
||||
nm_enum_types_sources = $(nm_sources)
|
||||
nm_enum_types_sources = $(libNetworkManager_la_SOURCES)
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
|
||||
|
||||
glue_sources = \
|
||||
nm-access-point-glue.h \
|
||||
nm-active-connection-glue.h \
|
||||
nm-agent-manager-glue.h \
|
||||
nm-device-bond-glue.h \
|
||||
nm-device-bridge-glue.h \
|
||||
nm-device-ethernet-glue.h \
|
||||
nm-device-generic-glue.h \
|
||||
nm-device-glue.h \
|
||||
nm-device-gre-glue.h \
|
||||
nm-device-infiniband-glue.h \
|
||||
nm-device-macvlan-glue.h \
|
||||
nm-device-tun-glue.h \
|
||||
nm-device-veth-glue.h \
|
||||
nm-device-vlan-glue.h \
|
||||
nm-device-vxlan-glue.h \
|
||||
nm-dhcp4-config-glue.h \
|
||||
nm-dhcp6-config-glue.h \
|
||||
nm-ip4-config-glue.h \
|
||||
nm-ip6-config-glue.h \
|
||||
nm-manager-glue.h \
|
||||
nm-ppp-manager-glue.h \
|
||||
nm-settings-connection-glue.h \
|
||||
nm-settings-glue.h \
|
||||
nm-vpn-connection-glue.h
|
||||
|
||||
BUILT_SOURCES += $(glue_sources)
|
||||
|
||||
%-glue.h: $(top_srcdir)/introspection/%.xml
|
||||
$(AM_V_GEN) dbus-binding-tool --prefix=$(subst -,_,$(subst -glue.h,,$@)) --mode=glib-server --output=$@ $<
|
||||
|
||||
|
||||
AM_CPPFLAGS += \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(GUDEV_CFLAGS) \
|
||||
$(LIBNL_CFLAGS) \
|
||||
|
|
@ -450,14 +417,10 @@ AM_CPPFLAGS += \
|
|||
\
|
||||
$(NULL)
|
||||
|
||||
libNetworkManager_la_SOURCES = \
|
||||
$(nm_sources) \
|
||||
$(glue_sources)
|
||||
|
||||
libNetworkManager_la_LIBADD = \
|
||||
$(top_builddir)/libnm-core/libnm-core.la \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
libsystemd-nm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS) \
|
||||
$(LIBNL_LIBS) \
|
||||
|
|
@ -533,8 +496,8 @@ endif
|
|||
|
||||
libnm_iface_helper_la_LIBADD = \
|
||||
$(top_builddir)/libnm-core/libnm-core.la \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
libsystemd-nm.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS) \
|
||||
$(LIBNL_LIBS) \
|
||||
|
|
@ -555,7 +518,6 @@ nm_iface_helper_LDADD = \
|
|||
$(top_builddir)/libnm-core/libnm-core.la \
|
||||
libsystemd-nm.la \
|
||||
libnm-iface-helper.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS) \
|
||||
$(SYSTEMD_JOURNAL_LIBS) \
|
||||
|
|
@ -582,8 +544,4 @@ install-data-hook:
|
|||
$(mkinstalldirs) -m 0755 $(DESTDIR)$(pkglibdir)
|
||||
|
||||
CLEANFILES = \
|
||||
$(BUILT_SOURCES) \
|
||||
settings/*-glue.h \
|
||||
devices/*-glue.h \
|
||||
devices/*/*-glue.h
|
||||
|
||||
$(BUILT_SOURCES)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
/*
|
||||
* Some toolchains (E.G. uClibc 0.9.33 and earlier) don't export
|
||||
|
|
@ -2890,47 +2889,6 @@ nm_utils_ipv6_interface_identfier_get_from_addr (NMUtilsIPv6IfaceId *iid,
|
|||
memcpy (iid, addr->s6_addr + 8, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_connection_hash_to_dict:
|
||||
* @hash: a hashed #NMConnection
|
||||
*
|
||||
* Returns: a (floating) #GVariant equivalent to @hash.
|
||||
*/
|
||||
GVariant *
|
||||
nm_utils_connection_hash_to_dict (GHashTable *hash)
|
||||
{
|
||||
GValue val = { 0, };
|
||||
GVariant *variant;
|
||||
|
||||
if (!hash)
|
||||
return NULL;
|
||||
|
||||
g_value_init (&val, DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT);
|
||||
g_value_set_boxed (&val, hash);
|
||||
variant = dbus_g_value_build_g_variant (&val);
|
||||
g_value_unset (&val);
|
||||
|
||||
return variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_connection_dict_to_hash:
|
||||
* @dict: a #GVariant-serialized #NMConnection
|
||||
*
|
||||
* Returns: a #GHashTable equivalent to @dict.
|
||||
*/
|
||||
GHashTable *
|
||||
nm_utils_connection_dict_to_hash (GVariant *dict)
|
||||
{
|
||||
GValue val = { 0, };
|
||||
|
||||
if (!dict)
|
||||
return NULL;
|
||||
|
||||
dbus_g_value_parse_g_variant (dict, &val);
|
||||
return g_value_get_boxed (&val);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_setpgid:
|
||||
* @unused: unused
|
||||
|
|
@ -2963,9 +2921,9 @@ nm_utils_g_value_set_object_path (GValue *value, gpointer object)
|
|||
g_return_if_fail (!object || NM_IS_EXPORTED_OBJECT (object));
|
||||
|
||||
if (object && nm_exported_object_is_exported (object))
|
||||
g_value_set_boxed (value, nm_exported_object_get_path (object));
|
||||
g_value_set_string (value, nm_exported_object_get_path (object));
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2989,5 +2947,27 @@ nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects)
|
|||
continue;
|
||||
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (object)));
|
||||
}
|
||||
g_value_take_boxed (value, paths);
|
||||
g_ptr_array_add (paths, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (paths, FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_g_value_set_strv:
|
||||
* @value: a #GValue, initialized to store a #G_TYPE_STRV
|
||||
* @strings: a #GPtrArray of strings
|
||||
*
|
||||
* Converts @strings to a #GStrv and stores it in @value.
|
||||
*/
|
||||
void
|
||||
nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings)
|
||||
{
|
||||
char **strv;
|
||||
int i;
|
||||
|
||||
strv = g_new (char *, strings->len + 1);
|
||||
for (i = 0; i < strings->len; i++)
|
||||
strv[i] = g_strdup (strings->pdata[i]);
|
||||
strv[i] = NULL;
|
||||
|
||||
g_value_take_boxed (value, strv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,9 +224,6 @@ void nm_utils_ipv6_addr_set_interface_identfier (struct in6_addr *addr,
|
|||
void nm_utils_ipv6_interface_identfier_get_from_addr (NMUtilsIPv6IfaceId *iid,
|
||||
const struct in6_addr *addr);
|
||||
|
||||
GVariant *nm_utils_connection_hash_to_dict (GHashTable *hash);
|
||||
GHashTable *nm_utils_connection_dict_to_hash (GVariant *dict);
|
||||
|
||||
void nm_utils_array_remove_at_indexes (GArray *array, const guint *indexes_to_delete, gsize len);
|
||||
|
||||
void nm_utils_setpgid (gpointer unused);
|
||||
|
|
@ -253,5 +250,6 @@ void _nm_utils_set_testing (NMUtilsTestFlags flags);
|
|||
|
||||
void nm_utils_g_value_set_object_path (GValue *value, gpointer object);
|
||||
void nm_utils_g_value_set_object_path_array (GValue *value, GSList *objects);
|
||||
void nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings);
|
||||
|
||||
#endif /* __NETWORKMANAGER_UTILS_H__ */
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ AM_CPPFLAGS = \
|
|||
-I${top_builddir}/src \
|
||||
-I${top_srcdir}/src/devices \
|
||||
-I${top_srcdir}/src/platform \
|
||||
-I${top_builddir}/introspection \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-adsl"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GUDEV_CFLAGS)
|
||||
|
||||
GLIB_GENERATED = nm-adsl-enum-types.h nm-adsl-enum-types.c
|
||||
|
|
@ -21,10 +21,7 @@ GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
|
|||
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
|
||||
nm_adsl_enum_types_sources = $(srcdir)/nm-device-adsl.h
|
||||
|
||||
nm-device-adsl-glue.h: $(top_srcdir)/introspection/nm-device-adsl.xml
|
||||
dbus-binding-tool --prefix=nm_device_adsl --mode=glib-server --output=$@ $<
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED) nm-device-adsl-glue.h
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-device-plugin-adsl.la
|
||||
|
||||
|
|
@ -43,7 +40,7 @@ libnm_device_plugin_adsl_la_LDFLAGS = \
|
|||
-Wl,--version-script=$(SYMBOL_VIS_FILE)
|
||||
|
||||
libnm_device_plugin_adsl_la_LIBADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
$(GUDEV_LIBS)
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
#include "nm-setting-adsl.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-adsl-glue.h"
|
||||
#include "nmdbus-device-adsl.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF (NMDeviceAdsl);
|
||||
|
|
@ -613,5 +613,6 @@ nm_device_adsl_class_init (NMDeviceAdslClass *klass)
|
|||
parent_class->deactivate = deactivate;
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_adsl_object_info);
|
||||
NMDBUS_TYPE_DEVICE_ADSL_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,23 +9,21 @@ AM_CPPFLAGS = \
|
|||
-I${top_srcdir}/src/settings \
|
||||
-I${top_srcdir}/src/platform \
|
||||
-I${top_srcdir}/src/devices/wwan \
|
||||
-I${top_builddir}/introspection \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-bluetooth"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(DBUS_CFLAGS)
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
GLIB_GENERATED = nm-bt-enum-types.h nm-bt-enum-types.c
|
||||
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
|
||||
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
|
||||
nm_bt_enum_types_sources = $(srcdir)/nm-bt-error.h
|
||||
|
||||
nm-device-bt-glue.h: $(top_srcdir)/introspection/nm-device-bt.xml
|
||||
dbus-binding-tool --prefix=nm_device_bt --mode=glib-server --output=$@ $<
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED) nm-device-bt-glue.h
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-device-plugin-bluetooth.la
|
||||
|
||||
|
|
@ -56,8 +54,9 @@ libnm_device_plugin_bluetooth_la_LDFLAGS = \
|
|||
-Wl,--version-script=$(SYMBOL_VIS_FILE)
|
||||
|
||||
libnm_device_plugin_bluetooth_la_LIBADD = \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
$(top_builddir)/src/devices/wwan/libnm-wwan.la \
|
||||
$(DBUS_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS)
|
||||
|
||||
if WITH_BLUEZ5_DUN
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "nm-device-bt.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-compat.h"
|
||||
|
||||
typedef struct {
|
||||
int bluez_version;
|
||||
|
|
|
|||
|
|
@ -35,13 +35,14 @@
|
|||
#include "nm-setting-gsm.h"
|
||||
#include "nm-setting-serial.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
#include "nm-device-bt-glue.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-bt-enum-types.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-bt-error.h"
|
||||
#include "nm-bt-enum-types.h"
|
||||
|
||||
#include "nmdbus-device-bt.h"
|
||||
|
||||
#define MM_DBUS_SERVICE "org.freedesktop.ModemManager1"
|
||||
#define MM_DBUS_PATH "/org/freedesktop/ModemManager1"
|
||||
#define MM_DBUS_INTERFACE "org.freedesktop.ModemManager1"
|
||||
|
|
@ -1194,5 +1195,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
|
|||
G_TYPE_UINT, G_TYPE_UINT);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_bt_object_info);
|
||||
NMDBUS_TYPE_DEVICE_BLUETOOTH_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,12 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-device-factory.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-ip4-config.h"
|
||||
|
||||
#include "nm-device-bond-glue.h"
|
||||
#include "nmdbus-device-bond.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceBond);
|
||||
|
|
@ -556,12 +555,13 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_SLAVES,
|
||||
g_param_spec_boxed (NM_DEVICE_BOND_SLAVES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_bond_object_info);
|
||||
NMDBUS_TYPE_DEVICE_BOND_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -26,13 +26,12 @@
|
|||
#include "nm-device-bridge.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-bridge-glue.h"
|
||||
#include "nmdbus-device-bridge.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceBridge);
|
||||
|
|
@ -501,12 +500,13 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_SLAVES,
|
||||
g_param_spec_boxed (NM_DEVICE_BRIDGE_SLAVES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_bridge_object_info);
|
||||
NMDBUS_TYPE_DEVICE_BRIDGE_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
#include "nm-core-internal.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nm-device-ethernet-glue.h"
|
||||
#include "nmdbus-device-ethernet.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceEthernet);
|
||||
|
|
@ -1712,7 +1712,8 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_ethernet_object_info);
|
||||
NMDBUS_TYPE_DEVICE_ETHERNET_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-generic-glue.h"
|
||||
#include "nmdbus-device-generic.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE)
|
||||
|
||||
|
|
@ -202,5 +202,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_generic_object_info);
|
||||
NMDBUS_TYPE_DEVICE_GENERIC_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include "nm-device-factory.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-gre-glue.h"
|
||||
#include "nmdbus-device-gre.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceGre);
|
||||
|
|
@ -187,10 +187,10 @@ nm_device_gre_class_init (NMDeviceGreClass *klass)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PARENT,
|
||||
g_param_spec_boxed (NM_DEVICE_GRE_PARENT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_GRE_PARENT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_INPUT_FLAGS,
|
||||
|
|
@ -256,7 +256,8 @@ nm_device_gre_class_init (NMDeviceGreClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_gre_object_info);
|
||||
NMDBUS_TYPE_DEVICE_GRE_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include "nm-device-factory.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-infiniband-glue.h"
|
||||
#include "nmdbus-device-infiniband.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE)
|
||||
|
||||
|
|
@ -350,7 +350,8 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_infiniband_object_info);
|
||||
NMDBUS_TYPE_DEVICE_INFINIBAND_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-macvlan-glue.h"
|
||||
#include "nmdbus-device-macvlan.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceMacvlan);
|
||||
|
|
@ -144,10 +144,10 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PARENT,
|
||||
g_param_spec_boxed (NM_DEVICE_MACVLAN_PARENT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_MACVLAN_PARENT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MODE,
|
||||
|
|
@ -164,7 +164,8 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_macvlan_object_info);
|
||||
NMDBUS_TYPE_DEVICE_MACVLAN_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-tun-glue.h"
|
||||
#include "nmdbus-device-tun.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceTun);
|
||||
|
|
@ -232,7 +232,8 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_tun_object_info);
|
||||
NMDBUS_TYPE_DEVICE_TUN_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-veth-glue.h"
|
||||
#include "nmdbus-device-veth.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceVeth);
|
||||
|
|
@ -160,13 +160,14 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PEER,
|
||||
g_param_spec_boxed (NM_DEVICE_VETH_PEER, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_VETH_PEER, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_veth_object_info);
|
||||
NMDBUS_TYPE_DEVICE_VETH_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#include "nm-manager.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-vlan-glue.h"
|
||||
#include "nmdbus-device-vlan.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceVlan);
|
||||
|
|
@ -617,10 +617,10 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PARENT,
|
||||
g_param_spec_boxed (NM_DEVICE_VLAN_PARENT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_VLAN_PARENT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VLAN_ID,
|
||||
g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "",
|
||||
|
|
@ -628,7 +628,8 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_vlan_object_info);
|
||||
NMDBUS_TYPE_DEVICE_VLAN_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include "nm-utils.h"
|
||||
#include "nm-device-factory.h"
|
||||
|
||||
#include "nm-device-vxlan-glue.h"
|
||||
#include "nmdbus-device-vxlan.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceVxlan);
|
||||
|
|
@ -234,10 +234,10 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PARENT,
|
||||
g_param_spec_boxed (NM_DEVICE_VXLAN_PARENT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_VXLAN_PARENT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ID,
|
||||
|
|
@ -345,7 +345,8 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_vxlan_object_info);
|
||||
NMDBUS_TYPE_DEVICE_VXLAN_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -55,7 +54,6 @@
|
|||
#include "nm-settings-connection.h"
|
||||
#include "nm-connection-provider.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-dispatcher.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-dns-manager.h"
|
||||
|
|
@ -68,13 +66,11 @@
|
|||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF (NMDevice);
|
||||
|
||||
static void impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context);
|
||||
static void impl_device_delete (NMDevice *self, DBusGMethodInvocation *context);
|
||||
#include "nmdbus-device.h"
|
||||
|
||||
static void nm_device_update_metered (NMDevice *self);
|
||||
static void ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data);
|
||||
|
||||
#include "nm-device-glue.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
||||
|
|
@ -6178,7 +6174,7 @@ delete_on_deactivate_check_and_schedule (NMDevice *self, int ifindex)
|
|||
|
||||
static void
|
||||
disconnect_cb (NMDevice *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
|
|
@ -6187,7 +6183,7 @@ disconnect_cb (NMDevice *self,
|
|||
GError *local = NULL;
|
||||
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, subject, error->message);
|
||||
return;
|
||||
}
|
||||
|
|
@ -6197,16 +6193,15 @@ disconnect_cb (NMDevice *self,
|
|||
local = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ACTIVE,
|
||||
"Device is not active");
|
||||
dbus_g_method_return_error (context, local);
|
||||
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, subject, local->message);
|
||||
g_error_free (local);
|
||||
g_dbus_method_invocation_take_error (context, local);
|
||||
} else {
|
||||
nm_device_set_autoconnect (self, FALSE);
|
||||
|
||||
nm_device_state_changed (self,
|
||||
NM_DEVICE_STATE_DEACTIVATING,
|
||||
NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, TRUE, subject, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -6221,7 +6216,7 @@ _clear_queued_act_request (NMDevicePrivate *priv)
|
|||
}
|
||||
|
||||
static void
|
||||
impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context)
|
||||
impl_device_disconnect (NMDevice *self, GDBusMethodInvocation *context)
|
||||
{
|
||||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
|
@ -6230,8 +6225,7 @@ impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context)
|
|||
error = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ACTIVE,
|
||||
"This device is not active");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -6250,25 +6244,25 @@ impl_device_disconnect (NMDevice *self, DBusGMethodInvocation *context)
|
|||
|
||||
static void
|
||||
delete_cb (NMDevice *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, FALSE, subject, error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Authorized */
|
||||
nm_platform_link_delete (NM_PLATFORM_GET, nm_device_get_ifindex (self));
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, TRUE, subject, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_device_delete (NMDevice *self, DBusGMethodInvocation *context)
|
||||
impl_device_delete (NMDevice *self, GDBusMethodInvocation *context)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
|
|
@ -6276,8 +6270,7 @@ impl_device_delete (NMDevice *self, DBusGMethodInvocation *context)
|
|||
error = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_SOFTWARE,
|
||||
"This device is not a software device");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -9311,8 +9304,6 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
#define DBUS_TYPE_STATE_REASON_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID))
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -9376,8 +9367,8 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->state);
|
||||
break;
|
||||
case PROP_STATE_REASON:
|
||||
g_value_take_boxed (value, dbus_g_type_specialized_construct (DBUS_TYPE_STATE_REASON_STRUCT));
|
||||
dbus_g_type_struct_set (value, 0, priv->state, 1, priv->state_reason, G_MAXUINT);
|
||||
g_value_take_variant (value,
|
||||
g_variant_new ("(uu)", priv->state, priv->state_reason));
|
||||
break;
|
||||
case PROP_ACTIVE_CONNECTION:
|
||||
nm_utils_g_value_set_object_path (value, priv->act_request);
|
||||
|
|
@ -9408,7 +9399,8 @@ get_property (GObject *object, guint prop_id,
|
|||
g_hash_table_iter_init (&iter, priv->available_connections);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &connection, NULL))
|
||||
g_ptr_array_add (array, g_strdup (nm_connection_get_path (connection)));
|
||||
g_value_take_boxed (value, array);
|
||||
g_ptr_array_add (array, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
|
||||
break;
|
||||
case PROP_PHYSICAL_PORT_ID:
|
||||
g_value_set_string (value, priv->physical_port_id);
|
||||
|
|
@ -9548,31 +9540,31 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP4_CONFIG,
|
||||
g_param_spec_boxed (NM_DEVICE_IP4_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_IP4_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP4_CONFIG,
|
||||
g_param_spec_boxed (NM_DEVICE_DHCP4_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_DHCP4_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP6_CONFIG,
|
||||
g_param_spec_boxed (NM_DEVICE_IP6_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_IP6_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP6_CONFIG,
|
||||
g_param_spec_boxed (NM_DEVICE_DHCP6_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_DHCP6_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_STATE,
|
||||
|
|
@ -9583,17 +9575,18 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_STATE_REASON,
|
||||
g_param_spec_boxed (NM_DEVICE_STATE_REASON, "", "",
|
||||
DBUS_TYPE_STATE_REASON_STRUCT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_variant (NM_DEVICE_STATE_REASON, "", "",
|
||||
G_VARIANT_TYPE ("(uu)"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ACTIVE_CONNECTION,
|
||||
g_param_spec_boxed (NM_DEVICE_ACTIVE_CONNECTION, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_ACTIVE_CONNECTION, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DEVICE_TYPE,
|
||||
|
|
@ -9656,7 +9649,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_AVAILABLE_CONNECTIONS,
|
||||
g_param_spec_boxed (NM_DEVICE_AVAILABLE_CONNECTIONS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
|
@ -9732,8 +9725,8 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL,
|
||||
/* dbus-glib context, connection, permission, allow_interaction, callback, user_data */
|
||||
G_TYPE_NONE, 6, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);
|
||||
/* context, connection, permission, allow_interaction, callback, user_data */
|
||||
G_TYPE_NONE, 6, G_TYPE_DBUS_METHOD_INVOCATION, NM_TYPE_CONNECTION, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);
|
||||
|
||||
signals[IP4_CONFIG_CHANGED] =
|
||||
g_signal_new (NM_DEVICE_IP4_CONFIG_CHANGED,
|
||||
|
|
@ -9771,7 +9764,8 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
G_TYPE_NONE, 0);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_object_info);
|
||||
|
||||
dbus_g_error_domain_register (NM_DEVICE_ERROR, NULL, NM_TYPE_DEVICE_ERROR);
|
||||
NMDBUS_TYPE_DEVICE_SKELETON,
|
||||
"Disconnect", impl_device_disconnect,
|
||||
"Delete", impl_device_delete,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef __NETWORKMANAGER_DEVICE_H__
|
||||
#define __NETWORKMANAGER_DEVICE_H__
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "nm-exported-object.h"
|
||||
|
|
@ -310,7 +309,7 @@ typedef struct {
|
|||
} NMDeviceClass;
|
||||
|
||||
typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ AM_CPPFLAGS = \
|
|||
-I${top_builddir}/src \
|
||||
-I${top_srcdir}/src/devices \
|
||||
-I${top_srcdir}/src/platform \
|
||||
-I${top_builddir}/introspection \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-team"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(DBUS_CFLAGS)
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
if WITH_TEAMDCTL
|
||||
AM_CPPFLAGS += ${LIBTEAMDCTL_CFLAGS}
|
||||
|
|
@ -24,13 +25,7 @@ GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
|
|||
GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
|
||||
nm_team_enum_types_sources = $(srcdir)/nm-device-team.h
|
||||
|
||||
glue_sources = \
|
||||
nm-device-team-glue.h
|
||||
|
||||
%-glue.h: $(top_srcdir)/introspection/%.xml
|
||||
$(AM_V_GEN) dbus-binding-tool --prefix=$(subst -,_,$(subst -glue.h,,$@)) --mode=glib-server --output=$@ $<
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED) $(glue_sources)
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-device-plugin-team.la
|
||||
|
||||
|
|
@ -49,7 +44,8 @@ libnm_device_plugin_team_la_LDFLAGS = \
|
|||
-Wl,--version-script=$(SYMBOL_VIS_FILE)
|
||||
|
||||
libnm_device_plugin_team_la_LIBADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS)
|
||||
|
||||
if WITH_TEAMDCTL
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-team-enum-types.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-dbus-compat.h"
|
||||
|
||||
#include "nm-device-team-glue.h"
|
||||
#include "nmdbus-device-team.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceTeam);
|
||||
|
|
@ -809,11 +809,12 @@ nm_device_team_class_init (NMDeviceTeamClass *klass)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_SLAVES,
|
||||
g_param_spec_boxed (NM_DEVICE_TEAM_SLAVES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_team_object_info);
|
||||
NMDBUS_TYPE_DEVICE_TEAM_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ AM_CPPFLAGS = \
|
|||
-I${top_srcdir}/src/settings \
|
||||
-I${top_srcdir}/src/platform \
|
||||
-I${top_srcdir}/src/supplicant-manager \
|
||||
-I${top_builddir}/introspection \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(DBUS_CFLAGS)
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
GLIB_GENERATED = nm-wifi-enum-types.h nm-wifi-enum-types.c
|
||||
GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
|
||||
|
|
@ -29,14 +30,7 @@ nm_wifi_enum_types_sources = \
|
|||
$(srcdir)/nm-wifi-ap.h \
|
||||
$(srcdir)/nm-device-olpc-mesh.h
|
||||
|
||||
glue_sources = \
|
||||
nm-device-wifi-glue.h \
|
||||
nm-device-olpc-mesh-glue.h
|
||||
|
||||
%-glue.h: $(top_srcdir)/introspection/%.xml
|
||||
$(AM_V_GEN) dbus-binding-tool --prefix=$(subst -,_,$(subst -glue.h,,$@)) --mode=glib-server --output=$@ $<
|
||||
|
||||
BUILT_SOURCES = $(GLIB_GENERATED) $(glue_sources)
|
||||
BUILT_SOURCES = $(GLIB_GENERATED)
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-device-plugin-wifi.la
|
||||
|
||||
|
|
@ -60,7 +54,8 @@ libnm_device_plugin_wifi_la_LDFLAGS = \
|
|||
-Wl,--version-script=$(SYMBOL_VIS_FILE)
|
||||
|
||||
libnm_device_plugin_wifi_la_LIBADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(GUDEV_LIBS)
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -54,7 +53,7 @@
|
|||
/* This is a bug; but we can't really change API now... */
|
||||
#include "nm-vpn-dbus-interface.h"
|
||||
|
||||
#include "nm-device-olpc-mesh-glue.h"
|
||||
#include "nmdbus-device-olpc-mesh.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceOlpcMesh);
|
||||
|
|
@ -531,10 +530,10 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
|
|||
/* Properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_COMPANION,
|
||||
g_param_spec_boxed (NM_DEVICE_OLPC_MESH_COMPANION, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_OLPC_MESH_COMPANION, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ACTIVE_CHANNEL,
|
||||
|
|
@ -544,6 +543,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_olpc_mesh_object_info);
|
||||
NMDBUS_TYPE_DEVICE_OLPC_MESH_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -48,23 +47,10 @@
|
|||
#include "nm-auth-utils.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-wifi-enum-types.h"
|
||||
#include "nm-connection-provider.h"
|
||||
|
||||
static gboolean impl_device_get_access_points (NMDeviceWifi *device,
|
||||
GPtrArray **aps,
|
||||
GError **err);
|
||||
|
||||
static gboolean impl_device_get_all_access_points (NMDeviceWifi *device,
|
||||
GPtrArray **aps,
|
||||
GError **err);
|
||||
|
||||
static void impl_device_request_scan (NMDeviceWifi *device,
|
||||
GHashTable *options,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
#include "nm-device-wifi-glue.h"
|
||||
#include "nmdbus-device-wifi.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceWifi);
|
||||
|
|
@ -1017,102 +1003,108 @@ get_sorted_ap_list (NMDeviceWifi *self)
|
|||
return g_slist_sort (sorted, (GCompareFunc) ap_id_compare);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_device_get_access_points (NMDeviceWifi *self,
|
||||
GPtrArray **aps,
|
||||
GError **err)
|
||||
static void
|
||||
impl_device_wifi_get_access_points (NMDeviceWifi *self,
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
GSList *sorted, *iter;
|
||||
GPtrArray *paths;
|
||||
|
||||
*aps = g_ptr_array_new ();
|
||||
paths = g_ptr_array_new ();
|
||||
sorted = get_sorted_ap_list (self);
|
||||
for (iter = sorted; iter; iter = iter->next) {
|
||||
NMAccessPoint *ap = NM_AP (iter->data);
|
||||
|
||||
if (nm_ap_get_ssid (ap))
|
||||
g_ptr_array_add (*aps, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
|
||||
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (ap))));
|
||||
}
|
||||
g_ptr_array_add (paths, NULL);
|
||||
g_slist_free (sorted);
|
||||
return TRUE;
|
||||
|
||||
g_dbus_method_invocation_return_value (context, g_variant_new ("(^ao)", (char **) paths->pdata));
|
||||
g_ptr_array_unref (paths);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_device_get_all_access_points (NMDeviceWifi *self,
|
||||
GPtrArray **aps,
|
||||
GError **err)
|
||||
static void
|
||||
impl_device_wifi_get_all_access_points (NMDeviceWifi *self,
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
GSList *sorted, *iter;
|
||||
GPtrArray *paths;
|
||||
|
||||
*aps = g_ptr_array_new ();
|
||||
paths = g_ptr_array_new ();
|
||||
sorted = get_sorted_ap_list (self);
|
||||
for (iter = sorted; iter; iter = iter->next)
|
||||
g_ptr_array_add (*aps, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (iter->data))));
|
||||
g_ptr_array_add (paths, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (iter->data))));
|
||||
g_ptr_array_add (paths, NULL);
|
||||
g_slist_free (sorted);
|
||||
return TRUE;
|
||||
|
||||
g_dbus_method_invocation_return_value (context, g_variant_new ("(^ao)", (char **) paths->pdata));
|
||||
g_ptr_array_unref (paths);
|
||||
}
|
||||
|
||||
static void
|
||||
request_scan_cb (NMDevice *device,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
||||
GError *local = NULL;
|
||||
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!check_scanning_allowed (self)) {
|
||||
local = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed at this time");
|
||||
dbus_g_method_return_error (context, local);
|
||||
g_error_free (local);
|
||||
g_dbus_method_invocation_return_error_literal (context,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed at this time");
|
||||
return;
|
||||
}
|
||||
|
||||
cancel_pending_scan (self);
|
||||
request_wireless_scan (self);
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_device_request_scan (NMDeviceWifi *self,
|
||||
GHashTable *options,
|
||||
DBusGMethodInvocation *context)
|
||||
impl_device_wifi_request_scan (NMDeviceWifi *self,
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *options)
|
||||
{
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMDevice *device = NM_DEVICE (self);
|
||||
gint32 last_scan;
|
||||
GError *error;
|
||||
|
||||
if ( !priv->enabled
|
||||
|| !priv->sup_iface
|
||||
|| nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED
|
||||
|| nm_device_is_activating (device)) {
|
||||
error = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed while unavailable or activating");
|
||||
goto error;
|
||||
g_dbus_method_invocation_return_error_literal (context,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed while unavailable or activating");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nm_supplicant_interface_get_scanning (priv->sup_iface)) {
|
||||
error = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed while already scanning");
|
||||
goto error;
|
||||
g_dbus_method_invocation_return_error_literal (context,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed while already scanning");
|
||||
return;
|
||||
}
|
||||
|
||||
last_scan = nm_supplicant_interface_get_last_scan_time (priv->sup_iface);
|
||||
if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) {
|
||||
error = g_error_new_literal (NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed immediately following previous scan");
|
||||
goto error;
|
||||
g_dbus_method_invocation_return_error_literal (context,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_NOT_ALLOWED,
|
||||
"Scanning not allowed immediately following previous scan");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ask the manager to authenticate this request for us */
|
||||
|
|
@ -1124,11 +1116,6 @@ impl_device_request_scan (NMDeviceWifi *self,
|
|||
TRUE,
|
||||
request_scan_cb,
|
||||
NULL);
|
||||
return;
|
||||
|
||||
error:
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -2922,11 +2909,12 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->capabilities);
|
||||
break;
|
||||
case PROP_ACCESS_POINTS:
|
||||
array = g_ptr_array_sized_new (g_hash_table_size (priv->aps));
|
||||
array = g_ptr_array_sized_new (g_hash_table_size (priv->aps) + 1);
|
||||
g_hash_table_iter_init (&iter, priv->aps);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &dbus_path, NULL))
|
||||
g_ptr_array_add (array, g_strdup (dbus_path));
|
||||
g_value_take_boxed (value, array);
|
||||
g_ptr_array_add (array, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
|
||||
break;
|
||||
case PROP_ACTIVE_ACCESS_POINT:
|
||||
nm_utils_g_value_set_object_path (value, priv->current_ap);
|
||||
|
|
@ -3011,16 +2999,16 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_ACCESS_POINTS,
|
||||
g_param_spec_boxed (NM_DEVICE_WIFI_ACCESS_POINTS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ACTIVE_ACCESS_POINT,
|
||||
g_param_spec_boxed (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CAPABILITIES,
|
||||
|
|
@ -3044,7 +3032,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
G_STRUCT_OFFSET (NMDeviceWifiClass, access_point_added),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
NM_TYPE_AP);
|
||||
|
||||
signals[ACCESS_POINT_REMOVED] =
|
||||
g_signal_new ("access-point-removed",
|
||||
|
|
@ -3053,7 +3041,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
NM_TYPE_AP);
|
||||
|
||||
signals[SCANNING_ALLOWED] =
|
||||
g_signal_new ("scanning-allowed",
|
||||
|
|
@ -3064,7 +3052,11 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
|
|||
G_TYPE_BOOLEAN, 0);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
||||
&dbus_glib_nm_device_wifi_object_info);
|
||||
NMDBUS_TYPE_DEVICE_WIFI_SKELETON,
|
||||
"GetAccessPoints", impl_device_wifi_get_access_points,
|
||||
"GetAllAccessPoints", impl_device_wifi_get_all_access_points,
|
||||
"RequestScan", impl_device_wifi_request_scan,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "nm-setting-wireless.h"
|
||||
|
||||
#include "nm-access-point-glue.h"
|
||||
#include "nmdbus-access-point.h"
|
||||
|
||||
/*
|
||||
* Encapsulates Access Point information
|
||||
|
|
@ -46,7 +46,7 @@ typedef struct
|
|||
GByteArray * ssid;
|
||||
char * address;
|
||||
NM80211Mode mode;
|
||||
gint8 strength;
|
||||
guint8 strength;
|
||||
guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
|
||||
guint32 max_bitrate;/* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */
|
||||
|
||||
|
|
@ -902,9 +902,7 @@ get_property (GObject *object, guint prop_id,
|
|||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
||||
GArray * ssid;
|
||||
int len;
|
||||
int i;
|
||||
GVariant *ssid;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FLAGS:
|
||||
|
|
@ -917,12 +915,12 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->rsn_flags);
|
||||
break;
|
||||
case PROP_SSID:
|
||||
len = priv->ssid ? priv->ssid->len : 0;
|
||||
ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), len);
|
||||
for (i = 0; i < len; i++)
|
||||
g_array_append_val (ssid, priv->ssid->data[i]);
|
||||
g_value_set_boxed (value, ssid);
|
||||
g_array_free (ssid, TRUE);
|
||||
if (priv->ssid) {
|
||||
ssid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
priv->ssid->data, priv->ssid->len, 1);
|
||||
} else
|
||||
ssid = g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0);
|
||||
g_value_take_variant (value, ssid);
|
||||
break;
|
||||
case PROP_FREQUENCY:
|
||||
g_value_set_uint (value, priv->freq);
|
||||
|
|
@ -937,7 +935,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->max_bitrate);
|
||||
break;
|
||||
case PROP_STRENGTH:
|
||||
g_value_set_schar (value, priv->strength);
|
||||
g_value_set_uchar (value, priv->strength);
|
||||
break;
|
||||
case PROP_LAST_SEEN:
|
||||
g_value_set_int (value,
|
||||
|
|
@ -1004,9 +1002,10 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SSID,
|
||||
g_param_spec_boxed (NM_AP_SSID, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_variant (NM_AP_SSID, "", "",
|
||||
G_VARIANT_TYPE ("ay"),
|
||||
NULL,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_FREQUENCY,
|
||||
|
|
@ -1034,9 +1033,9 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_STRENGTH,
|
||||
g_param_spec_char (NM_AP_STRENGTH, "", "",
|
||||
G_MININT8, G_MAXINT8, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_uchar (NM_AP_STRENGTH, "", "",
|
||||
0, G_MAXINT8, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LAST_SEEN,
|
||||
|
|
@ -1045,6 +1044,7 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
|
|||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (ap_class),
|
||||
&dbus_glib_nm_access_point_object_info);
|
||||
NMDBUS_TYPE_ACCESS_POINT_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir)/introspection \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-core \
|
||||
-I$(top_builddir)/libnm-core \
|
||||
|
|
@ -9,8 +10,7 @@ AM_CPPFLAGS = \
|
|||
-DG_LOG_DOMAIN=\""NetworkManager-wifi"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
noinst_PROGRAMS = test-wifi-ap-utils
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "nm-default.h"
|
||||
#include "nm-wifi-ap-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@ AM_CPPFLAGS = \
|
|||
-I${top_srcdir}/src/devices \
|
||||
-I${top_srcdir}/src/settings \
|
||||
-I${top_srcdir}/src/platform \
|
||||
-I${top_builddir}/introspection \
|
||||
-I${top_srcdir}/include \
|
||||
-I${top_builddir}/libnm-core \
|
||||
-I${top_srcdir}/libnm-core \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-wwan"\" \
|
||||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(MM_GLIB_CFLAGS)
|
||||
|
||||
BUILT_SOURCES = $(null)
|
||||
|
|
@ -45,31 +46,29 @@ WWAN_SYMBOL_VIS_FILE=$(srcdir)/wwan-exports.ver
|
|||
libnm_wwan_la_LDFLAGS = \
|
||||
-avoid-version \
|
||||
-Wl,--version-script=$(WWAN_SYMBOL_VIS_FILE)
|
||||
libnm_wwan_la_LIBADD = $(DBUS_LIBS) $(MM_GLIB_LIBS)
|
||||
libnm_wwan_la_LIBADD = \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(MM_GLIB_LIBS)
|
||||
|
||||
###########################################################
|
||||
|
||||
nm-device-modem-glue.h: $(top_srcdir)/introspection/nm-device-modem.xml
|
||||
dbus-binding-tool --prefix=nm_device_modem --mode=glib-server --output=$@ $<
|
||||
|
||||
BUILT_SOURCES += nm-device-modem-glue.h
|
||||
|
||||
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
|
||||
|
||||
libnm_device_plugin_wwan_la_SOURCES = \
|
||||
nm-wwan-factory.c \
|
||||
nm-wwan-factory.h \
|
||||
nm-device-modem.c \
|
||||
nm-device-modem.h \
|
||||
nm-device-modem-glue.h
|
||||
nm-device-modem.h
|
||||
|
||||
libnm_device_plugin_wwan_la_LDFLAGS = \
|
||||
-module -avoid-version \
|
||||
-Wl,--version-script=$(SYMBOL_VIS_FILE)
|
||||
|
||||
libnm_device_plugin_wwan_la_LIBADD = \
|
||||
$(top_builddir)/introspection/libnmdbus.la \
|
||||
libnm-wwan.la \
|
||||
$(DBUS_LIBS)
|
||||
$(GLIB_LIBS)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceModem);
|
||||
|
||||
#include "nmdbus-device-modem.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceModem, nm_device_modem, NM_TYPE_DEVICE)
|
||||
|
||||
#define NM_DEVICE_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MODEM, NMDeviceModemPrivate))
|
||||
|
||||
#include "nm-device-modem-glue.h"
|
||||
|
||||
typedef struct {
|
||||
NMModem *modem;
|
||||
NMDeviceModemCapabilities caps;
|
||||
|
|
@ -794,5 +794,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
|
|||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (mclass),
|
||||
&dbus_glib_nm_device_modem_object_info);
|
||||
NMDBUS_TYPE_DEVICE_MODEM_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "nm-default.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-modem-enum-types.h"
|
||||
#include "nm-route-manager.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,15 +12,3 @@ nm_dhcp_helper_CPPFLAGS = \
|
|||
-DNMRUNDIR=\"$(nmrundir)\"
|
||||
|
||||
nm_dhcp_helper_LDADD = $(GLIB_LIBS)
|
||||
|
||||
|
||||
# FIXME: remove when dbus-glib >= 0.100 or GDBus is required
|
||||
dhcp_helper_conf = nm-dhcp-helper.conf
|
||||
|
||||
if !HAVE_DBUS_GLIB_100
|
||||
dbusservicedir = $(DBUS_SYS_DIR)
|
||||
dbusservice_DATA = $(dhcp_helper_conf)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(dhcp_helper_conf)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include "nm-default.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-dhcp-client.h"
|
||||
#include "nm-dhcp-utils.h"
|
||||
#include "nm-platform.h"
|
||||
|
|
@ -648,21 +647,25 @@ nm_dhcp_client_stop (NMDhcpClient *self, gboolean release)
|
|||
/********************************************/
|
||||
|
||||
static char *
|
||||
garray_to_string (GArray *array, const char *key)
|
||||
bytearray_variant_to_string (GVariant *value, const char *key)
|
||||
{
|
||||
const guint8 *array;
|
||||
gsize length;
|
||||
GString *str;
|
||||
int i;
|
||||
unsigned char c;
|
||||
char *converted = NULL;
|
||||
|
||||
g_return_val_if_fail (array != NULL, NULL);
|
||||
g_return_val_if_fail (value != NULL, NULL);
|
||||
|
||||
array = g_variant_get_fixed_array (value, &length, 1);
|
||||
|
||||
/* Since the DHCP options come through environment variables, they should
|
||||
* already be UTF-8 safe, but just make sure.
|
||||
*/
|
||||
str = g_string_sized_new (array->len);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
c = array->data[i];
|
||||
str = g_string_sized_new (length);
|
||||
for (i = 0; i < length; i++) {
|
||||
c = array[i];
|
||||
|
||||
/* Convert NULLs to spaces and non-ASCII characters to ? */
|
||||
if (c == '\0')
|
||||
|
|
@ -684,11 +687,10 @@ garray_to_string (GArray *array, const char *key)
|
|||
#define NEW_TAG "new_"
|
||||
|
||||
static void
|
||||
copy_option (const char * key,
|
||||
GValue *value,
|
||||
gpointer user_data)
|
||||
maybe_add_option (GHashTable *hash,
|
||||
const char *key,
|
||||
GVariant *value)
|
||||
{
|
||||
GHashTable *hash = user_data;
|
||||
char *str_value = NULL;
|
||||
const char **p;
|
||||
static const char *ignored_keys[] = {
|
||||
|
|
@ -699,10 +701,7 @@ copy_option (const char * key,
|
|||
NULL
|
||||
};
|
||||
|
||||
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_UCHAR_ARRAY)) {
|
||||
nm_log_warn (LOGD_DHCP, "key %s value type was not DBUS_TYPE_G_UCHAR_ARRAY", key);
|
||||
return;
|
||||
}
|
||||
g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING));
|
||||
|
||||
if (g_str_has_prefix (key, OLD_TAG))
|
||||
return;
|
||||
|
|
@ -718,7 +717,7 @@ copy_option (const char * key,
|
|||
if (!key[0])
|
||||
return;
|
||||
|
||||
str_value = garray_to_string ((GArray *) g_value_get_boxed (value), key);
|
||||
str_value = bytearray_variant_to_string (value, key);
|
||||
if (str_value)
|
||||
g_hash_table_insert (hash, g_strdup (key), str_value);
|
||||
}
|
||||
|
|
@ -727,7 +726,7 @@ gboolean
|
|||
nm_dhcp_client_handle_event (gpointer unused,
|
||||
const char *iface,
|
||||
gint pid,
|
||||
GHashTable *options,
|
||||
GVariant *options,
|
||||
const char *reason,
|
||||
NMDhcpClient *self)
|
||||
{
|
||||
|
|
@ -740,7 +739,7 @@ nm_dhcp_client_handle_event (gpointer unused,
|
|||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
|
||||
g_return_val_if_fail (iface != NULL, FALSE);
|
||||
g_return_val_if_fail (pid > 0, FALSE);
|
||||
g_return_val_if_fail (options != NULL, FALSE);
|
||||
g_return_val_if_fail (g_variant_is_of_type (options, G_VARIANT_TYPE_VARDICT), FALSE);
|
||||
g_return_val_if_fail (reason != NULL, FALSE);
|
||||
|
||||
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
|
||||
|
|
@ -756,9 +755,17 @@ nm_dhcp_client_handle_event (gpointer unused,
|
|||
iface, reason, state_to_string (new_state));
|
||||
|
||||
if (new_state == NM_DHCP_STATE_BOUND) {
|
||||
GVariantIter iter;
|
||||
const char *name;
|
||||
GVariant *value;
|
||||
|
||||
/* Copy options */
|
||||
str_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
g_hash_table_foreach (options, (GHFunc) copy_option, str_options);
|
||||
g_variant_iter_init (&iter, options);
|
||||
while (g_variant_iter_next (&iter, "{&sv}", &name, &value)) {
|
||||
maybe_add_option (str_options, name, value);
|
||||
g_variant_unref (value);
|
||||
}
|
||||
|
||||
/* Create the IP config */
|
||||
g_warn_if_fail (g_hash_table_size (str_options));
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void nm_dhcp_client_set_state (NMDhcpClient *self,
|
|||
gboolean nm_dhcp_client_handle_event (gpointer unused,
|
||||
const char *iface,
|
||||
gint pid,
|
||||
GHashTable *options,
|
||||
GVariant *options,
|
||||
const char *reason,
|
||||
NMDhcpClient *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,69 +75,6 @@ build_signal_parameters (void)
|
|||
return g_variant_new ("(a{sv})", &builder);
|
||||
}
|
||||
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
/* It doesn't matter that nm-dhcp-helper doesn't use dbus-glib itself; the
|
||||
* workaround code is for if the daemon is built with old dbus-glib.
|
||||
*/
|
||||
|
||||
static gboolean ever_acquired = FALSE;
|
||||
|
||||
static void
|
||||
on_name_acquired (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
GMainLoop *loop = user_data;
|
||||
|
||||
ever_acquired = TRUE;
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
static void
|
||||
on_name_lost (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (ever_acquired) {
|
||||
g_print ("Lost D-Bus name: exiting\n");
|
||||
exit (0);
|
||||
} else {
|
||||
g_printerr ("Error: Could not acquire the NM DHCP client service.\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
static GDBusConnection *
|
||||
shared_connection_init (void)
|
||||
{
|
||||
GDBusConnection *connection;
|
||||
GError *error = NULL;
|
||||
GMainLoop *loop;
|
||||
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!connection) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
g_printerr ("Error: could not get the system bus. Make sure "
|
||||
"the message bus daemon is running! Message: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
g_bus_own_name_on_connection (connection,
|
||||
"org.freedesktop.nm_dhcp_client",
|
||||
0,
|
||||
on_name_acquired,
|
||||
on_name_lost,
|
||||
loop, NULL);
|
||||
g_main_loop_run (loop);
|
||||
g_main_loop_unref (loop);
|
||||
|
||||
return connection;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
fatal_error (void)
|
||||
{
|
||||
|
|
@ -164,16 +101,11 @@ main (int argc, char *argv[])
|
|||
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
|
||||
NULL, NULL, &error);
|
||||
if (!connection) {
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
connection = shared_connection_init ();
|
||||
#endif
|
||||
if (!connection) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
g_printerr ("Error: could not connect to NetworkManager D-Bus socket: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
fatal_error ();
|
||||
}
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
g_printerr ("Error: could not connect to NetworkManager D-Bus socket: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
fatal_error ();
|
||||
}
|
||||
|
||||
if (!g_dbus_connection_emit_signal (connection,
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.nm_dhcp_client"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.nm_dhcp_client"/>
|
||||
<deny send_destination="org.freedesktop.nm_dhcp_client"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
|
@ -32,7 +31,6 @@
|
|||
#include "nm-dhcp-listener.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-bus-manager.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
|
||||
|
|
@ -43,8 +41,7 @@ typedef struct {
|
|||
NMBusManager * dbus_mgr;
|
||||
guint new_conn_id;
|
||||
guint dis_conn_id;
|
||||
GHashTable * proxies;
|
||||
DBusGProxy * proxy;
|
||||
GHashTable * signal_handlers;
|
||||
} NMDhcpListenerPrivate;
|
||||
|
||||
#define NM_DHCP_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_LISTENER, NMDhcpListenerPrivate))
|
||||
|
|
@ -60,61 +57,44 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
/***************************************************/
|
||||
|
||||
static char *
|
||||
garray_to_string (GArray *array, const char *key)
|
||||
get_option (GVariant *options, const char *key)
|
||||
{
|
||||
GString *str;
|
||||
int i;
|
||||
unsigned char c;
|
||||
char *converted = NULL;
|
||||
GVariant *value;
|
||||
const guchar *bytes, *s;
|
||||
gsize len;
|
||||
char *converted, *d;
|
||||
|
||||
g_return_val_if_fail (array != NULL, NULL);
|
||||
if (!g_variant_lookup (options, key, "@ay", &value))
|
||||
return NULL;
|
||||
|
||||
bytes = g_variant_get_fixed_array (value, &len, 1);
|
||||
|
||||
/* Since the DHCP options come through environment variables, they should
|
||||
* already be UTF-8 safe, but just make sure.
|
||||
*/
|
||||
str = g_string_sized_new (array->len);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
c = array->data[i];
|
||||
|
||||
converted = g_malloc (len + 1);
|
||||
for (s = bytes, d = converted; s < bytes + len; s++, d++) {
|
||||
/* Convert NULLs to spaces and non-ASCII characters to ? */
|
||||
if (c == '\0')
|
||||
c = ' ';
|
||||
else if (c > 127)
|
||||
c = '?';
|
||||
str = g_string_append_c (str, c);
|
||||
if (*s == '\0')
|
||||
*d = ' ';
|
||||
else if (*s > 127)
|
||||
*d = '?';
|
||||
else
|
||||
*d = *s;
|
||||
}
|
||||
str = g_string_append_c (str, '\0');
|
||||
*d = '\0';
|
||||
|
||||
converted = str->str;
|
||||
if (!g_utf8_validate (converted, -1, NULL))
|
||||
nm_log_warn (LOGD_DHCP, "DHCP option '%s' couldn't be converted to UTF-8", key);
|
||||
g_string_free (str, FALSE);
|
||||
return converted;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_option (GHashTable *hash, const char *key)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_hash_table_lookup (hash, key);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
|
||||
if (G_VALUE_TYPE (value) != DBUS_TYPE_G_UCHAR_ARRAY) {
|
||||
nm_log_warn (LOGD_DHCP, "unexpected key %s value type was not "
|
||||
"DBUS_TYPE_G_UCHAR_ARRAY",
|
||||
(char *) key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return garray_to_string ((GArray *) g_value_get_boxed (value), key);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_event (DBusGProxy *proxy,
|
||||
GHashTable *options,
|
||||
gpointer user_data)
|
||||
handle_event (GDBusConnection *connection,
|
||||
const char *sender_name,
|
||||
const char *object_path,
|
||||
const char *interface_name,
|
||||
const char *signal_name,
|
||||
GVariant *parameters,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDhcpListener *self = NM_DHCP_LISTENER (user_data);
|
||||
char *iface = NULL;
|
||||
|
|
@ -122,6 +102,12 @@ handle_event (DBusGProxy *proxy,
|
|||
char *reason = NULL;
|
||||
gint pid;
|
||||
gboolean handled = FALSE;
|
||||
GVariant *options;
|
||||
|
||||
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})")))
|
||||
return;
|
||||
|
||||
g_variant_get (parameters, "(@a{sv})", &options);
|
||||
|
||||
iface = get_option (options, "interface");
|
||||
if (iface == NULL) {
|
||||
|
|
@ -155,39 +141,42 @@ out:
|
|||
g_free (iface);
|
||||
g_free (pid_str);
|
||||
g_free (reason);
|
||||
g_variant_unref (options);
|
||||
}
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
static void
|
||||
new_connection_cb (NMBusManager *mgr,
|
||||
DBusGConnection *connection,
|
||||
GDBusConnection *connection,
|
||||
NMDhcpListener *self)
|
||||
{
|
||||
DBusGProxy *proxy;
|
||||
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
||||
guint id;
|
||||
|
||||
/* Create a new proxy for the client */
|
||||
proxy = dbus_g_proxy_new_for_peer (connection, "/", NM_DHCP_CLIENT_DBUS_IFACE);
|
||||
dbus_g_proxy_add_signal (proxy, "Event", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (proxy, "Event", G_CALLBACK (handle_event), self, NULL);
|
||||
|
||||
g_hash_table_insert (NM_DHCP_LISTENER_GET_PRIVATE (self)->proxies, connection, proxy);
|
||||
id = g_dbus_connection_signal_subscribe (connection,
|
||||
NULL,
|
||||
NM_DHCP_CLIENT_DBUS_IFACE,
|
||||
"Event",
|
||||
NULL,
|
||||
NULL,
|
||||
G_DBUS_SIGNAL_FLAGS_NONE,
|
||||
handle_event, self, NULL);
|
||||
g_hash_table_insert (priv->signal_handlers, connection, GUINT_TO_POINTER (id));
|
||||
}
|
||||
|
||||
static void
|
||||
dis_connection_cb (NMBusManager *mgr,
|
||||
DBusGConnection *connection,
|
||||
GDBusConnection *connection,
|
||||
NMDhcpListener *self)
|
||||
{
|
||||
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
||||
DBusGProxy *proxy;
|
||||
guint id;
|
||||
|
||||
proxy = g_hash_table_lookup (priv->proxies, connection);
|
||||
if (proxy) {
|
||||
dbus_g_proxy_disconnect_signal (proxy, "Event", G_CALLBACK (handle_event), self);
|
||||
g_hash_table_remove (priv->proxies, connection);
|
||||
id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->signal_handlers, connection));
|
||||
if (id) {
|
||||
g_dbus_connection_signal_unsubscribe (connection, id);
|
||||
g_hash_table_remove (priv->signal_handlers, connection);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************/
|
||||
|
||||
|
|
@ -197,16 +186,12 @@ static void
|
|||
nm_dhcp_listener_init (NMDhcpListener *self)
|
||||
{
|
||||
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
DBusGConnection *g_connection;
|
||||
#endif
|
||||
|
||||
/* Maps DBusGConnection :: DBusGProxy */
|
||||
priv->proxies = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
|
||||
/* Maps GDBusConnection :: GDBusProxy */
|
||||
priv->signal_handlers = g_hash_table_new (NULL, NULL);
|
||||
|
||||
priv->dbus_mgr = nm_bus_manager_get ();
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
/* Register the socket our DHCP clients will return lease info on */
|
||||
nm_bus_manager_private_server_register (priv->dbus_mgr, PRIV_SOCK_PATH, PRIV_SOCK_TAG);
|
||||
priv->new_conn_id = g_signal_connect (priv->dbus_mgr,
|
||||
|
|
@ -217,16 +202,6 @@ nm_dhcp_listener_init (NMDhcpListener *self)
|
|||
NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG,
|
||||
G_CALLBACK (dis_connection_cb),
|
||||
self);
|
||||
#else
|
||||
g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
priv->proxy = dbus_g_proxy_new_for_name (g_connection,
|
||||
"org.freedesktop.nm_dhcp_client",
|
||||
"/",
|
||||
NM_DHCP_CLIENT_DBUS_IFACE);
|
||||
g_assert (priv->proxy);
|
||||
dbus_g_proxy_add_signal (priv->proxy, "Event", DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (priv->proxy, "Event", G_CALLBACK (handle_event), self, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -244,11 +219,7 @@ dispose (GObject *object)
|
|||
}
|
||||
priv->dbus_mgr = NULL;
|
||||
|
||||
if (priv->proxies) {
|
||||
g_hash_table_destroy (priv->proxies);
|
||||
priv->proxies = NULL;
|
||||
}
|
||||
g_clear_object (&priv->proxy);
|
||||
g_clear_pointer (&priv->signal_handlers, g_hash_table_destroy);
|
||||
|
||||
G_OBJECT_CLASS (nm_dhcp_listener_parent_class)->dispose (object);
|
||||
}
|
||||
|
|
@ -274,6 +245,6 @@ nm_dhcp_listener_class_init (NMDhcpListenerClass *listener_class)
|
|||
4,
|
||||
G_TYPE_STRING, /* iface */
|
||||
G_TYPE_INT, /* pid */
|
||||
G_TYPE_HASH_TABLE, /* options */
|
||||
G_TYPE_VARIANT, /* options */
|
||||
G_TYPE_STRING); /* reason */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#include "nm-dhcp-dhcpcd.h"
|
||||
#include "nm-dhcp-systemd.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#define DHCP_TIMEOUT 45 /* default DHCP timeout, in seconds */
|
||||
|
|
@ -180,7 +179,7 @@ get_client_type (const char *client, GError **error)
|
|||
static void client_state_changed (NMDhcpClient *client,
|
||||
NMDhcpState state,
|
||||
GObject *ip_config,
|
||||
GHashTable *options,
|
||||
GVariant *options,
|
||||
NMDhcpManager *self);
|
||||
|
||||
static void
|
||||
|
|
@ -200,7 +199,7 @@ static void
|
|||
client_state_changed (NMDhcpClient *client,
|
||||
NMDhcpState state,
|
||||
GObject *ip_config,
|
||||
GHashTable *options,
|
||||
GVariant *options,
|
||||
NMDhcpManager *self)
|
||||
{
|
||||
if (state >= NM_DHCP_STATE_TIMEOUT)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ AM_CPPFLAGS = \
|
|||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DTESTDIR="\"$(abs_srcdir)\""
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
|
|
|
|||
51
src/main.c
51
src/main.c
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <getopt.h>
|
||||
#include <locale.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -261,7 +258,6 @@ main (int argc, char *argv[])
|
|||
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
|
||||
gboolean success = FALSE;
|
||||
NMManager *manager = NULL;
|
||||
gs_unref_object NMSettings *settings = NULL;
|
||||
NMConfig *config;
|
||||
GError *error = NULL;
|
||||
gboolean wrote_pidfile = FALSE;
|
||||
|
|
@ -402,13 +398,6 @@ main (int argc, char *argv[])
|
|||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
dbus_threads_init_default ();
|
||||
|
||||
/* Ensure that non-exported properties don't leak out, and that the
|
||||
* introspection 'access' permissions are respected.
|
||||
*/
|
||||
dbus_glib_global_set_disable_legacy_property_access ();
|
||||
|
||||
nm_log_info (LOGD_CORE, "Read config: %s", nm_config_data_get_config_description (nm_config_get_data (config)));
|
||||
nm_config_data_log (nm_config_get_data (config), "CONFIG: ");
|
||||
nm_log_dbg (LOGD_CORE, "WEXT support is %s",
|
||||
|
|
@ -419,13 +408,16 @@ main (int argc, char *argv[])
|
|||
#endif
|
||||
);
|
||||
|
||||
nm_auth_manager_setup (nm_config_get_auth_polkit (config));
|
||||
|
||||
manager = nm_manager_setup (global_opt.state_file,
|
||||
net_enabled,
|
||||
wifi_enabled,
|
||||
wwan_enabled,
|
||||
wimax_enabled);
|
||||
|
||||
if (!nm_bus_manager_get_connection (nm_bus_manager_get ())) {
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
nm_log_warn (LOGD_CORE, "Failed to connect to D-Bus; only private bus is available");
|
||||
#else
|
||||
nm_log_err (LOGD_CORE, "Failed to connect to D-Bus, exiting...");
|
||||
goto done;
|
||||
#endif
|
||||
} else {
|
||||
/* Start our DBus service */
|
||||
if (!nm_bus_manager_start_service (nm_bus_manager_get ())) {
|
||||
|
|
@ -443,33 +435,14 @@ main (int argc, char *argv[])
|
|||
* NMPlatform. */
|
||||
g_object_ref (NM_PLATFORM_GET);
|
||||
|
||||
nm_auth_manager_setup (nm_config_get_auth_polkit (config));
|
||||
|
||||
nm_dispatcher_init ();
|
||||
|
||||
settings = nm_settings_new (&error);
|
||||
if (!settings) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize settings storage: %s",
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
goto done;
|
||||
}
|
||||
|
||||
manager = nm_manager_new (settings,
|
||||
global_opt.state_file,
|
||||
net_enabled,
|
||||
wifi_enabled,
|
||||
wwan_enabled,
|
||||
wimax_enabled,
|
||||
&error);
|
||||
if (manager == NULL) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize the network manager: %s",
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
goto done;
|
||||
}
|
||||
|
||||
g_signal_connect (manager, NM_MANAGER_CONFIGURE_QUIT, G_CALLBACK (manager_configure_quit), config);
|
||||
|
||||
nm_manager_start (manager);
|
||||
if (!nm_manager_start (manager, &error)) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize: %s", error->message);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Make sure the loopback interface is up. If interface is down, we bring
|
||||
* it up and kernel will assign it link-local IPv4 and IPv6 addresses. If
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
|
||||
if (!device) {
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@
|
|||
#include "nm-default.h"
|
||||
#include "nm-active-connection.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-auth-subject.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-active-connection-glue.h"
|
||||
|
||||
#include "nmdbus-active-connection.h"
|
||||
|
||||
/* Base class for anything implementing the Connection.Active D-Bus interface */
|
||||
G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
|
@ -586,7 +586,7 @@ nm_active_connection_get_assumed (NMActiveConnection *self)
|
|||
static void
|
||||
auth_done (NMAuthChain *chain,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *unused,
|
||||
GDBusMethodInvocation *unused,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data);
|
||||
|
|
@ -720,10 +720,10 @@ set_property (GObject *object, guint prop_id,
|
|||
nm_active_connection_set_master (NM_ACTIVE_CONNECTION (object), g_value_get_object (value));
|
||||
break;
|
||||
case PROP_SPECIFIC_OBJECT:
|
||||
tmp = g_value_get_boxed (value);
|
||||
tmp = g_value_get_string (value);
|
||||
/* NM uses "/" to mean NULL */
|
||||
if (g_strcmp0 (tmp, "/") != 0)
|
||||
priv->specific_object = g_value_dup_boxed (value);
|
||||
priv->specific_object = g_strdup (tmp);
|
||||
break;
|
||||
case PROP_DEFAULT:
|
||||
priv->is_default = !!g_value_get_boolean (value);
|
||||
|
|
@ -752,7 +752,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
|
||||
g_value_set_string (value, nm_connection_get_path (priv->connection));
|
||||
break;
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, nm_connection_get_id (priv->connection));
|
||||
|
|
@ -764,13 +764,14 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_connection_get_connection_type (priv->connection));
|
||||
break;
|
||||
case PROP_SPECIFIC_OBJECT:
|
||||
g_value_set_boxed (value, priv->specific_object ? priv->specific_object : "/");
|
||||
g_value_set_string (value, priv->specific_object ? priv->specific_object : "/");
|
||||
break;
|
||||
case PROP_DEVICES:
|
||||
devices = g_ptr_array_sized_new (1);
|
||||
devices = g_ptr_array_sized_new (2);
|
||||
if (priv->device && priv->state < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
|
||||
g_ptr_array_add (devices, g_strdup (nm_exported_object_get_path (NM_EXPORTED_OBJECT (priv->device))));
|
||||
g_value_take_boxed (value, devices);
|
||||
g_ptr_array_add (devices, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (devices, FALSE));
|
||||
break;
|
||||
case PROP_STATE:
|
||||
if (priv->state_set)
|
||||
|
|
@ -787,19 +788,19 @@ get_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_IP4_CONFIG:
|
||||
/* The IP and DHCP config properties may be overridden by a subclass */
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
break;
|
||||
case PROP_DHCP4_CONFIG:
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
break;
|
||||
case PROP_DEFAULT6:
|
||||
g_value_set_boolean (value, priv->is_default6);
|
||||
break;
|
||||
case PROP_IP6_CONFIG:
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
break;
|
||||
case PROP_DHCP6_CONFIG:
|
||||
g_value_set_boxed (value, "/");
|
||||
g_value_set_string (value, "/");
|
||||
break;
|
||||
case PROP_VPN:
|
||||
g_value_set_boolean (value, priv->vpn);
|
||||
|
|
@ -888,10 +889,10 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
/* D-Bus exported properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CONNECTION,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_CONNECTION, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ID,
|
||||
|
|
@ -916,15 +917,15 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SPECIFIC_OBJECT,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DEVICES,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
|
@ -946,17 +947,17 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP4_CONFIG,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP4_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_IP4_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP4_CONFIG,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP4_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_DHCP4_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DEFAULT6,
|
||||
|
|
@ -967,17 +968,17 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP6_CONFIG,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP6_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_IP6_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP6_CONFIG,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP6_CONFIG, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_DHCP6_CONFIG, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VPN,
|
||||
|
|
@ -988,10 +989,10 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MASTER,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_MASTER, "", "",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_MASTER, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/* Internal properties */
|
||||
g_object_class_install_property
|
||||
|
|
@ -1045,6 +1046,7 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
|||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (ac_class),
|
||||
&dbus_glib_nm_active_connection_object_info);
|
||||
NMDBUS_TYPE_ACTIVE_CONNECTION_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ nm_auth_subject_get_unix_process_dbus_sender (NMAuthSubject *subject)
|
|||
/**************************************************************/
|
||||
|
||||
static NMAuthSubject *
|
||||
_new_unix_process (DBusGMethodInvocation *context,
|
||||
DBusConnection *connection,
|
||||
DBusMessage *message)
|
||||
_new_unix_process (GDBusMethodInvocation *context,
|
||||
GDBusConnection *connection,
|
||||
GDBusMessage *message)
|
||||
{
|
||||
NMAuthSubject *self;
|
||||
gboolean success = FALSE;
|
||||
|
|
@ -221,14 +221,14 @@ _new_unix_process (DBusGMethodInvocation *context,
|
|||
}
|
||||
|
||||
NMAuthSubject *
|
||||
nm_auth_subject_new_unix_process_from_context (DBusGMethodInvocation *context)
|
||||
nm_auth_subject_new_unix_process_from_context (GDBusMethodInvocation *context)
|
||||
{
|
||||
return _new_unix_process (context, NULL, NULL);
|
||||
}
|
||||
|
||||
NMAuthSubject *
|
||||
nm_auth_subject_new_unix_process_from_message (DBusConnection *connection,
|
||||
DBusMessage *message)
|
||||
nm_auth_subject_new_unix_process_from_message (GDBusConnection *connection,
|
||||
GDBusMessage *message)
|
||||
{
|
||||
return _new_unix_process (NULL, connection, message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
#define __NETWORKMANAGER_AUTH_SUBJECT_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
|
|
@ -57,9 +55,9 @@ GType nm_auth_subject_get_type (void);
|
|||
|
||||
NMAuthSubject *nm_auth_subject_new_internal (void);
|
||||
|
||||
NMAuthSubject *nm_auth_subject_new_unix_process_from_context (DBusGMethodInvocation *context);
|
||||
NMAuthSubject *nm_auth_subject_new_unix_process_from_context (GDBusMethodInvocation *context);
|
||||
|
||||
NMAuthSubject *nm_auth_subject_new_unix_process_from_message (DBusConnection *connection, DBusMessage *message);
|
||||
NMAuthSubject *nm_auth_subject_new_unix_process_from_message (GDBusConnection *connection, GDBusMessage *message);
|
||||
|
||||
|
||||
NMAuthSubjectType nm_auth_subject_get_subject_type (NMAuthSubject *subject);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ struct NMAuthChain {
|
|||
GSList *calls;
|
||||
GHashTable *data;
|
||||
|
||||
DBusGMethodInvocation *context;
|
||||
GDBusMethodInvocation *context;
|
||||
NMAuthSubject *subject;
|
||||
GError *error;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ auth_chain_finish (gpointer user_data)
|
|||
|
||||
/* Creates the NMAuthSubject automatically */
|
||||
NMAuthChain *
|
||||
nm_auth_chain_new_context (DBusGMethodInvocation *context,
|
||||
nm_auth_chain_new_context (GDBusMethodInvocation *context,
|
||||
NMAuthChainResultFunc done_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
|
@ -107,7 +107,7 @@ nm_auth_chain_new_context (DBusGMethodInvocation *context,
|
|||
/* Requires an NMAuthSubject */
|
||||
NMAuthChain *
|
||||
nm_auth_chain_new_subject (NMAuthSubject *subject,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthChainResultFunc done_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __NETWORKMANAGER_MANAGER_AUTH_H__
|
||||
#define __NETWORKMANAGER_MANAGER_AUTH_H__
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include "nm-default.h"
|
||||
|
||||
|
|
@ -50,15 +48,15 @@ typedef enum {
|
|||
|
||||
typedef void (*NMAuthChainResultFunc) (NMAuthChain *chain,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data);
|
||||
|
||||
NMAuthChain *nm_auth_chain_new_context (DBusGMethodInvocation *context,
|
||||
NMAuthChain *nm_auth_chain_new_context (GDBusMethodInvocation *context,
|
||||
NMAuthChainResultFunc done_func,
|
||||
gpointer user_data);
|
||||
|
||||
NMAuthChain *nm_auth_chain_new_subject (NMAuthSubject *subject,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthChainResultFunc done_func,
|
||||
gpointer user_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@
|
|||
#include "nm-default.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-bus-manager.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-dbus-compat.h"
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <string.h>
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
|
@ -41,7 +40,6 @@
|
|||
|
||||
enum {
|
||||
DBUS_CONNECTION_CHANGED = 0,
|
||||
NAME_OWNER_CHANGED,
|
||||
PRIVATE_CONNECTION_NEW,
|
||||
PRIVATE_CONNECTION_DISCONNECTED,
|
||||
NUMBER_OF_SIGNALS
|
||||
|
|
@ -58,22 +56,21 @@ G_DEFINE_TYPE(NMBusManager, nm_bus_manager, G_TYPE_OBJECT)
|
|||
typedef struct _PrivateServer PrivateServer;
|
||||
|
||||
typedef struct {
|
||||
DBusConnection *connection;
|
||||
DBusGConnection *g_connection;
|
||||
GDBusConnection *connection;
|
||||
GHashTable *exported;
|
||||
gboolean started;
|
||||
|
||||
GSList *private_servers;
|
||||
PrivateServer *priv_server;
|
||||
|
||||
DBusGProxy *proxy;
|
||||
guint proxy_destroy_id;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
guint bus_closed_id;
|
||||
guint reconnect_id;
|
||||
} NMBusManagerPrivate;
|
||||
|
||||
static gboolean nm_bus_manager_init_bus (NMBusManager *self);
|
||||
static void nm_bus_manager_cleanup (NMBusManager *self, gboolean dispose);
|
||||
static void nm_bus_manager_cleanup (NMBusManager *self);
|
||||
static void start_reconnection_timeout (NMBusManager *self);
|
||||
static void object_destroyed (NMBusManager *self, gpointer object);
|
||||
|
||||
|
|
@ -111,82 +108,73 @@ struct _PrivateServer {
|
|||
const char *tag;
|
||||
GQuark detail;
|
||||
char *address;
|
||||
DBusServer *server;
|
||||
GDBusServer *server;
|
||||
GHashTable *connections;
|
||||
NMBusManager *manager;
|
||||
};
|
||||
|
||||
static DBusHandlerResult
|
||||
private_server_message_filter (DBusConnection *conn,
|
||||
DBusMessage *message,
|
||||
void *data)
|
||||
static void
|
||||
private_server_closed (GDBusConnection *conn,
|
||||
gboolean remote_peer_vanished,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
PrivateServer *s = data;
|
||||
int fd;
|
||||
PrivateServer *s = user_data;
|
||||
|
||||
/* Clean up after the connection */
|
||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||
nm_log_dbg (LOGD_CORE, "(%s) closed connection %p on private socket (fd %d).",
|
||||
s->tag, conn, dbus_connection_get_unix_fd (conn, &fd) ? fd : -1);
|
||||
nm_log_dbg (LOGD_CORE, "(%s) closed connection %p on private socket.",
|
||||
s->tag, conn);
|
||||
|
||||
/* Emit this for the manager */
|
||||
g_signal_emit (s->manager,
|
||||
signals[PRIVATE_CONNECTION_DISCONNECTED],
|
||||
s->detail,
|
||||
dbus_connection_get_g_connection (conn));
|
||||
/* Emit this for the manager */
|
||||
g_signal_emit (s->manager,
|
||||
signals[PRIVATE_CONNECTION_DISCONNECTED],
|
||||
s->detail,
|
||||
conn);
|
||||
|
||||
g_hash_table_remove (s->connections, conn);
|
||||
|
||||
/* Let dbus-glib process the message too */
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
g_hash_table_remove (s->connections, conn);
|
||||
}
|
||||
|
||||
static dbus_bool_t
|
||||
allow_only_root (DBusConnection *connection, unsigned long uid, void *data)
|
||||
{
|
||||
return uid == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
private_server_new_connection (DBusServer *server,
|
||||
DBusConnection *conn,
|
||||
static gboolean
|
||||
private_server_new_connection (GDBusServer *server,
|
||||
GDBusConnection *conn,
|
||||
gpointer user_data)
|
||||
{
|
||||
PrivateServer *s = user_data;
|
||||
static guint32 counter = 0;
|
||||
char *sender;
|
||||
int fd;
|
||||
|
||||
if (!dbus_connection_add_filter (conn, private_server_message_filter, s, NULL)) {
|
||||
dbus_connection_close (conn);
|
||||
return;
|
||||
}
|
||||
dbus_connection_set_unix_user_function (conn, allow_only_root, NULL, NULL);
|
||||
dbus_connection_setup_with_g_main (conn, NULL);
|
||||
g_signal_connect (conn, "closed", G_CALLBACK (private_server_closed), s);
|
||||
|
||||
/* Fake a sender since private connections don't have one */
|
||||
sender = g_strdup_printf ("x:y:%d", counter++);
|
||||
g_hash_table_insert (s->connections, dbus_connection_ref (conn), sender);
|
||||
g_hash_table_insert (s->connections, g_object_ref (conn), sender);
|
||||
|
||||
nm_log_dbg (LOGD_CORE, "(%s) accepted connection %p on private socket (fd %d).",
|
||||
s->tag, conn, dbus_connection_get_unix_fd (conn, &fd) ? fd : -1);
|
||||
nm_log_dbg (LOGD_CORE, "(%s) accepted connection %p on private socket.",
|
||||
s->tag, conn);
|
||||
|
||||
/* Emit this for the manager */
|
||||
g_signal_emit (s->manager,
|
||||
signals[PRIVATE_CONNECTION_NEW],
|
||||
s->detail,
|
||||
dbus_connection_get_g_connection (conn));
|
||||
conn);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
private_server_dbus_connection_destroy (DBusConnection *conn)
|
||||
private_server_dbus_connection_destroy (GDBusConnection *conn)
|
||||
{
|
||||
if (dbus_connection_get_is_connected (conn))
|
||||
dbus_connection_close (conn);
|
||||
dbus_connection_unref (conn);
|
||||
if (!g_dbus_connection_is_closed (conn))
|
||||
g_dbus_connection_close (conn, NULL, NULL, NULL);
|
||||
g_object_unref (conn);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
private_server_authorize (GDBusAuthObserver *observer,
|
||||
GIOStream *stream,
|
||||
GCredentials *credentials,
|
||||
gpointer user_data)
|
||||
{
|
||||
return g_credentials_get_unix_user (credentials, NULL) == 0;
|
||||
}
|
||||
|
||||
static PrivateServer *
|
||||
|
|
@ -195,21 +183,32 @@ private_server_new (const char *path,
|
|||
NMBusManager *manager)
|
||||
{
|
||||
PrivateServer *s;
|
||||
DBusServer *server;
|
||||
DBusError error;
|
||||
char *address;
|
||||
GDBusAuthObserver *auth_observer;
|
||||
GDBusServer *server;
|
||||
GError *error = NULL;
|
||||
char *address, *guid;
|
||||
|
||||
unlink (path);
|
||||
address = g_strdup_printf ("unix:path=%s", path);
|
||||
|
||||
nm_log_dbg (LOGD_CORE, "(%s) creating private socket %s.", tag, address);
|
||||
|
||||
dbus_error_init (&error);
|
||||
server = dbus_server_listen (address, &error);
|
||||
guid = g_dbus_generate_guid ();
|
||||
auth_observer = g_dbus_auth_observer_new ();
|
||||
g_signal_connect (auth_observer, "authorize-authenticated-peer",
|
||||
G_CALLBACK (private_server_authorize), NULL);
|
||||
server = g_dbus_server_new_sync (address,
|
||||
G_DBUS_SERVER_FLAGS_NONE,
|
||||
guid,
|
||||
auth_observer,
|
||||
NULL, &error);
|
||||
g_free (guid);
|
||||
g_object_unref (auth_observer);
|
||||
|
||||
if (!server) {
|
||||
nm_log_warn (LOGD_CORE, "(%s) failed to set up private socket %s: %s",
|
||||
tag, address, error.message);
|
||||
dbus_error_free (&error);
|
||||
tag, address, error->message);
|
||||
g_error_free (error);
|
||||
g_free (address);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -217,8 +216,8 @@ private_server_new (const char *path,
|
|||
s = g_malloc0 (sizeof (*s));
|
||||
s->address = address;
|
||||
s->server = server;
|
||||
dbus_server_setup_with_g_main (s->server, NULL);
|
||||
dbus_server_set_new_connection_function (s->server, private_server_new_connection, s, NULL);
|
||||
g_signal_connect (server, "new-connection",
|
||||
G_CALLBACK (private_server_new_connection), s);
|
||||
|
||||
s->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||
(GDestroyNotify) private_server_dbus_connection_destroy,
|
||||
|
|
@ -227,6 +226,8 @@ private_server_new (const char *path,
|
|||
s->detail = g_quark_from_string (tag);
|
||||
s->tag = g_quark_to_string (s->detail);
|
||||
|
||||
g_dbus_server_start (server);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -238,8 +239,10 @@ private_server_free (gpointer ptr)
|
|||
unlink (s->address);
|
||||
g_free (s->address);
|
||||
g_hash_table_destroy (s->connections);
|
||||
dbus_server_disconnect (s->server);
|
||||
dbus_server_unref (s->server);
|
||||
|
||||
g_dbus_server_stop (s->server);
|
||||
g_object_unref (s->server);
|
||||
|
||||
memset (s, 0, sizeof (*s));
|
||||
g_free (s);
|
||||
}
|
||||
|
|
@ -253,10 +256,6 @@ nm_bus_manager_private_server_register (NMBusManager *self,
|
|||
PrivateServer *s;
|
||||
GSList *iter;
|
||||
|
||||
#if !HAVE_DBUS_GLIB_100
|
||||
g_assert_not_reached ();
|
||||
#endif
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (path != NULL);
|
||||
g_return_if_fail (tag != NULL);
|
||||
|
|
@ -274,12 +273,12 @@ nm_bus_manager_private_server_register (NMBusManager *self,
|
|||
}
|
||||
|
||||
static const char *
|
||||
private_server_get_connection_owner (PrivateServer *s, DBusGConnection *connection)
|
||||
private_server_get_connection_owner (PrivateServer *s, GDBusConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (s != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
return g_hash_table_lookup (s->connections, dbus_g_connection_get_connection (connection));
|
||||
return g_hash_table_lookup (s->connections, connection);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
|
@ -291,52 +290,74 @@ _bus_get_unix_pid (NMBusManager *self,
|
|||
GError **error)
|
||||
{
|
||||
guint32 unix_pid = G_MAXUINT32;
|
||||
GVariant *ret;
|
||||
|
||||
if (!dbus_g_proxy_call_with_timeout (NM_BUS_MANAGER_GET_PRIVATE (self)->proxy,
|
||||
"GetConnectionUnixProcessID", 2000, error,
|
||||
G_TYPE_STRING, sender,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &unix_pid,
|
||||
G_TYPE_INVALID)) {
|
||||
ret = _nm_dbus_proxy_call_sync (NM_BUS_MANAGER_GET_PRIVATE (self)->proxy,
|
||||
"GetConnectionUnixProcessID",
|
||||
g_variant_new ("(s)", sender),
|
||||
G_VARIANT_TYPE ("(u)"),
|
||||
G_DBUS_CALL_FLAGS_NONE, 2000,
|
||||
NULL, error);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_variant_get (ret, "(u)", &unix_pid);
|
||||
|
||||
*out_pid = (gulong) unix_pid;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_bus_get_unix_user (NMBusManager *self,
|
||||
const char *sender,
|
||||
gulong *out_user,
|
||||
GError **error)
|
||||
{
|
||||
guint32 unix_uid = G_MAXUINT32;
|
||||
GVariant *ret;
|
||||
|
||||
ret = _nm_dbus_proxy_call_sync (NM_BUS_MANAGER_GET_PRIVATE (self)->proxy,
|
||||
"GetConnectionUnixUser",
|
||||
g_variant_new ("(s)", sender),
|
||||
G_VARIANT_TYPE ("(u)"),
|
||||
G_DBUS_CALL_FLAGS_NONE, 2000,
|
||||
NULL, error);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
|
||||
g_variant_get (ret, "(u)", &unix_uid);
|
||||
|
||||
*out_user = (gulong) unix_uid;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* _get_caller_info_from_context():
|
||||
* _get_caller_info():
|
||||
*
|
||||
* Given a dbus-glib method invocation, or a DBusConnection + DBusMessage,
|
||||
* Given a GDBus method invocation, or a GDBusConnection + GDBusMessage,
|
||||
* return the sender and the UID of the sender.
|
||||
*/
|
||||
static gboolean
|
||||
_get_caller_info (NMBusManager *self,
|
||||
DBusGMethodInvocation *context,
|
||||
DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
GDBusMethodInvocation *context,
|
||||
GDBusConnection *connection,
|
||||
GDBusMessage *message,
|
||||
char **out_sender,
|
||||
gulong *out_uid,
|
||||
gulong *out_pid)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
DBusGConnection *gconn;
|
||||
char *sender;
|
||||
const char *priv_sender;
|
||||
DBusError error;
|
||||
const char *sender;
|
||||
GSList *iter;
|
||||
|
||||
if (context) {
|
||||
gconn = dbus_g_method_invocation_get_g_connection (context);
|
||||
g_assert (gconn);
|
||||
connection = dbus_g_connection_get_connection (gconn);
|
||||
connection = g_dbus_method_invocation_get_connection (context);
|
||||
|
||||
/* only bus connections will have a sender */
|
||||
sender = dbus_g_method_get_sender (context);
|
||||
sender = g_dbus_method_invocation_get_sender (context);
|
||||
} else {
|
||||
g_assert (message);
|
||||
sender = g_strdup (dbus_message_get_sender (message));
|
||||
sender = g_dbus_message_get_sender (message);
|
||||
}
|
||||
g_assert (connection);
|
||||
|
||||
|
|
@ -345,14 +366,25 @@ _get_caller_info (NMBusManager *self,
|
|||
for (iter = priv->private_servers; iter; iter = g_slist_next (iter)) {
|
||||
PrivateServer *s = iter->data;
|
||||
|
||||
priv_sender = g_hash_table_lookup (s->connections, connection);
|
||||
if (priv_sender) {
|
||||
sender = g_hash_table_lookup (s->connections, connection);
|
||||
if (sender) {
|
||||
if (out_uid)
|
||||
*out_uid = 0;
|
||||
if (out_sender)
|
||||
*out_sender = g_strdup (priv_sender);
|
||||
*out_sender = g_strdup (sender);
|
||||
if (out_pid) {
|
||||
if (!dbus_connection_get_unix_process_id (connection, out_pid))
|
||||
GCredentials *creds;
|
||||
|
||||
creds = g_dbus_connection_get_peer_credentials (connection);
|
||||
if (creds) {
|
||||
pid_t pid;
|
||||
|
||||
pid = g_credentials_get_unix_pid (creds, NULL);
|
||||
if (pid == -1)
|
||||
*out_pid = G_MAXULONG;
|
||||
else
|
||||
*out_pid = pid;
|
||||
} else
|
||||
*out_pid = G_MAXULONG;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
@ -364,12 +396,8 @@ _get_caller_info (NMBusManager *self,
|
|||
/* Bus connections always have a sender */
|
||||
g_assert (sender);
|
||||
if (out_uid) {
|
||||
dbus_error_init (&error);
|
||||
*out_uid = dbus_bus_get_unix_user (connection, sender, &error);
|
||||
if (dbus_error_is_set (&error)) {
|
||||
dbus_error_free (&error);
|
||||
if (!_bus_get_unix_user (self, sender, out_uid, NULL)) {
|
||||
*out_uid = G_MAXULONG;
|
||||
g_free (sender);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -377,7 +405,6 @@ _get_caller_info (NMBusManager *self,
|
|||
if (out_pid) {
|
||||
if (!_bus_get_unix_pid (self, sender, out_pid, NULL)) {
|
||||
*out_pid = G_MAXULONG;
|
||||
g_free (sender);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -385,13 +412,12 @@ _get_caller_info (NMBusManager *self,
|
|||
if (out_sender)
|
||||
*out_sender = g_strdup (sender);
|
||||
|
||||
g_free (sender);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_bus_manager_get_caller_info (NMBusManager *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
char **out_sender,
|
||||
gulong *out_uid,
|
||||
gulong *out_pid)
|
||||
|
|
@ -401,8 +427,8 @@ nm_bus_manager_get_caller_info (NMBusManager *self,
|
|||
|
||||
gboolean
|
||||
nm_bus_manager_get_caller_info_from_message (NMBusManager *self,
|
||||
DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
GDBusConnection *connection,
|
||||
GDBusMessage *message,
|
||||
char **out_sender,
|
||||
gulong *out_uid,
|
||||
gulong *out_pid)
|
||||
|
|
@ -417,7 +443,7 @@ nm_bus_manager_get_unix_user (NMBusManager *self,
|
|||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GSList *iter;
|
||||
DBusError error;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (sender != NULL, FALSE);
|
||||
g_return_val_if_fail (out_uid != NULL, FALSE);
|
||||
|
|
@ -438,11 +464,10 @@ nm_bus_manager_get_unix_user (NMBusManager *self,
|
|||
}
|
||||
|
||||
/* Otherwise, a bus connection */
|
||||
dbus_error_init (&error);
|
||||
*out_uid = dbus_bus_get_unix_user (priv->connection, sender, &error);
|
||||
if (dbus_error_is_set (&error)) {
|
||||
if (!_bus_get_unix_user (self, sender, out_uid, &error)) {
|
||||
nm_log_warn (LOGD_CORE, "Failed to get unix user for dbus sender '%s': %s",
|
||||
sender, error.message);
|
||||
sender, error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -451,38 +476,30 @@ nm_bus_manager_get_unix_user (NMBusManager *self,
|
|||
|
||||
/**************************************************************/
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
static void
|
||||
private_connection_new (NMBusManager *self, DBusGConnection *connection)
|
||||
private_connection_new (NMBusManager *self, GDBusConnection *connection)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
GObject *object;
|
||||
GDBusInterfaceSkeleton *interface;
|
||||
const char *path;
|
||||
GError *error = NULL;
|
||||
|
||||
/* Register all exported objects on this private connection */
|
||||
g_hash_table_iter_init (&iter, priv->exported);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &object, (gpointer) &path)) {
|
||||
dbus_g_connection_register_g_object (connection, path, object);
|
||||
nm_log_trace (LOGD_CORE, "(%s) registered %p (%s) at '%s' on private socket.",
|
||||
PRIV_SOCK_TAG, object, G_OBJECT_TYPE_NAME (object), path);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &interface, (gpointer) &path)) {
|
||||
if (g_dbus_interface_skeleton_export (interface, connection, path, &error)) {
|
||||
nm_log_trace (LOGD_CORE, "(%s) registered %p (%s) at '%s' on private socket.",
|
||||
PRIV_SOCK_TAG, interface, G_OBJECT_TYPE_NAME (interface), path);
|
||||
} else {
|
||||
nm_log_warn (LOGD_CORE, "(%s) could not register %p (%s) at '%s' on private socket: %s.",
|
||||
PRIV_SOCK_TAG, interface, G_OBJECT_TYPE_NAME (interface), path,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
private_connection_disconnected (NMBusManager *self, DBusGConnection *connection)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
const char *owner;
|
||||
|
||||
owner = private_server_get_connection_owner (priv->priv_server, connection);
|
||||
g_assert (owner);
|
||||
|
||||
/* Fake a NameOwnerChanged to let listerners know this owner has quit */
|
||||
g_signal_emit (G_OBJECT (self), signals[NAME_OWNER_CHANGED],
|
||||
0, owner, owner, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
private_server_setup (NMBusManager *self)
|
||||
{
|
||||
|
|
@ -500,18 +517,12 @@ private_server_setup (NMBusManager *self)
|
|||
priv->priv_server = private_server_new (PRIV_SOCK_PATH, PRIV_SOCK_TAG, self);
|
||||
if (priv->priv_server) {
|
||||
priv->private_servers = g_slist_append (priv->private_servers, priv->priv_server);
|
||||
|
||||
g_signal_connect (self,
|
||||
NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "::" PRIV_SOCK_TAG,
|
||||
(GCallback) private_connection_new,
|
||||
NULL);
|
||||
g_signal_connect (self,
|
||||
NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "::" PRIV_SOCK_TAG,
|
||||
(GCallback) private_connection_disconnected,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_DBUS_GLIB_100 */
|
||||
|
||||
static void
|
||||
nm_bus_manager_init (NMBusManager *self)
|
||||
|
|
@ -520,9 +531,7 @@ nm_bus_manager_init (NMBusManager *self)
|
|||
|
||||
priv->exported = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
|
||||
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
private_server_setup (self);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -546,7 +555,7 @@ nm_bus_manager_dispose (GObject *object)
|
|||
priv->private_servers = NULL;
|
||||
priv->priv_server = NULL;
|
||||
|
||||
nm_bus_manager_cleanup (self, TRUE);
|
||||
nm_bus_manager_cleanup (self);
|
||||
|
||||
if (priv->reconnect_id) {
|
||||
g_source_remove (priv->reconnect_id);
|
||||
|
|
@ -573,14 +582,6 @@ nm_bus_manager_class_init (NMBusManagerClass *klass)
|
|||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
|
||||
signals[NAME_OWNER_CHANGED] =
|
||||
g_signal_new (NM_BUS_MANAGER_NAME_OWNER_CHANGED,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (NMBusManagerClass, name_owner_changed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
signals[PRIVATE_CONNECTION_NEW] =
|
||||
g_signal_new (NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
|
|
@ -601,23 +602,16 @@ nm_bus_manager_class_init (NMBusManagerClass *klass)
|
|||
|
||||
/* Only cleanup a specific dbus connection, not all our private data */
|
||||
static void
|
||||
nm_bus_manager_cleanup (NMBusManager *self, gboolean dispose)
|
||||
nm_bus_manager_cleanup (NMBusManager *self)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
if (priv->proxy) {
|
||||
if (dispose) {
|
||||
g_signal_handler_disconnect (priv->proxy, priv->proxy_destroy_id);
|
||||
priv->proxy_destroy_id = 0;
|
||||
}
|
||||
g_object_unref (priv->proxy);
|
||||
priv->proxy = NULL;
|
||||
}
|
||||
g_clear_object (&priv->proxy);
|
||||
|
||||
if (priv->g_connection) {
|
||||
dbus_g_connection_unref (priv->g_connection);
|
||||
priv->g_connection = NULL;
|
||||
priv->connection = NULL;
|
||||
if (priv->connection) {
|
||||
g_signal_handler_disconnect (priv->connection, priv->bus_closed_id);
|
||||
priv->bus_closed_id = 0;
|
||||
g_clear_object (&priv->connection);
|
||||
}
|
||||
|
||||
priv->started = FALSE;
|
||||
|
|
@ -642,7 +636,7 @@ nm_bus_manager_reconnect (gpointer user_data)
|
|||
}
|
||||
|
||||
/* Try again */
|
||||
nm_bus_manager_cleanup (self, FALSE);
|
||||
nm_bus_manager_cleanup (self);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -658,81 +652,18 @@ start_reconnection_timeout (NMBusManager *self)
|
|||
priv->reconnect_id = g_timeout_add_seconds (3, nm_bus_manager_reconnect, self);
|
||||
}
|
||||
|
||||
char *
|
||||
nm_bus_manager_get_name_owner (NMBusManager *self,
|
||||
const char *name,
|
||||
GError **error)
|
||||
{
|
||||
char *owner = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_BUS_MANAGER (self), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, NULL);
|
||||
|
||||
if (!NM_BUS_MANAGER_GET_PRIVATE (self)->proxy)
|
||||
return NULL;
|
||||
|
||||
if (!dbus_g_proxy_call_with_timeout (NM_BUS_MANAGER_GET_PRIVATE (self)->proxy,
|
||||
"GetNameOwner", 2000, error,
|
||||
G_TYPE_STRING, name,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_STRING, &owner,
|
||||
G_TYPE_INVALID)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_bus_manager_name_has_owner (NMBusManager *self,
|
||||
const char *name)
|
||||
{
|
||||
gboolean has_owner = FALSE;
|
||||
GError *err = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_BUS_MANAGER (self), FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
if (!NM_BUS_MANAGER_GET_PRIVATE (self)->proxy)
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_g_proxy_call (NM_BUS_MANAGER_GET_PRIVATE (self)->proxy,
|
||||
"NameHasOwner", &err,
|
||||
G_TYPE_STRING, name,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_BOOLEAN, &has_owner,
|
||||
G_TYPE_INVALID)) {
|
||||
nm_log_warn (LOGD_CORE, "NameHasOwner request failed: %s",
|
||||
(err && err->message) ? err->message : "(unknown)");
|
||||
g_clear_error (&err);
|
||||
}
|
||||
|
||||
return has_owner;
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_name_owner_changed (DBusGProxy *proxy,
|
||||
const char *name,
|
||||
const char *old_owner,
|
||||
const char *new_owner,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_signal_emit (G_OBJECT (user_data), signals[NAME_OWNER_CHANGED],
|
||||
0, name, old_owner, new_owner);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_cb (DBusGProxy *proxy, gpointer user_data)
|
||||
closed_cb (GDBusConnection *connection,
|
||||
gboolean remote_peer_vanished,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMBusManager *self = NM_BUS_MANAGER (user_data);
|
||||
|
||||
/* Clean up existing connection */
|
||||
nm_log_warn (LOGD_CORE, "disconnected by the system bus.");
|
||||
NM_BUS_MANAGER_GET_PRIVATE (self)->proxy = NULL;
|
||||
|
||||
nm_bus_manager_cleanup (self, FALSE);
|
||||
nm_bus_manager_cleanup (self);
|
||||
|
||||
g_signal_emit (G_OBJECT (self), signals[DBUS_CONNECTION_CHANGED], 0, NULL);
|
||||
|
||||
|
|
@ -743,43 +674,47 @@ static gboolean
|
|||
nm_bus_manager_init_bus (NMBusManager *self)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
|
||||
if (priv->connection) {
|
||||
nm_log_warn (LOGD_CORE, "DBus Manager already has a valid connection.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dbus_connection_set_change_sigpipe (TRUE);
|
||||
|
||||
priv->g_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
|
||||
if (!priv->g_connection) {
|
||||
priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!priv->connection) {
|
||||
/* Log with 'info' severity; there won't be a bus daemon in minimal
|
||||
* environments (eg, initrd) where we only want to use the private
|
||||
* socket.
|
||||
*/
|
||||
nm_log_info (LOGD_CORE, "Could not connect to the system bus; only the "
|
||||
"private D-Bus socket will be available.");
|
||||
nm_log_info (LOGD_CORE, "Could not connect to the system bus (%s); only the "
|
||||
"private D-Bus socket will be available.",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->connection = dbus_g_connection_get_connection (priv->g_connection);
|
||||
dbus_connection_set_exit_on_disconnect (priv->connection, FALSE);
|
||||
g_dbus_connection_set_exit_on_close (priv->connection, FALSE);
|
||||
priv->bus_closed_id = g_signal_connect (priv->connection, "closed",
|
||||
G_CALLBACK (closed_cb), self);
|
||||
|
||||
priv->proxy = dbus_g_proxy_new_for_name (priv->g_connection,
|
||||
DBUS_SERVICE_DBUS,
|
||||
DBUS_PATH_DBUS,
|
||||
DBUS_INTERFACE_DBUS);
|
||||
priv->proxy = g_dbus_proxy_new_sync (priv->connection,
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
|
||||
NULL,
|
||||
DBUS_SERVICE_DBUS,
|
||||
DBUS_PATH_DBUS,
|
||||
DBUS_INTERFACE_DBUS,
|
||||
NULL, &error);
|
||||
if (!priv->proxy) {
|
||||
g_clear_object (&priv->connection);
|
||||
nm_log_warn (LOGD_CORE, "Could not create org.freedesktop.DBus proxy (%s); only the "
|
||||
"private D-Bus socket will be available.",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->proxy_destroy_id = g_signal_connect (priv->proxy, "destroy",
|
||||
G_CALLBACK (destroy_cb), self);
|
||||
|
||||
dbus_g_proxy_add_signal (priv->proxy, "NameOwnerChanged",
|
||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
||||
G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal (priv->proxy,
|
||||
"NameOwnerChanged",
|
||||
G_CALLBACK (proxy_name_owner_changed),
|
||||
self, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -791,6 +726,7 @@ gboolean
|
|||
nm_bus_manager_start_service (NMBusManager *self)
|
||||
{
|
||||
NMBusManagerPrivate *priv;
|
||||
GVariant *ret;
|
||||
int result;
|
||||
GError *err = NULL;
|
||||
|
||||
|
|
@ -807,19 +743,23 @@ nm_bus_manager_start_service (NMBusManager *self)
|
|||
if (!priv->proxy)
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_g_proxy_call (priv->proxy, "RequestName", &err,
|
||||
G_TYPE_STRING, NM_DBUS_SERVICE,
|
||||
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &result,
|
||||
G_TYPE_INVALID)) {
|
||||
ret = _nm_dbus_proxy_call_sync (priv->proxy,
|
||||
"RequestName",
|
||||
g_variant_new ("(su)",
|
||||
NM_DBUS_SERVICE,
|
||||
DBUS_NAME_FLAG_DO_NOT_QUEUE),
|
||||
G_VARIANT_TYPE ("(u)"),
|
||||
G_DBUS_CALL_FLAGS_NONE, -1,
|
||||
NULL, &err);
|
||||
if (!ret) {
|
||||
nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service.\n"
|
||||
" Error: '%s'",
|
||||
(err && err->message) ? err->message : "(unknown)");
|
||||
" Error: '%s'", err->message);
|
||||
g_error_free (err);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_variant_get (ret, "(u)", &result);
|
||||
|
||||
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
||||
nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service as it is already taken.");
|
||||
return FALSE;
|
||||
|
|
@ -829,20 +769,12 @@ nm_bus_manager_start_service (NMBusManager *self)
|
|||
return priv->started;
|
||||
}
|
||||
|
||||
DBusConnection *
|
||||
nm_bus_manager_get_dbus_connection (NMBusManager *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_BUS_MANAGER (self), NULL);
|
||||
|
||||
return NM_BUS_MANAGER_GET_PRIVATE (self)->connection;
|
||||
}
|
||||
|
||||
DBusGConnection *
|
||||
GDBusConnection *
|
||||
nm_bus_manager_get_connection (NMBusManager *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_BUS_MANAGER (self), NULL);
|
||||
|
||||
return NM_BUS_MANAGER_GET_PRIVATE (self)->g_connection;
|
||||
return NM_BUS_MANAGER_GET_PRIVATE (self)->connection;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -858,9 +790,9 @@ nm_bus_manager_register_object (NMBusManager *self,
|
|||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
DBusConnection *connection;
|
||||
GDBusConnection *connection;
|
||||
|
||||
g_assert (G_IS_OBJECT (object));
|
||||
g_assert (G_IS_DBUS_INTERFACE_SKELETON (object));
|
||||
|
||||
if (g_hash_table_lookup (priv->exported, G_OBJECT (object)))
|
||||
g_return_if_reached ();
|
||||
|
|
@ -868,27 +800,43 @@ nm_bus_manager_register_object (NMBusManager *self,
|
|||
g_hash_table_insert (priv->exported, G_OBJECT (object), g_strdup (path));
|
||||
g_object_weak_ref (G_OBJECT (object), (GWeakNotify) object_destroyed, self);
|
||||
|
||||
if (priv->g_connection)
|
||||
dbus_g_connection_register_g_object (priv->g_connection, path, G_OBJECT (object));
|
||||
if (priv->connection) {
|
||||
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (object),
|
||||
priv->connection, path, NULL);
|
||||
}
|
||||
|
||||
if (priv->priv_server) {
|
||||
g_hash_table_iter_init (&iter, priv->priv_server->connections);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &connection, NULL)) {
|
||||
dbus_g_connection_register_g_object (dbus_connection_get_g_connection (connection),
|
||||
path,
|
||||
G_OBJECT (object));
|
||||
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (object),
|
||||
connection, path, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gpointer
|
||||
nm_bus_manager_get_registered_object (NMBusManager *self,
|
||||
const char *path)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
GObject *object;
|
||||
const char *export_path;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->exported);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &object, (gpointer *) &export_path)) {
|
||||
if (!strcmp (path, export_path))
|
||||
return object;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
nm_bus_manager_unregister_object (NMBusManager *self, gpointer object)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
DBusConnection *connection;
|
||||
|
||||
g_assert (G_IS_OBJECT (object));
|
||||
g_assert (G_IS_DBUS_INTERFACE_SKELETON (object));
|
||||
|
||||
if (!g_hash_table_lookup (priv->exported, G_OBJECT (object)))
|
||||
g_return_if_reached ();
|
||||
|
|
@ -896,74 +844,69 @@ nm_bus_manager_unregister_object (NMBusManager *self, gpointer object)
|
|||
g_hash_table_remove (priv->exported, G_OBJECT (object));
|
||||
g_object_weak_unref (G_OBJECT (object), (GWeakNotify) object_destroyed, self);
|
||||
|
||||
if (priv->g_connection)
|
||||
dbus_g_connection_unregister_g_object (priv->g_connection, G_OBJECT (object));
|
||||
|
||||
if (priv->priv_server) {
|
||||
g_hash_table_iter_init (&iter, priv->priv_server->connections);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &connection, NULL)) {
|
||||
dbus_g_connection_unregister_g_object (dbus_connection_get_g_connection (connection),
|
||||
G_OBJECT (object));
|
||||
}
|
||||
}
|
||||
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (object));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_bus_manager_new_proxy:
|
||||
* @self: the #NMBusManager
|
||||
* @context: the method call context this proxy should be created
|
||||
* @proxy_type: the type of #GDBusProxy to create
|
||||
* @name: any name on the message bus
|
||||
* @path: name of the object instance to call methods on
|
||||
* @iface: name of the interface to call methods on
|
||||
*
|
||||
* Creates a new proxy for a name on a given bus. Since the process which
|
||||
* called the D-Bus method could be coming from a private connection or the
|
||||
* system bus connection, differnet proxies must be created for each case. This
|
||||
* function abstracts that.
|
||||
* Creates a new proxy (of type @proxy_type) for a name on a given bus. Since
|
||||
* the process which called the D-Bus method could be coming from a private
|
||||
* connection or the system bus connection, different proxies must be created
|
||||
* for each case. This function abstracts that.
|
||||
*
|
||||
* Returns: a #DBusGProxy capable of calling D-Bus methods of the calling process
|
||||
* Returns: a #GDBusProxy capable of calling D-Bus methods of the calling process
|
||||
*/
|
||||
DBusGProxy *
|
||||
GDBusProxy *
|
||||
nm_bus_manager_new_proxy (NMBusManager *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
GType proxy_type,
|
||||
const char *name,
|
||||
const char *path,
|
||||
const char *iface)
|
||||
{
|
||||
NMBusManagerPrivate *priv = NM_BUS_MANAGER_GET_PRIVATE (self);
|
||||
DBusGConnection *connection;
|
||||
GDBusConnection *connection;
|
||||
GSList *iter;
|
||||
const char *owner;
|
||||
GDBusProxy *proxy;
|
||||
GError *error = NULL;
|
||||
|
||||
connection = dbus_g_method_invocation_get_g_connection (context);
|
||||
g_return_val_if_fail (g_type_is_a (proxy_type, G_TYPE_DBUS_PROXY), NULL);
|
||||
|
||||
connection = g_dbus_method_invocation_get_connection (context);
|
||||
g_assert (connection);
|
||||
|
||||
/* Might be a private connection, for which we fake a sender */
|
||||
/* Might be a private connection, for which @name is fake */
|
||||
for (iter = priv->private_servers; iter; iter = g_slist_next (iter)) {
|
||||
PrivateServer *s = iter->data;
|
||||
|
||||
owner = private_server_get_connection_owner (s, connection);
|
||||
if (owner) {
|
||||
g_assert_cmpstr (owner, ==, name);
|
||||
return dbus_g_proxy_new_for_peer (connection, path, iface);
|
||||
name = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dbus_g_proxy_new_for_name (connection, name, path, iface);
|
||||
proxy = g_initable_new (proxy_type, NULL, &error,
|
||||
"g-connection", connection,
|
||||
"g-flags", (G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
|
||||
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS),
|
||||
"g-name", name,
|
||||
"g-object-path", path,
|
||||
"g-interface-name", iface,
|
||||
NULL);
|
||||
if (!proxy) {
|
||||
nm_log_warn (LOGD_CORE, "Could not create proxy for %s on connection %s: %s",
|
||||
iface, name, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
#if !HAVE_DBUS_GLIB_GMI_GET_CONNECTION
|
||||
struct _HACKDBusGMethodInvocation {
|
||||
DBusGConnection *connection;
|
||||
/* ... */
|
||||
};
|
||||
|
||||
DBusGConnection *
|
||||
dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context)
|
||||
{
|
||||
/* Evil hack; this method exists in dbus-glib >= 101, but if we don't
|
||||
* have that, emulate it.
|
||||
*/
|
||||
return ((struct _HACKDBusGMethodInvocation *) context)->connection;
|
||||
}
|
||||
#endif /* HAVE_DBUS_GLIB_GMI_GET_CONNECTION */
|
||||
|
|
|
|||
|
|
@ -23,17 +23,11 @@
|
|||
#define __NM_BUS_MANAGER_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef gboolean (* NMDBusSignalHandlerFunc) (DBusConnection * connection,
|
||||
DBusMessage * message,
|
||||
gpointer user_data);
|
||||
|
||||
#define NM_TYPE_BUS_MANAGER (nm_bus_manager_get_type ())
|
||||
#define NM_BUS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_BUS_MANAGER, NMBusManager))
|
||||
#define NM_BUS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_BUS_MANAGER, NMBusManagerClass))
|
||||
|
|
@ -42,7 +36,6 @@ typedef gboolean (* NMDBusSignalHandlerFunc) (DBusConnection * connection,
|
|||
#define NM_BUS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NM_TYPE_BUS_MANAGER, NMBusManagerClass))
|
||||
|
||||
#define NM_BUS_MANAGER_DBUS_CONNECTION_CHANGED "dbus-connection-changed"
|
||||
#define NM_BUS_MANAGER_NAME_OWNER_CHANGED "name-owner-changed"
|
||||
#define NM_BUS_MANAGER_PRIVATE_CONNECTION_NEW "private-connection-new"
|
||||
#define NM_BUS_MANAGER_PRIVATE_CONNECTION_DISCONNECTED "private-connection-disconnected"
|
||||
|
||||
|
|
@ -55,18 +48,13 @@ typedef struct {
|
|||
|
||||
/* Signals */
|
||||
void (*dbus_connection_changed) (NMBusManager *mgr,
|
||||
DBusConnection *connection);
|
||||
|
||||
void (*name_owner_changed) (NMBusManager *mgr,
|
||||
const char *name,
|
||||
const char *old_owner,
|
||||
const char *new_owner);
|
||||
GDBusConnection *connection);
|
||||
|
||||
void (*private_connection_new) (NMBusManager *mgr,
|
||||
DBusGConnection *connection);
|
||||
GDBusConnection *connection);
|
||||
|
||||
void (*private_connection_disconnected) (NMBusManager *mgr,
|
||||
DBusGConnection *connection);
|
||||
GDBusConnection *connection);
|
||||
} NMBusManagerClass;
|
||||
|
||||
GType nm_bus_manager_get_type (void);
|
||||
|
|
@ -74,20 +62,12 @@ GType nm_bus_manager_get_type (void);
|
|||
NMBusManager * nm_bus_manager_get (void);
|
||||
void nm_bus_manager_setup (NMBusManager *instance);
|
||||
|
||||
char * nm_bus_manager_get_name_owner (NMBusManager *self,
|
||||
const char *name,
|
||||
GError **error);
|
||||
|
||||
gboolean nm_bus_manager_start_service (NMBusManager *self);
|
||||
|
||||
gboolean nm_bus_manager_name_has_owner (NMBusManager *self,
|
||||
const char *name);
|
||||
|
||||
DBusConnection * nm_bus_manager_get_dbus_connection (NMBusManager *self);
|
||||
DBusGConnection * nm_bus_manager_get_connection (NMBusManager *self);
|
||||
GDBusConnection * nm_bus_manager_get_connection (NMBusManager *self);
|
||||
|
||||
gboolean nm_bus_manager_get_caller_info (NMBusManager *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
char **out_sender,
|
||||
gulong *out_uid,
|
||||
gulong *out_pid);
|
||||
|
|
@ -97,8 +77,8 @@ gboolean nm_bus_manager_get_unix_user (NMBusManager *self,
|
|||
gulong *out_uid);
|
||||
|
||||
gboolean nm_bus_manager_get_caller_info_from_message (NMBusManager *self,
|
||||
DBusConnection *connection,
|
||||
DBusMessage *message,
|
||||
GDBusConnection *connection,
|
||||
GDBusMessage *message,
|
||||
char **out_sender,
|
||||
gulong *out_uid,
|
||||
gulong *out_pid);
|
||||
|
|
@ -109,20 +89,20 @@ void nm_bus_manager_register_object (NMBusManager *self,
|
|||
|
||||
void nm_bus_manager_unregister_object (NMBusManager *self, gpointer object);
|
||||
|
||||
gpointer nm_bus_manager_get_registered_object (NMBusManager *self,
|
||||
const char *path);
|
||||
|
||||
void nm_bus_manager_private_server_register (NMBusManager *self,
|
||||
const char *path,
|
||||
const char *tag);
|
||||
|
||||
DBusGProxy *nm_bus_manager_new_proxy (NMBusManager *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusProxy *nm_bus_manager_new_proxy (NMBusManager *self,
|
||||
GDBusMethodInvocation *context,
|
||||
GType proxy_type,
|
||||
const char *name,
|
||||
const char *path,
|
||||
const char *iface);
|
||||
|
||||
#if !HAVE_DBUS_GLIB_GMI_GET_CONNECTION
|
||||
DBusGConnection *dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context);
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_BUS_MANAGER_H__ */
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@
|
|||
#include "nm-default.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-dhcp4-config.h"
|
||||
#include "nm-dhcp4-config-glue.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
#include "nmdbus-dhcp4-config.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_DHCP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigPrivate))
|
||||
|
|
@ -128,11 +128,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_OPTIONS:
|
||||
/* dbus_g_value_parse_g_variant() will call g_value_init(), but
|
||||
* @value is already inited.
|
||||
*/
|
||||
g_value_unset (value);
|
||||
dbus_g_value_parse_g_variant (priv->options, value);
|
||||
g_value_set_variant (value, priv->options);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -157,11 +153,13 @@ nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_OPTIONS,
|
||||
g_param_spec_boxed (NM_DHCP4_CONFIG_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "",
|
||||
G_VARIANT_TYPE ("a{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
|
||||
&dbus_glib_nm_dhcp4_config_object_info);
|
||||
NMDBUS_TYPE_DHCP4_CONFIG_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@
|
|||
#include "nm-default.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-dhcp6-config.h"
|
||||
#include "nm-dhcp6-config-glue.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
#include "nmdbus-dhcp6-config.h"
|
||||
|
||||
G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_DHCP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigPrivate))
|
||||
|
|
@ -128,11 +128,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_OPTIONS:
|
||||
/* dbus_g_value_parse_g_variant() will call g_value_init(), but
|
||||
* @value is already inited.
|
||||
*/
|
||||
g_value_unset (value);
|
||||
dbus_g_value_parse_g_variant (priv->options, value);
|
||||
g_value_set_variant (value, priv->options);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -157,11 +153,13 @@ nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
|
|||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_OPTIONS,
|
||||
g_param_spec_boxed (NM_DHCP6_CONFIG_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "",
|
||||
G_VARIANT_TYPE ("a{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
|
||||
&dbus_glib_nm_dhcp6_config_object_info);
|
||||
NMDBUS_TYPE_DHCP6_CONFIG_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "nm-dhcp6-config.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-ip6-config.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-exported-object.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-bus-manager.h"
|
||||
#include "nm-default.h"
|
||||
|
||||
|
|
@ -34,85 +34,374 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMExportedObject, nm_exported_object, G_TYPE_O
|
|||
)
|
||||
|
||||
typedef struct {
|
||||
GSList *interfaces;
|
||||
|
||||
char *path;
|
||||
|
||||
GHashTable *pending_notifies;
|
||||
GVariantBuilder pending_notifies;
|
||||
guint notify_idle_id;
|
||||
} NMExportedObjectPrivate;
|
||||
|
||||
#define NM_EXPORTED_OBJECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_EXPORTED_OBJECT, NMExportedObjectPrivate))
|
||||
|
||||
enum {
|
||||
PROPERTIES_CHANGED,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
typedef struct {
|
||||
GType dbus_skeleton_type;
|
||||
char *method_name;
|
||||
GCallback impl;
|
||||
} NMExportedObjectDBusMethodImpl;
|
||||
|
||||
typedef struct {
|
||||
GHashTable *properties;
|
||||
GSList *skeleton_types;
|
||||
GArray *methods;
|
||||
} NMExportedObjectClassInfo;
|
||||
|
||||
GQuark nm_exported_object_class_info_quark (void);
|
||||
G_DEFINE_QUARK (NMExportedObjectClassInfo, nm_exported_object_class_info)
|
||||
|
||||
/* "AddConnectionUnsaved" -> "handle-add-connection-unsaved" */
|
||||
static char *
|
||||
skeletonify_method_name (const char *dbus_method_name)
|
||||
{
|
||||
GString *out;
|
||||
const char *p;
|
||||
|
||||
out = g_string_new ("handle");
|
||||
for (p = dbus_method_name; *p; p++) {
|
||||
if (g_ascii_isupper (*p) || p == dbus_method_name) {
|
||||
g_string_append_c (out, '-');
|
||||
g_string_append_c (out, g_ascii_tolower (*p));
|
||||
} else
|
||||
g_string_append_c (out, *p);
|
||||
}
|
||||
|
||||
return g_string_free (out, FALSE);
|
||||
}
|
||||
|
||||
/* "can-modify" -> "CanModify" */
|
||||
static char *
|
||||
dbusify_name (const char *gobject_name)
|
||||
{
|
||||
GString *out;
|
||||
const char *p;
|
||||
gboolean capitalize = TRUE;
|
||||
|
||||
out = g_string_new ("");
|
||||
for (p = gobject_name; *p; p++) {
|
||||
if (capitalize) {
|
||||
g_string_append_c (out, g_ascii_toupper (*p));
|
||||
capitalize = FALSE;
|
||||
} else if (*p == '-')
|
||||
capitalize = TRUE;
|
||||
else
|
||||
g_string_append_c (out, *p);
|
||||
}
|
||||
|
||||
return g_string_free (out, FALSE);
|
||||
}
|
||||
|
||||
/* "can_modify" -> "can-modify". Returns %NULL if @gobject_name contains no underscores */
|
||||
static char *
|
||||
hyphenify_name (const char *gobject_name)
|
||||
{
|
||||
char *hyphen_name, *p;
|
||||
|
||||
if (!strchr (gobject_name, '_'))
|
||||
return NULL;
|
||||
|
||||
hyphen_name = g_strdup (gobject_name);
|
||||
for (p = hyphen_name; *p; p++) {
|
||||
if (*p == '_')
|
||||
*p = '-';
|
||||
}
|
||||
return hyphen_name;
|
||||
}
|
||||
|
||||
/* Called when an #NMExportedObject emits a signal that corresponds to a D-Bus
|
||||
* signal, and re-emits that signal on the correct skeleton object as well.
|
||||
*/
|
||||
static gboolean
|
||||
nm_exported_object_signal_hook (GSignalInvocationHint *ihint,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer data)
|
||||
{
|
||||
NMExportedObject *self = g_value_get_object (¶m_values[0]);
|
||||
NMExportedObjectPrivate *priv;
|
||||
GSignalQuery *signal_info = data;
|
||||
GDBusObjectSkeleton *interface = NULL;
|
||||
GSList *iter;
|
||||
GValue *dbus_param_values;
|
||||
int i;
|
||||
|
||||
priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
if (!priv->path)
|
||||
return TRUE;
|
||||
|
||||
for (iter = priv->interfaces; iter; iter = iter->next) {
|
||||
if (g_type_is_a (G_OBJECT_TYPE (iter->data), signal_info->itype)) {
|
||||
interface = iter->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_return_val_if_fail (interface != NULL, TRUE);
|
||||
|
||||
dbus_param_values = g_new0 (GValue, n_param_values);
|
||||
g_value_init (&dbus_param_values[0], G_OBJECT_TYPE (interface));
|
||||
g_value_set_object (&dbus_param_values[0], interface);
|
||||
for (i = 1; i < n_param_values; i++) {
|
||||
if (g_type_is_a (param_values[i].g_type, NM_TYPE_EXPORTED_OBJECT)) {
|
||||
NMExportedObject *arg = g_value_get_object (¶m_values[i]);
|
||||
|
||||
g_value_init (&dbus_param_values[i], G_TYPE_STRING);
|
||||
if (arg && nm_exported_object_is_exported (arg))
|
||||
g_value_set_string (&dbus_param_values[i], nm_exported_object_get_path (arg));
|
||||
else
|
||||
g_value_set_string (&dbus_param_values[i], "/");
|
||||
} else {
|
||||
g_value_init (&dbus_param_values[i], param_values[i].g_type);
|
||||
g_value_copy (¶m_values[i], &dbus_param_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_emitv (dbus_param_values, signal_info->signal_id, 0, NULL);
|
||||
|
||||
for (i = 0; i < n_param_values; i++)
|
||||
g_value_unset (&dbus_param_values[i]);
|
||||
g_free (dbus_param_values);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_exported_object_class_add_interface:
|
||||
* @object_class: an #NMExportedObjectClass
|
||||
* @info: generated #DBusGObjectInfo for the class
|
||||
* @dbus_skeleton_type: the type of the #GDBusObjectSkeleton to add
|
||||
* @...: method name / handler pairs, %NULL-terminated
|
||||
*
|
||||
* Adds @info to the list of D-Bus interfaces implemented by @object_class and
|
||||
* sets up automatic dbus-glib handling for instances of that class.
|
||||
* Adds @dbus_skeleton_type to the list of D-Bus interfaces implemented by
|
||||
* @object_class. Instances of @object_class will automatically have a skeleton
|
||||
* of that type created, which will be exported when you call
|
||||
* nm_exported_object_export().
|
||||
*
|
||||
* If @info includes any properties, then a "PropertiesChanged" signal will
|
||||
* be emitted on @info's interface whenever any of those properties change on
|
||||
* an exported instance of @object_class.
|
||||
* The skeleton's properties will be initialized from the #NMExportedObject's,
|
||||
* and bidirectional bindings will be set up between them. When exported
|
||||
* properties change, both the org.freedesktop.DBus.Properties.PropertiesChanged
|
||||
* signal and the traditional NetworkManager PropertiesChanged signal will be
|
||||
* emitted.
|
||||
*
|
||||
* When a signal is emitted on an #NMExportedObject that has the same name as a
|
||||
* signal on @dbus_skeleton_type, it will automatically be emitted on the
|
||||
* skeleton as well; #NMExportedObject arguments in the signal will be converted
|
||||
* to D-Bus object paths in the skeleton signal.
|
||||
*
|
||||
* The arguments after @dbus_skeleton_type are pairs of D-Bus method names (in
|
||||
* CamelCase), and the corresponding handlers for them (which must have the same
|
||||
* prototype as the corresponding "handle-..." signal on @dbus_skeleton_type,
|
||||
* except with no return value, and with the first argument being an object of
|
||||
* @object_class's type, not of @dbus_skeleton_type).
|
||||
*
|
||||
* It is a programmer error if:
|
||||
* - @object_class does not define a property of the same name and type as
|
||||
* each of @dbus_skeleton_type's properties.
|
||||
* - @object_class does not define a signal with the same name and arguments
|
||||
* as each of @dbus_skeleton_type's signals.
|
||||
* - the list of method names includes any names that do not correspond to
|
||||
* "handle-" signals on @dbus_skeleton_type.
|
||||
* - the list of method names does not include every method defined by
|
||||
* @dbus_skeleton_type.
|
||||
*/
|
||||
void
|
||||
nm_exported_object_class_add_interface (NMExportedObjectClass *object_class,
|
||||
const DBusGObjectInfo *info)
|
||||
GType dbus_skeleton_type,
|
||||
...)
|
||||
{
|
||||
GType object_type = G_TYPE_FROM_CLASS (object_class);
|
||||
NMExportedObjectClassInfo *classinfo;
|
||||
const char *properties_info, *dbus_name, *gobject_name, *tmp_access;
|
||||
char *hyphen_name, *p;
|
||||
NMExportedObjectDBusMethodImpl method;
|
||||
va_list ap;
|
||||
const char *method_name;
|
||||
GCallback impl;
|
||||
GType *interfaces;
|
||||
guint n_interfaces;
|
||||
guint *dbus_signals, n_signals, n_method_signals;
|
||||
guint object_signal_id;
|
||||
GSignalQuery query;
|
||||
int i, s;
|
||||
GObjectClass *dbus_object_class;
|
||||
GParamSpec **dbus_properties, *object_property;
|
||||
guint n_dbus_properties;
|
||||
|
||||
dbus_g_object_type_install_info (object_type, info);
|
||||
if (!info->exported_properties)
|
||||
return;
|
||||
g_return_if_fail (NM_IS_EXPORTED_OBJECT_CLASS (object_class));
|
||||
g_return_if_fail (g_type_is_a (dbus_skeleton_type, G_TYPE_DBUS_INTERFACE_SKELETON));
|
||||
|
||||
classinfo = g_type_get_qdata (object_type, nm_exported_object_class_info_quark ());
|
||||
if (!classinfo) {
|
||||
classinfo = g_slice_new (NMExportedObjectClassInfo);
|
||||
classinfo->properties = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_type_set_qdata (object_type, nm_exported_object_class_info_quark (), classinfo);
|
||||
classinfo = g_slice_new (NMExportedObjectClassInfo);
|
||||
classinfo->skeleton_types = NULL;
|
||||
classinfo->methods = g_array_new (FALSE, FALSE, sizeof (NMExportedObjectDBusMethodImpl));
|
||||
classinfo->properties = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_type_set_qdata (G_TYPE_FROM_CLASS (object_class),
|
||||
nm_exported_object_class_info_quark (), classinfo);
|
||||
|
||||
classinfo->skeleton_types = g_slist_prepend (classinfo->skeleton_types,
|
||||
GSIZE_TO_POINTER (dbus_skeleton_type));
|
||||
|
||||
/* Ensure @dbus_skeleton_type's class_init has run, so its signals/properties
|
||||
* will be defined.
|
||||
*/
|
||||
dbus_object_class = g_type_class_ref (dbus_skeleton_type);
|
||||
|
||||
/* Add method implementations from the varargs */
|
||||
va_start (ap, dbus_skeleton_type);
|
||||
while ((method_name = va_arg (ap, const char *)) && (impl = va_arg (ap, GCallback))) {
|
||||
method.dbus_skeleton_type = dbus_skeleton_type;
|
||||
method.method_name = skeletonify_method_name (method_name);
|
||||
g_assert (g_signal_lookup (method.method_name, dbus_skeleton_type) != 0);
|
||||
method.impl = impl;
|
||||
|
||||
g_array_append_val (classinfo->methods, method);
|
||||
}
|
||||
va_end (ap);
|
||||
|
||||
properties_info = info->exported_properties;
|
||||
while (*properties_info) {
|
||||
/* The format is: "interface\0DBusPropertyName\0gobject_property_name\0access\0" */
|
||||
dbus_name = strchr (properties_info, '\0') + 1;
|
||||
gobject_name = strchr (dbus_name, '\0') + 1;
|
||||
tmp_access = strchr (gobject_name, '\0') + 1;
|
||||
properties_info = strchr (tmp_access, '\0') + 1;
|
||||
/* Properties */
|
||||
dbus_properties = g_object_class_list_properties (dbus_object_class, &n_dbus_properties);
|
||||
for (i = 0; i < n_dbus_properties; i++) {
|
||||
char *hyphen_name;
|
||||
|
||||
if (strchr (gobject_name, '_')) {
|
||||
hyphen_name = g_strdup (gobject_name);
|
||||
for (p = hyphen_name; *p; p++) {
|
||||
if (*p == '_')
|
||||
*p = '-';
|
||||
}
|
||||
if (g_str_has_prefix (dbus_properties[i]->name, "g-"))
|
||||
continue;
|
||||
|
||||
object_property = g_object_class_find_property (G_OBJECT_CLASS (object_class),
|
||||
dbus_properties[i]->name);
|
||||
g_assert (object_property != NULL);
|
||||
g_assert (object_property->value_type == dbus_properties[i]->value_type);
|
||||
|
||||
g_assert (!g_hash_table_contains (classinfo->properties, dbus_properties[i]->name));
|
||||
g_hash_table_insert (classinfo->properties,
|
||||
g_strdup (dbus_properties[i]->name),
|
||||
dbusify_name (dbus_properties[i]->name));
|
||||
hyphen_name = hyphenify_name (dbus_properties[i]->name);
|
||||
if (hyphen_name) {
|
||||
g_assert (!g_hash_table_contains (classinfo->properties, hyphen_name));
|
||||
g_hash_table_insert (classinfo->properties,
|
||||
(char *) g_intern_string (hyphen_name),
|
||||
(char *) dbus_name);
|
||||
g_free (hyphen_name);
|
||||
} else {
|
||||
g_assert (!g_hash_table_contains (classinfo->properties, (char *) gobject_name));
|
||||
g_hash_table_insert (classinfo->properties,
|
||||
(char *) gobject_name,
|
||||
(char *) dbus_name);
|
||||
hyphen_name,
|
||||
dbusify_name (dbus_properties[i]->name));
|
||||
}
|
||||
}
|
||||
|
||||
/* Signals. Unlike g_object_class_list_properties(), g_signal_list_ids() is
|
||||
* "shallow", so we need to query each implemented gdbus-generated interface
|
||||
* separately.
|
||||
*/
|
||||
interfaces = g_type_interfaces (dbus_skeleton_type, &n_interfaces);
|
||||
n_method_signals = 0;
|
||||
for (i = 0; i < n_interfaces; i++) {
|
||||
dbus_signals = g_signal_list_ids (interfaces[i], &n_signals);
|
||||
for (s = 0; s < n_signals; s++) {
|
||||
g_signal_query (dbus_signals[s], &query);
|
||||
|
||||
/* PropertiesChanged is handled specially */
|
||||
if (!strcmp (query.signal_name, "properties-changed"))
|
||||
continue;
|
||||
|
||||
if (g_str_has_prefix (query.signal_name, "handle-")) {
|
||||
n_method_signals++;
|
||||
continue;
|
||||
}
|
||||
|
||||
object_signal_id = g_signal_lookup (query.signal_name, G_TYPE_FROM_CLASS (object_class));
|
||||
g_assert (object_signal_id != 0);
|
||||
|
||||
g_signal_add_emission_hook (object_signal_id, 0,
|
||||
nm_exported_object_signal_hook,
|
||||
g_memdup (&query, sizeof (query)),
|
||||
g_free);
|
||||
}
|
||||
}
|
||||
|
||||
g_assert_cmpint (n_method_signals, ==, classinfo->methods->len);
|
||||
|
||||
g_type_class_unref (dbus_object_class);
|
||||
}
|
||||
|
||||
/* "meta-marshaller" that receives the skeleton "handle-foo" signal, replaces
|
||||
* the skeleton object with an #NMExportedObject in the parameters, drops the
|
||||
* user_data parameter, and adds a "TRUE" return value (indicating to gdbus that
|
||||
* the signal was handled).
|
||||
*/
|
||||
static void
|
||||
nm_exported_object_meta_marshal (GClosure *closure, GValue *return_value,
|
||||
guint n_param_values, const GValue *param_values,
|
||||
gpointer invocation_hint, gpointer marshal_data)
|
||||
{
|
||||
GValue *local_param_values;
|
||||
|
||||
local_param_values = g_new0 (GValue, n_param_values);
|
||||
g_value_init (&local_param_values[0], G_TYPE_POINTER);
|
||||
g_value_set_pointer (&local_param_values[0], closure->data);
|
||||
memcpy (local_param_values + 1, param_values + 1, (n_param_values - 1) * sizeof (GValue));
|
||||
|
||||
g_cclosure_marshal_generic (closure, NULL,
|
||||
n_param_values, local_param_values,
|
||||
invocation_hint,
|
||||
((GCClosure *)closure)->callback);
|
||||
g_value_set_boolean (return_value, TRUE);
|
||||
|
||||
g_value_unset (&local_param_values[0]);
|
||||
g_free (local_param_values);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exported_object_create_skeletons (NMExportedObject *self,
|
||||
GType object_type)
|
||||
{
|
||||
NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
GObjectClass *object_class = g_type_class_peek (object_type);
|
||||
NMExportedObjectClassInfo *classinfo;
|
||||
GSList *iter;
|
||||
GDBusObjectSkeleton *interface;
|
||||
GParamSpec **properties;
|
||||
guint n_properties;
|
||||
int i;
|
||||
|
||||
classinfo = g_type_get_qdata (object_type, nm_exported_object_class_info_quark ());
|
||||
if (!classinfo)
|
||||
return;
|
||||
|
||||
for (iter = classinfo->skeleton_types; iter; iter = iter->next) {
|
||||
GType dbus_skeleton_type = GPOINTER_TO_SIZE (iter->data);
|
||||
|
||||
interface = g_object_new (dbus_skeleton_type, NULL);
|
||||
priv->interfaces = g_slist_prepend (priv->interfaces, interface);
|
||||
|
||||
/* Bind properties */
|
||||
properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (interface), &n_properties);
|
||||
for (i = 0; i < n_properties; i++) {
|
||||
GParamSpec *nm_property;
|
||||
GBindingFlags flags;
|
||||
|
||||
nm_property = g_object_class_find_property (object_class, properties[i]->name);
|
||||
if (!nm_property)
|
||||
continue;
|
||||
|
||||
flags = G_BINDING_SYNC_CREATE;
|
||||
if ( (nm_property->flags & G_PARAM_WRITABLE)
|
||||
&& !(nm_property->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
flags |= G_BINDING_BIDIRECTIONAL;
|
||||
g_object_bind_property (self, properties[i]->name,
|
||||
interface, properties[i]->name,
|
||||
flags);
|
||||
}
|
||||
|
||||
/* Bind methods */
|
||||
for (i = 0; i < classinfo->methods->len; i++) {
|
||||
NMExportedObjectDBusMethodImpl *method = &g_array_index (classinfo->methods, NMExportedObjectDBusMethodImpl, i);
|
||||
GClosure *closure;
|
||||
|
||||
if (method->dbus_skeleton_type != dbus_skeleton_type)
|
||||
continue;
|
||||
|
||||
closure = g_cclosure_new_swap (method->impl, self, NULL);
|
||||
g_closure_set_meta_marshal (closure, NULL, nm_exported_object_meta_marshal);
|
||||
g_signal_connect_closure (interface, method->method_name, closure, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -135,7 +424,10 @@ const char *
|
|||
nm_exported_object_export (NMExportedObject *self)
|
||||
{
|
||||
NMExportedObjectPrivate *priv;
|
||||
NMBusManager *dbus_manager = nm_bus_manager_get ();
|
||||
const char *class_export_path, *p;
|
||||
GSList *iter;
|
||||
GType type;
|
||||
|
||||
g_return_val_if_fail (NM_IS_EXPORTED_OBJECT (self), NULL);
|
||||
priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
|
|
@ -160,7 +452,14 @@ nm_exported_object_export (NMExportedObject *self)
|
|||
} else
|
||||
priv->path = g_strdup (class_export_path);
|
||||
|
||||
nm_bus_manager_register_object (nm_bus_manager_get (), priv->path, self);
|
||||
type = G_OBJECT_TYPE (self);
|
||||
while (type != NM_TYPE_EXPORTED_OBJECT) {
|
||||
nm_exported_object_create_skeletons (self, type);
|
||||
type = g_type_parent (type);
|
||||
}
|
||||
|
||||
for (iter = priv->interfaces; iter; iter = iter->next)
|
||||
nm_bus_manager_register_object (dbus_manager, priv->path, iter->data);
|
||||
|
||||
return priv->path;
|
||||
}
|
||||
|
|
@ -208,6 +507,7 @@ void
|
|||
nm_exported_object_unexport (NMExportedObject *self)
|
||||
{
|
||||
NMExportedObjectPrivate *priv;
|
||||
GSList *iter;
|
||||
|
||||
g_return_if_fail (NM_IS_EXPORTED_OBJECT (self));
|
||||
priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
|
|
@ -215,16 +515,11 @@ nm_exported_object_unexport (NMExportedObject *self)
|
|||
g_return_if_fail (priv->path != NULL);
|
||||
|
||||
g_clear_pointer (&priv->path, g_free);
|
||||
nm_bus_manager_unregister_object (nm_bus_manager_get (), self);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_value (gpointer data)
|
||||
{
|
||||
GValue *val = (GValue *) data;
|
||||
|
||||
g_value_unset (val);
|
||||
g_slice_free (GValue, val);
|
||||
for (iter = priv->interfaces; iter; iter = iter->next)
|
||||
nm_bus_manager_unregister_object (nm_bus_manager_get (), iter->data);
|
||||
g_slist_free_full (priv->interfaces, g_object_unref);
|
||||
priv->interfaces = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -232,63 +527,77 @@ nm_exported_object_init (NMExportedObject *self)
|
|||
{
|
||||
NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
|
||||
priv->pending_notifies = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
NULL, destroy_value);
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_string (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
const char *name = (const char *) key;
|
||||
GString *buf = user_data;
|
||||
GValue str_val = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&str_val, G_TYPE_STRING);
|
||||
if (!g_value_transform ((GValue *) value, &str_val)) {
|
||||
if (G_VALUE_HOLDS_OBJECT (value)) {
|
||||
GObject *obj = g_value_get_object (value);
|
||||
|
||||
if (obj) {
|
||||
g_string_append_printf (buf, "{%s: %p (%s)}, ", name, obj,
|
||||
G_OBJECT_TYPE_NAME (obj));
|
||||
} else
|
||||
g_string_append_printf (buf, "{%s: %p}, ", name, obj);
|
||||
} else
|
||||
g_string_append_printf (buf, "{%s: <transform error>}, ", name);
|
||||
} else
|
||||
g_string_append_printf (buf, "{%s: %s}, ", name, g_value_get_string (&str_val));
|
||||
g_value_unset (&str_val);
|
||||
g_variant_builder_init (&priv->pending_notifies, G_VARIANT_TYPE_VARDICT);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
idle_emit_properties_changed (gpointer self)
|
||||
{
|
||||
NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (self);
|
||||
GVariant *notifies;
|
||||
GSList *iter;
|
||||
GDBusObjectSkeleton *interface = NULL;
|
||||
guint signal_id = 0;
|
||||
|
||||
priv->notify_idle_id = 0;
|
||||
notifies = g_variant_builder_end (&priv->pending_notifies);
|
||||
g_variant_ref_sink (notifies);
|
||||
g_variant_builder_init (&priv->pending_notifies, G_VARIANT_TYPE_VARDICT);
|
||||
|
||||
for (iter = priv->interfaces; iter; iter = iter->next) {
|
||||
signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (iter->data));
|
||||
if (signal_id != 0) {
|
||||
interface = iter->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_return_val_if_fail (signal_id != 0, FALSE);
|
||||
|
||||
if (nm_logging_enabled (LOGL_DEBUG, LOGD_DBUS_PROPS)) {
|
||||
GString *buf = g_string_new (NULL);
|
||||
char *notification;
|
||||
|
||||
g_hash_table_foreach (priv->pending_notifies, add_to_string, buf);
|
||||
nm_log_dbg (LOGD_DBUS_PROPS, "%s -> %s", G_OBJECT_TYPE_NAME (self), buf->str);
|
||||
g_string_free (buf, TRUE);
|
||||
notification = g_variant_print (notifies, TRUE);
|
||||
nm_log_dbg (LOGD_DBUS_PROPS, "PropertiesChanged %s %p: %s",
|
||||
G_OBJECT_TYPE_NAME (self), self, notification);
|
||||
g_free (notification);
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[PROPERTIES_CHANGED], 0, priv->pending_notifies);
|
||||
g_hash_table_remove_all (priv->pending_notifies);
|
||||
g_signal_emit (interface, signal_id, 0, notifies);
|
||||
g_variant_unref (notifies);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static const GVariantType *
|
||||
find_dbus_property_type (GDBusInterfaceSkeleton *skel,
|
||||
const char *dbus_property_name)
|
||||
{
|
||||
GDBusInterfaceInfo *iinfo;
|
||||
int i;
|
||||
|
||||
iinfo = g_dbus_interface_skeleton_get_info (skel);
|
||||
for (i = 0; iinfo->properties[i]; i++) {
|
||||
if (!strcmp (iinfo->properties[i]->name, dbus_property_name))
|
||||
return G_VARIANT_TYPE (iinfo->properties[i]->signature);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exported_object_notify (GObject *object, GParamSpec *pspec)
|
||||
{
|
||||
NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object);
|
||||
NMExportedObjectClassInfo *classinfo;
|
||||
const char *dbus_property_name = NULL;
|
||||
GValue *value;
|
||||
GType type;
|
||||
const char *dbus_property_name = NULL;
|
||||
GValue value = G_VALUE_INIT;
|
||||
const GVariantType *vtype;
|
||||
GVariant *variant;
|
||||
GSList *iter;
|
||||
|
||||
if (!priv->interfaces)
|
||||
return;
|
||||
|
||||
for (type = G_OBJECT_TYPE (object); type; type = g_type_parent (type)) {
|
||||
classinfo = g_type_get_qdata (type, nm_exported_object_class_info_quark ());
|
||||
|
|
@ -305,10 +614,19 @@ nm_exported_object_notify (GObject *object, GParamSpec *pspec)
|
|||
return;
|
||||
}
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, pspec->value_type);
|
||||
g_object_get_property (object, pspec->name, value);
|
||||
g_hash_table_insert (priv->pending_notifies, (char *) dbus_property_name, value);
|
||||
g_value_init (&value, pspec->value_type);
|
||||
g_object_get_property (G_OBJECT (object), pspec->name, &value);
|
||||
|
||||
vtype = NULL;
|
||||
for (iter = priv->interfaces; iter && !vtype; iter = iter->next)
|
||||
vtype = find_dbus_property_type (iter->data, dbus_property_name);
|
||||
g_return_if_fail (vtype != NULL);
|
||||
|
||||
variant = g_dbus_gvalue_to_gvariant (&value, vtype);
|
||||
g_variant_builder_add (&priv->pending_notifies, "{sv}",
|
||||
dbus_property_name,
|
||||
variant);
|
||||
g_value_unset (&value);
|
||||
|
||||
if (!priv->notify_idle_id)
|
||||
priv->notify_idle_id = g_idle_add (idle_emit_properties_changed, object);
|
||||
|
|
@ -322,22 +640,15 @@ nm_exported_object_dispose (GObject *object)
|
|||
if (priv->path)
|
||||
nm_exported_object_unexport (NM_EXPORTED_OBJECT (object));
|
||||
|
||||
g_hash_table_remove_all (priv->pending_notifies);
|
||||
g_variant_builder_clear (&priv->pending_notifies);
|
||||
nm_clear_g_source (&priv->notify_idle_id);
|
||||
|
||||
g_slist_free_full (priv->interfaces, g_object_unref);
|
||||
priv->interfaces = NULL;
|
||||
|
||||
G_OBJECT_CLASS (nm_exported_object_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exported_object_finalize (GObject *object)
|
||||
{
|
||||
NMExportedObjectPrivate *priv = NM_EXPORTED_OBJECT_GET_PRIVATE (object);
|
||||
|
||||
g_hash_table_destroy (priv->pending_notifies);
|
||||
|
||||
G_OBJECT_CLASS (nm_exported_object_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exported_object_class_init (NMExportedObjectClass *klass)
|
||||
{
|
||||
|
|
@ -345,14 +656,6 @@ nm_exported_object_class_init (NMExportedObjectClass *klass)
|
|||
|
||||
g_type_class_add_private (object_class, sizeof (NMExportedObjectPrivate));
|
||||
|
||||
object_class->notify = nm_exported_object_notify;
|
||||
object_class->notify = nm_exported_object_notify;
|
||||
object_class->dispose = nm_exported_object_dispose;
|
||||
object_class->finalize = nm_exported_object_finalize;
|
||||
|
||||
signals[PROPERTIES_CHANGED] = g_signal_new ("properties-changed",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,8 @@
|
|||
#ifndef NM_EXPORTED_OBJECT_H
|
||||
#define NM_EXPORTED_OBJECT_H
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
@ -47,7 +46,8 @@ typedef struct {
|
|||
GType nm_exported_object_get_type (void);
|
||||
|
||||
void nm_exported_object_class_add_interface (NMExportedObjectClass *object_class,
|
||||
const DBusGObjectInfo *info);
|
||||
GType dbus_skeleton_type,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
const char *nm_exported_object_export (NMExportedObject *self);
|
||||
const char *nm_exported_object_get_path (NMExportedObject *self);
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@
|
|||
#include "nm-default.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-ip4-config-glue.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-route-manager.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-macros-internal.h"
|
||||
|
||||
#include "nmdbus-ip4-config.h"
|
||||
|
||||
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
|
||||
|
|
@ -2139,15 +2139,6 @@ finalize (GObject *object)
|
|||
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gvalue_destroy (gpointer data)
|
||||
{
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
g_value_unset (value);
|
||||
g_slice_free (GValue, value);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -2161,127 +2152,116 @@ get_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_ADDRESS_DATA:
|
||||
{
|
||||
GPtrArray *addresses = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder, addr_builder;
|
||||
int naddr = nm_ip4_config_get_num_addresses (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aa{sv}"));
|
||||
for (i = 0; i < naddr; i++) {
|
||||
const NMPlatformIP4Address *address = nm_ip4_config_get_address (config, i);
|
||||
GHashTable *addr_hash;
|
||||
GValue *val;
|
||||
|
||||
addr_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gvalue_destroy);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet4_ntop (address->address, NULL));
|
||||
g_hash_table_insert (addr_hash, "address", val);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, address->plen);
|
||||
g_hash_table_insert (addr_hash, "prefix", val);
|
||||
g_variant_builder_init (&addr_builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
g_variant_builder_add (&addr_builder, "{sv}",
|
||||
"address",
|
||||
g_variant_new_string (nm_utils_inet4_ntop (address->address, NULL)));
|
||||
g_variant_builder_add (&addr_builder, "{sv}",
|
||||
"prefix",
|
||||
g_variant_new_uint32 (address->plen));
|
||||
|
||||
if (*address->label) {
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, address->label);
|
||||
g_hash_table_insert (addr_hash, "label", val);
|
||||
g_variant_builder_add (&addr_builder, "{sv}",
|
||||
"label",
|
||||
g_variant_new_string (address->label));
|
||||
}
|
||||
|
||||
g_ptr_array_add (addresses, addr_hash);
|
||||
g_variant_builder_add (&array_builder, "a{sv}", &addr_builder);
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, addresses);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
{
|
||||
GPtrArray *addresses = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder;
|
||||
int naddr = nm_ip4_config_get_num_addresses (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aau"));
|
||||
for (i = 0; i < naddr; i++) {
|
||||
const NMPlatformIP4Address *address = nm_ip4_config_get_address (config, i);
|
||||
GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
|
||||
guint32 gateway = i == 0 ? priv->gateway : 0;
|
||||
guint32 dbus_addr[3];
|
||||
|
||||
g_array_append_val (array, address->address);
|
||||
g_array_append_val (array, address->plen);
|
||||
g_array_append_val (array, gateway);
|
||||
dbus_addr[0] = address->address;
|
||||
dbus_addr[1] = address->plen;
|
||||
dbus_addr[2] = i == 0 ? priv->gateway : 0;
|
||||
|
||||
g_ptr_array_add (addresses, array);
|
||||
g_variant_builder_add (&array_builder, "@au",
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
|
||||
dbus_addr, 3, sizeof (guint32)));
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, addresses);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ROUTE_DATA:
|
||||
{
|
||||
GPtrArray *routes = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder, route_builder;
|
||||
guint nroutes = nm_ip4_config_get_num_routes (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aa{sv}"));
|
||||
for (i = 0; i < nroutes; i++) {
|
||||
const NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
|
||||
GHashTable *route_hash;
|
||||
GValue *val;
|
||||
|
||||
route_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gvalue_destroy);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet4_ntop (route->network, NULL));
|
||||
g_hash_table_insert (route_hash, "dest", val);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, route->plen);
|
||||
g_hash_table_insert (route_hash, "prefix", val);
|
||||
|
||||
g_variant_builder_init (&route_builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"dest",
|
||||
g_variant_new_string (nm_utils_inet4_ntop (route->network, NULL)));
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"prefix",
|
||||
g_variant_new_uint32 (route->plen));
|
||||
if (route->gateway) {
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet4_ntop (route->gateway, NULL));
|
||||
g_hash_table_insert (route_hash, "next-hop", val);
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"next-hop",
|
||||
g_variant_new_string (nm_utils_inet4_ntop (route->gateway, NULL)));
|
||||
}
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"metric",
|
||||
g_variant_new_uint32 (route->metric));
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, route->metric);
|
||||
g_hash_table_insert (route_hash, "metric", val);
|
||||
|
||||
g_ptr_array_add (routes, route_hash);
|
||||
g_variant_builder_add (&array_builder, "a{sv}", &route_builder);
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, routes);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
{
|
||||
GPtrArray *routes = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder;
|
||||
guint nroutes = nm_ip4_config_get_num_routes (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aau"));
|
||||
for (i = 0; i < nroutes; i++) {
|
||||
const NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
|
||||
GArray *array;
|
||||
guint32 dbus_route[4];
|
||||
|
||||
/* legacy versions of nm_ip4_route_set_prefix() in libnm-util assert that the
|
||||
* plen is positive. Skip the default routes not to break older clients. */
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
|
||||
continue;
|
||||
|
||||
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
|
||||
g_array_append_val (array, route->network);
|
||||
g_array_append_val (array, route->plen);
|
||||
g_array_append_val (array, route->gateway);
|
||||
g_array_append_val (array, route->metric);
|
||||
dbus_route[0] = route->network;
|
||||
dbus_route[1] = route->plen;
|
||||
dbus_route[2] = route->gateway;
|
||||
dbus_route[3] = route->metric;
|
||||
|
||||
g_ptr_array_add (routes, array);
|
||||
g_variant_builder_add (&array_builder, "@au",
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
|
||||
dbus_route, 4, sizeof (guint32)));
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, routes);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_GATEWAY:
|
||||
|
|
@ -2291,19 +2271,27 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
case PROP_NAMESERVERS:
|
||||
g_value_set_boxed (value, priv->nameservers);
|
||||
g_value_take_variant (value,
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
|
||||
priv->nameservers->data,
|
||||
priv->nameservers->len,
|
||||
sizeof (guint32)));
|
||||
break;
|
||||
case PROP_DOMAINS:
|
||||
g_value_set_boxed (value, priv->domains);
|
||||
nm_utils_g_value_set_strv (value, priv->domains);
|
||||
break;
|
||||
case PROP_SEARCHES:
|
||||
g_value_set_boxed (value, priv->searches);
|
||||
nm_utils_g_value_set_strv (value, priv->searches);
|
||||
break;
|
||||
case PROP_DNS_OPTIONS:
|
||||
g_value_set_boxed (value, priv->dns_options);
|
||||
nm_utils_g_value_set_strv (value, priv->dns_options);
|
||||
break;
|
||||
case PROP_WINS_SERVERS:
|
||||
g_value_set_boxed (value, priv->wins);
|
||||
g_value_take_variant (value,
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_UINT32,
|
||||
priv->wins->data,
|
||||
priv->wins->len,
|
||||
sizeof (guint32)));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -2344,65 +2332,72 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
|||
object_class->finalize = finalize;
|
||||
|
||||
obj_properties[PROP_IFINDEX] =
|
||||
g_param_spec_int (NM_IP4_CONFIG_IFINDEX, "", "",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_int (NM_IP4_CONFIG_IFINDEX, "", "",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ADDRESS_DATA] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_ADDRESS_DATA, "", "",
|
||||
DBUS_TYPE_NM_IP_ADDRESSES,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_ADDRESS_DATA, "", "",
|
||||
G_VARIANT_TYPE ("aa{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ADDRESSES] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_ADDRESSES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_ADDRESSES, "", "",
|
||||
G_VARIANT_TYPE ("aau"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ROUTE_DATA] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_ROUTE_DATA, "", "",
|
||||
DBUS_TYPE_NM_IP_ROUTES,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_ROUTE_DATA, "", "",
|
||||
G_VARIANT_TYPE ("aa{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ROUTES] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_ROUTES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_ROUTES, "", "",
|
||||
G_VARIANT_TYPE ("aau"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_GATEWAY] =
|
||||
g_param_spec_string (NM_IP4_CONFIG_GATEWAY, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_NAMESERVERS] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_NAMESERVERS, "", "",
|
||||
G_VARIANT_TYPE ("au"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_DOMAINS] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_SEARCHES] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_DNS_OPTIONS] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_DNS_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_WINS_SERVERS] =
|
||||
g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP4_CONFIG_WINS_SERVERS, "", "",
|
||||
G_VARIANT_TYPE ("au"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
|
||||
&dbus_glib_nm_ip4_config_object_info);
|
||||
NMDBUS_TYPE_IP4_CONFIG_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@
|
|||
|
||||
#include "nm-utils.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-ip6-config-glue.h"
|
||||
#include "nm-route-manager.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-macros-internal.h"
|
||||
|
||||
#include "nmdbus-ip6-config.h"
|
||||
|
||||
G_DEFINE_TYPE (NMIP6Config, nm_ip6_config, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
#define NM_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP6_CONFIG, NMIP6ConfigPrivate))
|
||||
|
|
@ -1891,31 +1891,21 @@ finalize (GObject *object)
|
|||
static void
|
||||
nameservers_to_gvalue (GArray *array, GValue *value)
|
||||
{
|
||||
GPtrArray *dns;
|
||||
GVariantBuilder builder;
|
||||
guint i = 0;
|
||||
|
||||
dns = g_ptr_array_new ();
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay"));
|
||||
|
||||
while (array && (i < array->len)) {
|
||||
struct in6_addr *addr;
|
||||
GByteArray *bytearray;
|
||||
addr = &g_array_index (array, struct in6_addr, i++);
|
||||
|
||||
bytearray = g_byte_array_sized_new (16);
|
||||
g_byte_array_append (bytearray, (guint8 *) addr->s6_addr, 16);
|
||||
g_ptr_array_add (dns, bytearray);
|
||||
addr = &g_array_index (array, struct in6_addr, i++);
|
||||
g_variant_builder_add (&builder, "@ay",
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
&addr, 16, 1));
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, dns);
|
||||
}
|
||||
|
||||
static void
|
||||
gvalue_destroy (gpointer data)
|
||||
{
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
g_value_unset (value);
|
||||
g_slice_free (GValue, value);
|
||||
g_value_take_variant (value, g_variant_builder_end (&builder));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1931,163 +1921,109 @@ get_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_ADDRESS_DATA:
|
||||
{
|
||||
GPtrArray *addresses = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder, addr_builder;
|
||||
int naddr = nm_ip6_config_get_num_addresses (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aa{sv}"));
|
||||
for (i = 0; i < naddr; i++) {
|
||||
const NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
|
||||
GHashTable *addr_hash;
|
||||
GValue *val;
|
||||
|
||||
addr_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gvalue_destroy);
|
||||
g_variant_builder_init (&addr_builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
g_variant_builder_add (&addr_builder, "{sv}",
|
||||
"address",
|
||||
g_variant_new_string (nm_utils_inet6_ntop (&address->address, NULL)));
|
||||
g_variant_builder_add (&addr_builder, "{sv}",
|
||||
"prefix",
|
||||
g_variant_new_uint32 (address->plen));
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet6_ntop (&address->address, NULL));
|
||||
g_hash_table_insert (addr_hash, "address", val);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, address->plen);
|
||||
g_hash_table_insert (addr_hash, "prefix", val);
|
||||
|
||||
g_ptr_array_add (addresses, addr_hash);
|
||||
g_variant_builder_add (&array_builder, "a{sv}", &addr_builder);
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, addresses);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
{
|
||||
GPtrArray *addresses = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder;
|
||||
const struct in6_addr *gateway = nm_ip6_config_get_gateway (config);
|
||||
int naddr = nm_ip6_config_get_num_addresses (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a(ayuay)"));
|
||||
for (i = 0; i < naddr; i++) {
|
||||
const NMPlatformIP6Address *address = nm_ip6_config_get_address (config, i);
|
||||
|
||||
GValueArray *array = g_value_array_new (3);
|
||||
GValue element = G_VALUE_INIT;
|
||||
GByteArray *ba;
|
||||
|
||||
/* IP address */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) &address->address, 16);
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* Prefix */
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, address->plen);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* Gateway */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) (i == 0 && gateway ? gateway : &in6addr_any), sizeof (*gateway));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (addresses, array);
|
||||
g_variant_builder_add (&array_builder, "(@ayu@ay)",
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
&address->address, 16, 1),
|
||||
address->plen,
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
(i == 0 && gateway ? gateway : &in6addr_any),
|
||||
16, 1));
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, addresses);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ROUTE_DATA:
|
||||
{
|
||||
GPtrArray *routes = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder, route_builder;
|
||||
guint nroutes = nm_ip6_config_get_num_routes (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aa{sv}"));
|
||||
for (i = 0; i < nroutes; i++) {
|
||||
const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
|
||||
GHashTable *route_hash;
|
||||
GValue *val;
|
||||
|
||||
route_hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gvalue_destroy);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet6_ntop (&route->network, NULL));
|
||||
g_hash_table_insert (route_hash, "dest", val);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, route->plen);
|
||||
g_hash_table_insert (route_hash, "prefix", val);
|
||||
|
||||
g_variant_builder_init (&route_builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"dest",
|
||||
g_variant_new_string (nm_utils_inet6_ntop (&route->network, NULL)));
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"prefix",
|
||||
g_variant_new_uint32 (route->plen));
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED (&route->gateway)) {
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, nm_utils_inet6_ntop (&route->gateway, NULL));
|
||||
g_hash_table_insert (route_hash, "next-hop", val);
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"next-hop",
|
||||
g_variant_new_string (nm_utils_inet6_ntop (&route->gateway, NULL)));
|
||||
}
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, route->metric);
|
||||
g_hash_table_insert (route_hash, "metric", val);
|
||||
g_variant_builder_add (&route_builder, "{sv}",
|
||||
"metric",
|
||||
g_variant_new_uint32 (route->metric));
|
||||
|
||||
g_ptr_array_add (routes, route_hash);
|
||||
g_variant_builder_add (&array_builder, "a{sv}", &route_builder);
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, routes);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
{
|
||||
GPtrArray *routes = g_ptr_array_new ();
|
||||
GVariantBuilder array_builder;
|
||||
int nroutes = nm_ip6_config_get_num_routes (config);
|
||||
int i;
|
||||
|
||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a(ayuayu)"));
|
||||
for (i = 0; i < nroutes; i++) {
|
||||
GValueArray *array;
|
||||
const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i);
|
||||
GByteArray *ba;
|
||||
GValue element = G_VALUE_INIT;
|
||||
|
||||
/* legacy versions of nm_ip6_route_set_prefix() in libnm-util assert that the
|
||||
* plen is positive. Skip the default routes not to break older clients. */
|
||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route))
|
||||
continue;
|
||||
|
||||
array = g_value_array_new (4);
|
||||
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) &route->network, sizeof (route->network));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, route->plen);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) &route->gateway, sizeof (route->gateway));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, route->metric);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (routes, array);
|
||||
g_variant_builder_add (&array_builder, "(@ayu@ayu)",
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
&route->network, 16, 1),
|
||||
g_variant_new_uint32 (route->plen),
|
||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
&route->gateway, 16, 1),
|
||||
g_variant_new_uint32 (route->metric));
|
||||
}
|
||||
|
||||
g_value_take_boxed (value, routes);
|
||||
g_value_take_variant (value, g_variant_builder_end (&array_builder));
|
||||
}
|
||||
break;
|
||||
case PROP_GATEWAY:
|
||||
|
|
@ -2100,13 +2036,13 @@ get_property (GObject *object, guint prop_id,
|
|||
nameservers_to_gvalue (priv->nameservers, value);
|
||||
break;
|
||||
case PROP_DOMAINS:
|
||||
g_value_set_boxed (value, priv->domains);
|
||||
nm_utils_g_value_set_strv (value, priv->domains);
|
||||
break;
|
||||
case PROP_SEARCHES:
|
||||
g_value_set_boxed (value, priv->searches);
|
||||
nm_utils_g_value_set_strv (value, priv->searches);
|
||||
break;
|
||||
case PROP_DNS_OPTIONS:
|
||||
g_value_set_boxed (value, priv->dns_options);
|
||||
nm_utils_g_value_set_strv (value, priv->dns_options);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -2149,59 +2085,65 @@ nm_ip6_config_class_init (NMIP6ConfigClass *config_class)
|
|||
|
||||
/* properties */
|
||||
obj_properties[PROP_IFINDEX] =
|
||||
g_param_spec_int (NM_IP6_CONFIG_IFINDEX, "", "",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_int (NM_IP6_CONFIG_IFINDEX, "", "",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ADDRESS_DATA] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_ADDRESS_DATA, "", "",
|
||||
DBUS_TYPE_NM_IP_ADDRESSES,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP6_CONFIG_ADDRESS_DATA, "", "",
|
||||
G_VARIANT_TYPE ("aa{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ADDRESSES] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_ADDRESSES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP6_CONFIG_ADDRESSES, "", "",
|
||||
G_VARIANT_TYPE ("a(ayuay)"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ROUTE_DATA] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_ROUTE_DATA, "", "",
|
||||
DBUS_TYPE_NM_IP_ROUTES,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP6_CONFIG_ROUTE_DATA, "", "",
|
||||
G_VARIANT_TYPE ("aa{sv}"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_ROUTES] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_ROUTES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP6_CONFIG_ROUTES, "", "",
|
||||
G_VARIANT_TYPE ("a(ayuayu)"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_GATEWAY] =
|
||||
g_param_spec_string (NM_IP6_CONFIG_GATEWAY, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_NAMESERVERS] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_NAMESERVERS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_variant (NM_IP6_CONFIG_NAMESERVERS, "", "",
|
||||
G_VARIANT_TYPE ("aay"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_DOMAINS] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_DOMAINS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_DOMAINS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_SEARCHES] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_SEARCHES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_SEARCHES, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
obj_properties[PROP_DNS_OPTIONS] =
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_DNS_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_param_spec_boxed (NM_IP6_CONFIG_DNS_OPTIONS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (config_class),
|
||||
&dbus_glib_nm_ip6_config_object_info);
|
||||
NMDBUS_TYPE_IP6_CONFIG_SKELETON,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
824
src/nm-manager.c
824
src/nm-manager.c
File diff suppressed because it is too large
Load diff
|
|
@ -75,18 +75,17 @@ typedef struct {
|
|||
|
||||
GType nm_manager_get_type (void);
|
||||
|
||||
/* nm_manager_new() should only be used by main.c */
|
||||
NMManager * nm_manager_new (NMSettings *settings,
|
||||
const char *state_file,
|
||||
/* nm_manager_setup() should only be used by main.c */
|
||||
NMManager * nm_manager_setup (const char *state_file,
|
||||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
gboolean initial_wwan_enabled,
|
||||
gboolean initial_wimax_enabled,
|
||||
GError **error);
|
||||
gboolean initial_wimax_enabled);
|
||||
|
||||
NMManager * nm_manager_get (void);
|
||||
|
||||
void nm_manager_start (NMManager *manager);
|
||||
gboolean nm_manager_start (NMManager *manager,
|
||||
GError **error);
|
||||
void nm_manager_stop (NMManager *manager);
|
||||
NMState nm_manager_get_state (NMManager *manager);
|
||||
const GSList *nm_manager_get_active_connections (NMManager *manager);
|
||||
|
|
|
|||
|
|
@ -48,22 +48,7 @@
|
|||
#include "nm-platform.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
static void impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static gboolean impl_ppp_manager_set_state (NMPPPManager *manager,
|
||||
guint32 state,
|
||||
GError **err);
|
||||
|
||||
static gboolean impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
||||
GHashTable *config,
|
||||
GError **err);
|
||||
|
||||
static gboolean impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
|
||||
GHashTable *config,
|
||||
GError **err);
|
||||
|
||||
#include "nm-ppp-manager-glue.h"
|
||||
#include "nmdbus-ppp-manager.h"
|
||||
|
||||
static void _ppp_cleanup (NMPPPManager *manager);
|
||||
static void _ppp_kill (NMPPPManager *manager);
|
||||
|
|
@ -77,7 +62,7 @@ typedef struct {
|
|||
char *parent_iface;
|
||||
|
||||
NMActRequest *act_req;
|
||||
DBusGMethodInvocation *pending_secrets_context;
|
||||
GDBusMethodInvocation *pending_secrets_context;
|
||||
guint32 secrets_id;
|
||||
const char *secrets_setting_name;
|
||||
|
||||
|
|
@ -341,14 +326,13 @@ ppp_secrets_cb (NMActRequest *req,
|
|||
|
||||
if (error) {
|
||||
nm_log_warn (LOGD_PPP, "%s", error->message);
|
||||
dbus_g_method_return_error (priv->pending_secrets_context, error);
|
||||
g_dbus_method_invocation_return_gerror (priv->pending_secrets_context, error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!extract_details_from_connection (connection, priv->secrets_setting_name, &username, &password, &local)) {
|
||||
nm_log_warn (LOGD_PPP, "%s", local->message);
|
||||
dbus_g_method_return_error (priv->pending_secrets_context, local);
|
||||
g_clear_error (&local);
|
||||
g_dbus_method_invocation_take_error (priv->pending_secrets_context, local);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +342,9 @@ ppp_secrets_cb (NMActRequest *req,
|
|||
* against libnm just to parse this. So instead, let's just send what
|
||||
* it needs.
|
||||
*/
|
||||
dbus_g_method_return (priv->pending_secrets_context, username, password);
|
||||
g_dbus_method_invocation_return_value (
|
||||
priv->pending_secrets_context,
|
||||
g_variant_new ("(ss)", username, password));
|
||||
|
||||
out:
|
||||
priv->pending_secrets_context = NULL;
|
||||
|
|
@ -368,7 +354,7 @@ ppp_secrets_cb (NMActRequest *req,
|
|||
|
||||
static void
|
||||
impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMConnection *connection;
|
||||
|
|
@ -391,8 +377,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
|||
ppp_secrets_cb (priv->act_req, priv->secrets_id, connection, NULL, manager);
|
||||
} else {
|
||||
nm_log_warn (LOGD_PPP, "%s", error->message);
|
||||
dbus_g_method_return_error (priv->pending_secrets_context, error);
|
||||
g_clear_error (&error);
|
||||
g_dbus_method_invocation_take_error (priv->pending_secrets_context, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -418,33 +403,33 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
|
|||
g_ptr_array_free (hints, TRUE);
|
||||
}
|
||||
|
||||
static gboolean impl_ppp_manager_set_state (NMPPPManager *manager,
|
||||
guint32 state,
|
||||
GError **err)
|
||||
static void
|
||||
impl_ppp_manager_set_state (NMPPPManager *manager,
|
||||
GDBusMethodInvocation *context,
|
||||
guint32 state)
|
||||
{
|
||||
g_signal_emit (manager, signals[STATE_CHANGED], 0, state);
|
||||
|
||||
return TRUE;
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_ip_config_common (NMPPPManager *self,
|
||||
GHashTable *hash,
|
||||
GVariant *config_dict,
|
||||
const char *iface_prop,
|
||||
guint32 *out_mtu)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
|
||||
NMConnection *connection;
|
||||
NMSettingPpp *s_ppp;
|
||||
GValue *val;
|
||||
const char *iface;
|
||||
|
||||
val = g_hash_table_lookup (hash, iface_prop);
|
||||
if (!val || !G_VALUE_HOLDS_STRING (val)) {
|
||||
if (!g_variant_lookup (config_dict, iface_prop, "&s", &iface)) {
|
||||
nm_log_err (LOGD_PPP, "no interface received!");
|
||||
return FALSE;
|
||||
}
|
||||
if (priv->ip_iface == NULL)
|
||||
priv->ip_iface = g_value_dup_string (val);
|
||||
priv->ip_iface = g_strdup (iface);
|
||||
|
||||
/* Got successful IP config; obviously the secrets worked */
|
||||
connection = nm_act_request_get_connection (priv->act_req);
|
||||
|
|
@ -460,17 +445,16 @@ set_ip_config_common (NMPPPManager *self,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
||||
GHashTable *config_hash,
|
||||
GError **err)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *config_dict)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMIP4Config *config;
|
||||
NMPlatformIP4Address address;
|
||||
GValue *val;
|
||||
int i;
|
||||
guint32 mtu = 0;
|
||||
guint32 u32;
|
||||
GVariantIter *iter;
|
||||
|
||||
nm_log_info (LOGD_PPP, "PPP manager (IPv4 Config Get) reply received.");
|
||||
|
||||
|
|
@ -481,19 +465,16 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
memset (&address, 0, sizeof (address));
|
||||
address.plen = 32;
|
||||
|
||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_GATEWAY);
|
||||
if (val) {
|
||||
nm_ip4_config_set_gateway (config, g_value_get_uint (val));
|
||||
address.peer_address = g_value_get_uint (val);
|
||||
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_GATEWAY, "u", &u32)) {
|
||||
nm_ip4_config_set_gateway (config, u32);
|
||||
address.peer_address = u32;
|
||||
}
|
||||
|
||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_ADDRESS);
|
||||
if (val)
|
||||
address.address = g_value_get_uint (val);
|
||||
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_ADDRESS, "u", &u32))
|
||||
address.address = u32;
|
||||
|
||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_PREFIX);
|
||||
if (val)
|
||||
address.plen = g_value_get_uint (val);
|
||||
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_PREFIX, "u", &u32))
|
||||
address.plen = u32;
|
||||
|
||||
if (address.address && address.plen) {
|
||||
address.source = NM_IP_CONFIG_SOURCE_PPP;
|
||||
|
|
@ -503,55 +484,47 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||
goto out;
|
||||
}
|
||||
|
||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_DNS);
|
||||
if (val) {
|
||||
GArray *dns = (GArray *) g_value_get_boxed (val);
|
||||
|
||||
for (i = 0; i < dns->len; i++)
|
||||
nm_ip4_config_add_nameserver (config, g_array_index (dns, guint, i));
|
||||
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_DNS, "au", &iter)) {
|
||||
while (g_variant_iter_next (iter, "u", &u32))
|
||||
nm_ip4_config_add_nameserver (config, u32);
|
||||
g_variant_iter_free (iter);
|
||||
}
|
||||
|
||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_WINS);
|
||||
if (val) {
|
||||
GArray *wins = (GArray *) g_value_get_boxed (val);
|
||||
|
||||
for (i = 0; i < wins->len; i++)
|
||||
nm_ip4_config_add_wins (config, g_array_index (wins, guint, i));
|
||||
if (g_variant_lookup (config_dict, NM_PPP_IP4_CONFIG_WINS, "au", &iter)) {
|
||||
while (g_variant_iter_next (iter, "u", &u32))
|
||||
nm_ip4_config_add_wins (config, u32);
|
||||
g_variant_iter_free (iter);
|
||||
}
|
||||
|
||||
if (!set_ip_config_common (manager, config_hash, NM_PPP_IP4_CONFIG_INTERFACE, &mtu))
|
||||
if (!set_ip_config_common (manager, config_dict, NM_PPP_IP4_CONFIG_INTERFACE, &u32))
|
||||
goto out;
|
||||
|
||||
if (mtu)
|
||||
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_PPP);
|
||||
if (u32)
|
||||
nm_ip4_config_set_mtu (config, u32, NM_IP_CONFIG_SOURCE_PPP);
|
||||
|
||||
/* Push the IP4 config up to the device */
|
||||
g_signal_emit (manager, signals[IP4_CONFIG], 0, priv->ip_iface, config);
|
||||
|
||||
out:
|
||||
g_object_unref (config);
|
||||
return TRUE;
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
}
|
||||
|
||||
/* Converts the named Interface Identifier item to an IPv6 LL address and
|
||||
* returns the IID.
|
||||
*/
|
||||
static gboolean
|
||||
iid_value_to_ll6_addr (GHashTable *hash,
|
||||
iid_value_to_ll6_addr (GVariant *dict,
|
||||
const char *prop,
|
||||
struct in6_addr *out_addr,
|
||||
NMUtilsIPv6IfaceId *out_iid)
|
||||
{
|
||||
GValue *val;
|
||||
guint64 iid;
|
||||
|
||||
val = g_hash_table_lookup (hash, prop);
|
||||
if (!val || !G_VALUE_HOLDS (val, G_TYPE_UINT64)) {
|
||||
if (!g_variant_lookup (dict, prop, "t", &iid)) {
|
||||
nm_log_dbg (LOGD_PPP, "pppd plugin property '%s' missing or not a uint64", prop);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
iid = g_value_get_uint64 (val);
|
||||
g_return_val_if_fail (iid != 0, FALSE);
|
||||
|
||||
/* Construct an IPv6 LL address from the interface identifier. See
|
||||
|
|
@ -566,10 +539,10 @@ iid_value_to_ll6_addr (GHashTable *hash,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
|
||||
GHashTable *hash,
|
||||
GError **err)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *config_dict)
|
||||
{
|
||||
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
|
||||
NMIP6Config *config;
|
||||
|
|
@ -586,15 +559,15 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
|
|||
memset (&addr, 0, sizeof (addr));
|
||||
addr.plen = 64;
|
||||
|
||||
if (iid_value_to_ll6_addr (hash, NM_PPP_IP6_CONFIG_PEER_IID, &a, NULL)) {
|
||||
if (iid_value_to_ll6_addr (config_dict, NM_PPP_IP6_CONFIG_PEER_IID, &a, NULL)) {
|
||||
nm_ip6_config_set_gateway (config, &a);
|
||||
addr.peer_address = a;
|
||||
}
|
||||
|
||||
if (iid_value_to_ll6_addr (hash, NM_PPP_IP6_CONFIG_OUR_IID, &addr.address, &iid)) {
|
||||
if (iid_value_to_ll6_addr (config_dict, NM_PPP_IP6_CONFIG_OUR_IID, &addr.address, &iid)) {
|
||||
nm_ip6_config_add_address (config, &addr);
|
||||
|
||||
if (set_ip_config_common (manager, hash, NM_PPP_IP6_CONFIG_INTERFACE, NULL)) {
|
||||
if (set_ip_config_common (manager, config_dict, NM_PPP_IP6_CONFIG_INTERFACE, NULL)) {
|
||||
/* Push the IPv6 config and interface identifier up to the device */
|
||||
g_signal_emit (manager, signals[IP6_CONFIG], 0, priv->ip_iface, &iid, config);
|
||||
}
|
||||
|
|
@ -602,7 +575,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
|
|||
nm_log_err (LOGD_PPP, "invalid IPv6 address received!");
|
||||
|
||||
g_object_unref (config);
|
||||
return TRUE;
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -667,7 +640,12 @@ nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
|
|||
G_TYPE_UINT, G_TYPE_UINT);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (manager_class),
|
||||
&dbus_glib_nm_ppp_manager_object_info);
|
||||
NMDBUS_TYPE_PPP_MANAGER_SKELETON,
|
||||
"NeedSecrets", impl_ppp_manager_need_secrets,
|
||||
"SetIp4Config", impl_ppp_manager_set_ip4_config,
|
||||
"SetIp6Config", impl_ppp_manager_set_ip6_config,
|
||||
"SetState", impl_ppp_manager_set_state,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*******************************************/
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ AM_CPPFLAGS = \
|
|||
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
||||
AM_LDFLAGS = \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(CODE_COVERAGE_LDFLAGS)
|
||||
|
||||
@GNOME_CODE_COVERAGE_RULES@
|
||||
|
|
|
|||
|
|
@ -23,16 +23,11 @@
|
|||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-agent-manager.h"
|
||||
#include "nm-secret-agent.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-setting-vpn.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-enum-types.h"
|
||||
|
|
@ -41,6 +36,9 @@
|
|||
#include "nm-session-monitor.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nmdbus-agent-manager.h"
|
||||
|
||||
G_DEFINE_TYPE (NMAgentManager, nm_agent_manager, NM_TYPE_EXPORTED_OBJECT)
|
||||
|
||||
|
|
@ -78,20 +76,6 @@ static void request_remove_agent (Request *req, NMSecretAgent *agent, GSList **p
|
|||
|
||||
static void request_next_agent (Request *req);
|
||||
|
||||
static void impl_agent_manager_register (NMAgentManager *self,
|
||||
const char *identifier,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_agent_manager_register_with_capabilities (NMAgentManager *self,
|
||||
const char *identifier,
|
||||
NMSecretAgentCapabilities capabilities,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_agent_manager_unregister (NMAgentManager *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
#include "nm-agent-manager-glue.h"
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -130,6 +114,17 @@ remove_agent (NMAgentManager *self, const char *owner)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Call this *after* calling request_next_agent() */
|
||||
static void
|
||||
maybe_remove_agent_on_error (NMSecretAgent *agent,
|
||||
GError *error)
|
||||
{
|
||||
if ( g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED)
|
||||
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED)
|
||||
|| g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))
|
||||
remove_agent (nm_agent_manager_get (), nm_secret_agent_get_dbus_owner (agent));
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -190,7 +185,7 @@ validate_identifier (const char *identifier, GError **error)
|
|||
static void
|
||||
agent_register_permissions_done (NMAuthChain *chain,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMAgentManager *self = NM_AGENT_MANAGER (user_data);
|
||||
|
|
@ -211,8 +206,7 @@ agent_register_permissions_done (NMAuthChain *chain,
|
|||
NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
"Failed to request agent permissions: (%d) %s",
|
||||
error->code, error->message);
|
||||
dbus_g_method_return_error (context, local);
|
||||
g_error_free (local);
|
||||
g_dbus_method_invocation_take_error (context, local);
|
||||
} else {
|
||||
agent = nm_auth_chain_steal_data (chain, "agent");
|
||||
g_assert (agent);
|
||||
|
|
@ -229,7 +223,7 @@ agent_register_permissions_done (NMAuthChain *chain,
|
|||
g_hash_table_insert (priv->agents, g_strdup (sender), agent);
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s) agent registered",
|
||||
nm_secret_agent_get_description (agent));
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
|
||||
/* Signal an agent was registered */
|
||||
g_signal_emit (self, signals[AGENT_REGISTERED], 0, agent);
|
||||
|
|
@ -271,9 +265,9 @@ agent_disconnected_cb (NMSecretAgent *agent, gpointer user_data)
|
|||
|
||||
static void
|
||||
impl_agent_manager_register_with_capabilities (NMAgentManager *self,
|
||||
GDBusMethodInvocation *context,
|
||||
const char *identifier,
|
||||
NMSecretAgentCapabilities capabilities,
|
||||
DBusGMethodInvocation *context)
|
||||
guint32 capabilities)
|
||||
{
|
||||
NMAgentManagerPrivate *priv = NM_AGENT_MANAGER_GET_PRIVATE (self);
|
||||
NMAuthSubject *subject;
|
||||
|
|
@ -334,22 +328,21 @@ impl_agent_manager_register_with_capabilities (NMAgentManager *self,
|
|||
|
||||
done:
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_clear_error (&error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
g_clear_object (&subject);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_agent_manager_register (NMAgentManager *self,
|
||||
const char *identifier,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
const char *identifier)
|
||||
{
|
||||
impl_agent_manager_register_with_capabilities (self, identifier, 0, context);
|
||||
impl_agent_manager_register_with_capabilities (self, context, identifier, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_agent_manager_unregister (NMAgentManager *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *sender = NULL;
|
||||
|
|
@ -373,19 +366,18 @@ impl_agent_manager_unregister (NMAgentManager *self,
|
|||
goto done;
|
||||
}
|
||||
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
|
||||
done:
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_clear_error (&error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
g_free (sender);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
typedef void (*RequestCompleteFunc) (Request *req,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
const char *agent_dbus_owner,
|
||||
const char *agent_username,
|
||||
GError *error,
|
||||
|
|
@ -481,7 +473,7 @@ request_free (Request *req)
|
|||
|
||||
static void
|
||||
req_complete_success (Request *req,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
const char *agent_dbus_owner,
|
||||
const char *agent_uname)
|
||||
{
|
||||
|
|
@ -658,7 +650,7 @@ typedef struct {
|
|||
char *setting_name;
|
||||
char **hints;
|
||||
|
||||
GHashTable *existing_secrets;
|
||||
GVariant *existing_secrets;
|
||||
|
||||
NMAgentSecretsResultFunc callback;
|
||||
gpointer callback_data;
|
||||
|
|
@ -682,7 +674,7 @@ connection_request_free (gpointer data)
|
|||
g_free (req->setting_name);
|
||||
g_strfreev (req->hints);
|
||||
if (req->existing_secrets)
|
||||
g_hash_table_unref (req->existing_secrets);
|
||||
g_variant_unref (req->existing_secrets);
|
||||
if (req->chain)
|
||||
nm_auth_chain_unref (req->chain);
|
||||
}
|
||||
|
|
@ -710,7 +702,7 @@ connection_request_add_agent (Request *parent, NMSecretAgent *agent)
|
|||
static ConnectionRequest *
|
||||
connection_request_new_get (NMConnection *connection,
|
||||
NMAuthSubject *subject,
|
||||
GHashTable *existing_secrets,
|
||||
GVariant *existing_secrets,
|
||||
const char *setting_name,
|
||||
const char *verb,
|
||||
NMSecretAgentGetSecretsFlags flags,
|
||||
|
|
@ -740,7 +732,7 @@ connection_request_new_get (NMConnection *connection,
|
|||
|
||||
req->connection = g_object_ref (connection);
|
||||
if (existing_secrets)
|
||||
req->existing_secrets = g_hash_table_ref (existing_secrets);
|
||||
req->existing_secrets = g_variant_ref (existing_secrets);
|
||||
req->setting_name = g_strdup (setting_name);
|
||||
req->hints = g_strdupv ((char **) hints);
|
||||
req->flags = flags;
|
||||
|
|
@ -779,13 +771,13 @@ connection_request_new_other (NMConnection *connection,
|
|||
static void
|
||||
get_done_cb (NMSecretAgent *agent,
|
||||
gconstpointer call_id,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
Request *parent = user_data;
|
||||
ConnectionRequest *req = user_data;
|
||||
GHashTable *setting_secrets;
|
||||
GVariant *setting_secrets;
|
||||
const char *agent_dbus_owner;
|
||||
struct passwd *pw;
|
||||
char *agent_uname = NULL;
|
||||
|
|
@ -799,7 +791,7 @@ get_done_cb (NMSecretAgent *agent,
|
|||
error ? error->code : -1,
|
||||
(error && error->message) ? error->message : "(unknown)");
|
||||
|
||||
if (dbus_g_error_has_name (error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) {
|
||||
if (_nm_dbus_error_has_name (error, NM_DBUS_INTERFACE_SECRET_AGENT ".UserCanceled")) {
|
||||
error = g_error_new_literal (NM_AGENT_MANAGER_ERROR,
|
||||
NM_AGENT_MANAGER_ERROR_USER_CANCELED,
|
||||
"User canceled the secrets request.");
|
||||
|
|
@ -808,13 +800,14 @@ get_done_cb (NMSecretAgent *agent,
|
|||
} else {
|
||||
/* Try the next agent */
|
||||
request_next_agent (parent);
|
||||
maybe_remove_agent_on_error (agent, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ensure the setting we wanted secrets for got returned and has something in it */
|
||||
setting_secrets = g_hash_table_lookup (secrets, req->setting_name);
|
||||
if (!setting_secrets || !g_hash_table_size (setting_secrets)) {
|
||||
setting_secrets = g_variant_lookup_value (secrets, req->setting_name, NM_VARIANT_TYPE_SETTING);
|
||||
if (!setting_secrets || !g_variant_n_children (setting_secrets)) {
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s) agent returned no secrets for request %p/%s/%s",
|
||||
nm_secret_agent_get_description (agent),
|
||||
req, parent->detail, req->setting_name);
|
||||
|
|
@ -841,40 +834,40 @@ get_done_cb (NMSecretAgent *agent,
|
|||
}
|
||||
|
||||
static void
|
||||
set_secrets_not_required (NMConnection *connection, GHashTable *hash)
|
||||
set_secrets_not_required (NMConnection *connection, GVariant *dict)
|
||||
{
|
||||
GHashTableIter iter, setting_iter;
|
||||
GVariantIter iter, setting_iter;
|
||||
const char *setting_name = NULL;
|
||||
GHashTable *setting_hash = NULL;
|
||||
GVariant *setting_dict = NULL;
|
||||
|
||||
/* Iterate through the settings hashes */
|
||||
g_hash_table_iter_init (&iter, hash);
|
||||
while (g_hash_table_iter_next (&iter,
|
||||
(gpointer *) &setting_name,
|
||||
(gpointer *) &setting_hash)) {
|
||||
/* Iterate through the settings dicts */
|
||||
g_variant_iter_init (&iter, dict);
|
||||
while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
|
||||
const char *key_name = NULL;
|
||||
NMSetting *setting;
|
||||
GValue *val;
|
||||
GVariant *val;
|
||||
|
||||
setting = nm_connection_get_setting_by_name (connection, setting_name);
|
||||
if (setting) {
|
||||
/* Now through each secret in the setting and mark it as not required */
|
||||
g_hash_table_iter_init (&setting_iter, setting_hash);
|
||||
while (g_hash_table_iter_next (&setting_iter, (gpointer *) &key_name, (gpointer *) &val)) {
|
||||
g_variant_iter_init (&setting_iter, setting_dict);
|
||||
while (g_variant_iter_next (&setting_iter, "{&sv}", &key_name, &val)) {
|
||||
/* For each secret, set the flag that it's not required; VPN
|
||||
* secrets need slightly different treatment here since the
|
||||
* "secrets" property is actually a hash table of secrets.
|
||||
* "secrets" property is actually a dictionary of secrets.
|
||||
*/
|
||||
if ( strcmp (setting_name, NM_SETTING_VPN_SETTING_NAME) == 0
|
||||
&& strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0) {
|
||||
GHashTableIter vpn_secret_iter;
|
||||
const char *secret_name;
|
||||
&& strcmp (key_name, NM_SETTING_VPN_SECRETS) == 0
|
||||
&& g_variant_is_of_type (val, G_VARIANT_TYPE ("a{ss}"))) {
|
||||
GVariantIter vpn_secret_iter;
|
||||
const char *secret_name, *secret;
|
||||
|
||||
g_hash_table_iter_init (&vpn_secret_iter, g_value_get_boxed (val));
|
||||
while (g_hash_table_iter_next (&vpn_secret_iter, (gpointer *) &secret_name, NULL))
|
||||
g_variant_iter_init (&vpn_secret_iter, val);
|
||||
while (g_variant_iter_next (&vpn_secret_iter, "{&s&s}", &secret_name, &secret))
|
||||
nm_setting_set_secret_flags (setting, secret_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL);
|
||||
} else
|
||||
nm_setting_set_secret_flags (setting, key_name, NM_SETTING_SECRET_FLAG_NOT_REQUIRED, NULL);
|
||||
g_variant_unref (val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -889,13 +882,8 @@ get_agent_request_secrets (ConnectionRequest *req, gboolean include_system_secre
|
|||
tmp = nm_simple_connection_new_clone (req->connection);
|
||||
nm_connection_clear_secrets (tmp);
|
||||
if (include_system_secrets) {
|
||||
if (req->existing_secrets) {
|
||||
GVariant *secrets_dict;
|
||||
|
||||
secrets_dict = nm_utils_connection_hash_to_dict (req->existing_secrets);
|
||||
(void) nm_connection_update_secrets (tmp, req->setting_name, secrets_dict, NULL);
|
||||
g_variant_unref (secrets_dict);
|
||||
}
|
||||
if (req->existing_secrets)
|
||||
(void) nm_connection_update_secrets (tmp, req->setting_name, req->existing_secrets, NULL);
|
||||
} else {
|
||||
/* Update secret flags in the temporary connection to indicate that
|
||||
* the system secrets we're not sending to the agent aren't required,
|
||||
|
|
@ -924,7 +912,7 @@ get_agent_request_secrets (ConnectionRequest *req, gboolean include_system_secre
|
|||
static void
|
||||
get_agent_modify_auth_cb (NMAuthChain *chain,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
Request *parent = user_data;
|
||||
|
|
@ -1058,19 +1046,18 @@ get_start (gpointer user_data)
|
|||
{
|
||||
Request *parent = user_data;
|
||||
ConnectionRequest *req = user_data;
|
||||
GHashTable *setting_secrets = NULL;
|
||||
GVariant *setting_secrets = NULL;
|
||||
|
||||
parent->idle_id = 0;
|
||||
|
||||
/* Check if there are any existing secrets */
|
||||
if (req->existing_secrets)
|
||||
setting_secrets = g_hash_table_lookup (req->existing_secrets, req->setting_name);
|
||||
setting_secrets = g_variant_lookup_value (req->existing_secrets, req->setting_name, NM_VARIANT_TYPE_SETTING);
|
||||
|
||||
if (setting_secrets && g_hash_table_size (setting_secrets)) {
|
||||
if (setting_secrets && g_variant_n_children (setting_secrets)) {
|
||||
NMConnection *tmp;
|
||||
GError *error = NULL;
|
||||
gboolean new_secrets = (req->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW);
|
||||
GVariant *secrets_dict;
|
||||
|
||||
/* The connection already had secrets; check if any more are required.
|
||||
* If no more are required, we're done. If secrets are still needed,
|
||||
|
|
@ -1080,8 +1067,7 @@ get_start (gpointer user_data)
|
|||
tmp = nm_simple_connection_new_clone (req->connection);
|
||||
g_assert (tmp);
|
||||
|
||||
secrets_dict = nm_utils_connection_hash_to_dict (req->existing_secrets);
|
||||
if (!nm_connection_update_secrets (tmp, req->setting_name, secrets_dict, &error)) {
|
||||
if (!nm_connection_update_secrets (tmp, req->setting_name, req->existing_secrets, &error)) {
|
||||
req_complete_error (parent, error);
|
||||
g_clear_error (&error);
|
||||
} else {
|
||||
|
|
@ -1107,7 +1093,6 @@ get_start (gpointer user_data)
|
|||
request_next_agent (parent);
|
||||
}
|
||||
}
|
||||
g_variant_unref (secrets_dict);
|
||||
g_object_unref (tmp);
|
||||
} else {
|
||||
/* Couldn't get secrets from system settings, so now we ask the
|
||||
|
|
@ -1117,12 +1102,15 @@ get_start (gpointer user_data)
|
|||
request_next_agent (parent);
|
||||
}
|
||||
|
||||
if (setting_secrets)
|
||||
g_variant_unref (setting_secrets);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
get_complete_cb (Request *parent,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
const char *agent_dbus_owner,
|
||||
const char *agent_username,
|
||||
GError *error,
|
||||
|
|
@ -1163,7 +1151,7 @@ guint32
|
|||
nm_agent_manager_get_secrets (NMAgentManager *self,
|
||||
NMConnection *connection,
|
||||
NMAuthSubject *subject,
|
||||
GHashTable *existing_secrets,
|
||||
GVariant *existing_secrets,
|
||||
const char *setting_name,
|
||||
NMSecretAgentGetSecretsFlags flags,
|
||||
const char **hints,
|
||||
|
|
@ -1233,7 +1221,7 @@ nm_agent_manager_cancel_secrets (NMAgentManager *self,
|
|||
static void
|
||||
save_done_cb (NMSecretAgent *agent,
|
||||
gconstpointer call_id,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
|
@ -1251,6 +1239,7 @@ save_done_cb (NMSecretAgent *agent,
|
|||
(error && error->message) ? error->message : "(unknown)");
|
||||
/* Try the next agent */
|
||||
request_next_agent (parent);
|
||||
maybe_remove_agent_on_error (agent, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1280,7 +1269,7 @@ save_next_cb (Request *parent)
|
|||
|
||||
static void
|
||||
save_complete_cb (Request *req,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
const char *agent_dbus_owner,
|
||||
const char *agent_username,
|
||||
GError *error,
|
||||
|
|
@ -1327,7 +1316,7 @@ nm_agent_manager_save_secrets (NMAgentManager *self,
|
|||
static void
|
||||
delete_done_cb (NMSecretAgent *agent,
|
||||
gconstpointer call_id,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
|
@ -1347,6 +1336,8 @@ delete_done_cb (NMSecretAgent *agent,
|
|||
|
||||
/* Tell the next agent to delete secrets */
|
||||
request_next_agent (req);
|
||||
if (error)
|
||||
maybe_remove_agent_on_error (agent, error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1367,7 +1358,7 @@ delete_next_cb (Request *parent)
|
|||
|
||||
static void
|
||||
delete_complete_cb (Request *req,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
const char *agent_dbus_owner,
|
||||
const char *agent_username,
|
||||
GError *error,
|
||||
|
|
@ -1460,7 +1451,7 @@ nm_agent_manager_all_agents_have_capability (NMAgentManager *manager,
|
|||
static void
|
||||
agent_permissions_changed_done (NMAuthChain *chain,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMAgentManager *self = NM_AGENT_MANAGER (user_data);
|
||||
|
|
@ -1609,9 +1600,9 @@ nm_agent_manager_class_init (NMAgentManagerClass *agent_manager_class)
|
|||
G_TYPE_OBJECT);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (agent_manager_class),
|
||||
&dbus_glib_nm_agent_manager_object_info);
|
||||
|
||||
dbus_g_error_domain_register (NM_AGENT_MANAGER_ERROR,
|
||||
NM_DBUS_INTERFACE_AGENT_MANAGER,
|
||||
NM_TYPE_AGENT_MANAGER_ERROR);
|
||||
NMDBUS_TYPE_AGENT_MANAGER_SKELETON,
|
||||
"Register", impl_agent_manager_register,
|
||||
"RegisterWithCapabilities", impl_agent_manager_register_with_capabilities,
|
||||
"Unregister", impl_agent_manager_unregister,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager,
|
|||
gboolean agent_has_modify,
|
||||
const char *setting_name,
|
||||
NMSecretAgentGetSecretsFlags flags,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
GError *error,
|
||||
gpointer user_data,
|
||||
gpointer other_data2,
|
||||
|
|
@ -65,7 +65,7 @@ typedef void (*NMAgentSecretsResultFunc) (NMAgentManager *manager,
|
|||
guint32 nm_agent_manager_get_secrets (NMAgentManager *manager,
|
||||
NMConnection *connection,
|
||||
NMAuthSubject *subject,
|
||||
GHashTable *existing_secrets,
|
||||
GVariant *existing_secrets,
|
||||
const char *setting_name,
|
||||
NMSecretAgentGetSecretsFlags flags,
|
||||
const char **hints,
|
||||
|
|
|
|||
|
|
@ -23,17 +23,14 @@
|
|||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-secret-agent.h"
|
||||
#include "nm-bus-manager.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-auth-subject.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nmdbus-secret-agent.h"
|
||||
|
||||
G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT)
|
||||
|
||||
|
|
@ -52,7 +49,7 @@ typedef struct {
|
|||
|
||||
GSList *permissions;
|
||||
|
||||
DBusGProxy *proxy;
|
||||
NMDBusSecretAgent *proxy;
|
||||
|
||||
GHashTable *requests;
|
||||
} NMSecretAgentPrivate;
|
||||
|
|
@ -68,7 +65,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
|
||||
typedef struct {
|
||||
NMSecretAgent *agent;
|
||||
DBusGProxyCall *call;
|
||||
GCancellable *cancellable;
|
||||
char *path;
|
||||
char *setting_name;
|
||||
NMSecretAgentCallback callback;
|
||||
|
|
@ -90,6 +87,7 @@ request_new (NMSecretAgent *agent,
|
|||
r->setting_name = g_strdup (setting_name);
|
||||
r->callback = callback;
|
||||
r->callback_data = callback_data;
|
||||
r->cancellable = g_cancellable_new ();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +96,7 @@ request_free (Request *r)
|
|||
{
|
||||
g_free (r->path);
|
||||
g_free (r->setting_name);
|
||||
g_object_unref (r->cancellable);
|
||||
g_slice_free (Request, r);
|
||||
}
|
||||
|
||||
|
|
@ -258,25 +257,26 @@ nm_secret_agent_has_permission (NMSecretAgent *agent, const char *permission)
|
|||
/*************************************************************/
|
||||
|
||||
static void
|
||||
get_callback (DBusGProxy *proxy,
|
||||
DBusGProxyCall *call,
|
||||
void *user_data)
|
||||
get_callback (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
Request *r = user_data;
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
|
||||
GVariant *secrets = NULL;
|
||||
GError *error = NULL;
|
||||
GHashTable *secrets = NULL;
|
||||
|
||||
g_return_if_fail (call == r->call);
|
||||
if (!g_cancellable_is_cancelled (r->cancellable)) {
|
||||
nmdbus_secret_agent_call_get_secrets_finish (priv->proxy, &secrets, result, &error);
|
||||
if (error)
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
|
||||
dbus_g_proxy_end_call (proxy, call, &error,
|
||||
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &secrets,
|
||||
G_TYPE_INVALID);
|
||||
r->callback (r->agent, r->call, secrets, error, r->callback_data);
|
||||
if (secrets)
|
||||
g_hash_table_unref (secrets);
|
||||
g_clear_error (&error);
|
||||
g_hash_table_remove (priv->requests, call);
|
||||
r->callback (r->agent, r, secrets, error, r->callback_data);
|
||||
g_clear_pointer (&secrets, g_variant_unref);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_hash_table_remove (priv->requests, r);
|
||||
}
|
||||
|
||||
gconstpointer
|
||||
|
|
@ -289,8 +289,8 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
|
|||
gpointer callback_data)
|
||||
{
|
||||
NMSecretAgentPrivate *priv;
|
||||
static const char *no_hints[] = { NULL };
|
||||
GVariant *dict;
|
||||
GHashTable *hash;
|
||||
Request *r;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
|
@ -301,123 +301,81 @@ nm_secret_agent_get_secrets (NMSecretAgent *self,
|
|||
g_return_val_if_fail (priv->proxy != NULL, NULL);
|
||||
|
||||
dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
hash = nm_utils_connection_dict_to_hash (dict);
|
||||
g_variant_unref (dict);
|
||||
|
||||
/* Mask off the private flags if present */
|
||||
flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM;
|
||||
flags &= ~NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS;
|
||||
|
||||
r = request_new (self, nm_connection_get_path (connection), setting_name, callback, callback_data);
|
||||
r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
|
||||
"GetSecrets",
|
||||
get_callback,
|
||||
r,
|
||||
NULL,
|
||||
120000, /* 120 seconds */
|
||||
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
|
||||
DBUS_TYPE_G_OBJECT_PATH, nm_connection_get_path (connection),
|
||||
G_TYPE_STRING, setting_name,
|
||||
G_TYPE_STRV, hints,
|
||||
G_TYPE_UINT, flags,
|
||||
G_TYPE_INVALID);
|
||||
g_hash_table_insert (priv->requests, r->call, r);
|
||||
nmdbus_secret_agent_call_get_secrets (priv->proxy,
|
||||
dict,
|
||||
nm_connection_get_path (connection),
|
||||
setting_name,
|
||||
hints ? hints : no_hints,
|
||||
flags,
|
||||
r->cancellable,
|
||||
get_callback, r);
|
||||
g_hash_table_insert (priv->requests, r, r);
|
||||
|
||||
g_hash_table_destroy (hash);
|
||||
return r->call;
|
||||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_done (DBusGProxy *proxy, DBusGProxyCall *call_id, void *user_data)
|
||||
cancel_done (GObject *proxy, GAsyncResult *result, gpointer user_data)
|
||||
{
|
||||
char *description = user_data;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s): agent failed to cancel secrets: (%d) %s",
|
||||
(const char *) user_data,
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
if (!nmdbus_secret_agent_call_cancel_get_secrets_finish (NMDBUS_SECRET_AGENT (proxy), result, &error)) {
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
nm_log_dbg (LOGD_AGENTS, "(%s): agent failed to cancel secrets: %s",
|
||||
description, error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_free (description);
|
||||
}
|
||||
|
||||
void
|
||||
nm_secret_agent_cancel_secrets (NMSecretAgent *self, gconstpointer call)
|
||||
{
|
||||
NMSecretAgentPrivate *priv;
|
||||
Request *r;
|
||||
Request *r = (gpointer) call;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->proxy != NULL);
|
||||
|
||||
r = g_hash_table_lookup (priv->requests, call);
|
||||
g_return_if_fail (r != NULL);
|
||||
|
||||
dbus_g_proxy_cancel_call (priv->proxy, (gpointer) call);
|
||||
g_cancellable_cancel (r->cancellable);
|
||||
|
||||
dbus_g_proxy_begin_call (priv->proxy,
|
||||
"CancelGetSecrets",
|
||||
cancel_done,
|
||||
g_strdup (nm_secret_agent_get_description (self)),
|
||||
g_free,
|
||||
DBUS_TYPE_G_OBJECT_PATH, r->path,
|
||||
G_TYPE_STRING, r->setting_name,
|
||||
G_TYPE_INVALID);
|
||||
g_hash_table_remove (priv->requests, call);
|
||||
nmdbus_secret_agent_call_cancel_get_secrets (priv->proxy,
|
||||
r->path, r->setting_name,
|
||||
NULL,
|
||||
cancel_done,
|
||||
g_strdup (nm_secret_agent_get_description (self)));
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
static void
|
||||
agent_save_delete_cb (DBusGProxy *proxy,
|
||||
DBusGProxyCall *call,
|
||||
void *user_data)
|
||||
agent_save_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
Request *r = user_data;
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (call == r->call);
|
||||
if (!g_cancellable_is_cancelled (r->cancellable)) {
|
||||
nmdbus_secret_agent_call_save_secrets_finish (priv->proxy, result, &error);
|
||||
if (error)
|
||||
g_dbus_error_strip_remote_error (error);
|
||||
r->callback (r->agent, r, NULL, error, r->callback_data);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
|
||||
r->callback (r->agent, r->call, NULL, error, r->callback_data);
|
||||
g_clear_error (&error);
|
||||
g_hash_table_remove (priv->requests, call);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
agent_new_save_delete (NMSecretAgent *self,
|
||||
NMConnection *connection,
|
||||
NMConnectionSerializationFlags flags,
|
||||
const char *method,
|
||||
NMSecretAgentCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
GVariant *dict;
|
||||
GHashTable *hash;
|
||||
Request *r;
|
||||
const char *cpath = nm_connection_get_path (connection);
|
||||
|
||||
dict = nm_connection_to_dbus (connection, flags);
|
||||
hash = nm_utils_connection_dict_to_hash (dict);
|
||||
g_variant_unref (dict);
|
||||
|
||||
r = request_new (self, cpath, NULL, callback, callback_data);
|
||||
r->call = dbus_g_proxy_begin_call_with_timeout (priv->proxy,
|
||||
method,
|
||||
agent_save_delete_cb,
|
||||
r,
|
||||
NULL,
|
||||
10000, /* 10 seconds */
|
||||
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
|
||||
DBUS_TYPE_G_OBJECT_PATH, cpath,
|
||||
G_TYPE_INVALID);
|
||||
g_hash_table_insert (priv->requests, r->call, r);
|
||||
|
||||
g_hash_table_destroy (hash);
|
||||
return r->call;
|
||||
g_hash_table_remove (priv->requests, r);
|
||||
}
|
||||
|
||||
gconstpointer
|
||||
|
|
@ -426,16 +384,46 @@ nm_secret_agent_save_secrets (NMSecretAgent *self,
|
|||
NMSecretAgentCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NMSecretAgentPrivate *priv;
|
||||
GVariant *dict;
|
||||
Request *r;
|
||||
const char *cpath;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
cpath = nm_connection_get_path (connection);
|
||||
|
||||
/* Caller should have ensured that only agent-owned secrets exist in 'connection' */
|
||||
return agent_new_save_delete (self,
|
||||
connection,
|
||||
NM_CONNECTION_SERIALIZE_ALL,
|
||||
"SaveSecrets",
|
||||
callback,
|
||||
callback_data);
|
||||
dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
|
||||
r = request_new (self, cpath, NULL, callback, callback_data);
|
||||
nmdbus_secret_agent_call_save_secrets (priv->proxy,
|
||||
dict, cpath,
|
||||
NULL,
|
||||
agent_save_cb, r);
|
||||
g_hash_table_insert (priv->requests, r, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
agent_delete_cb (GObject *proxy,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
Request *r = user_data;
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (r->agent);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_cancellable_is_cancelled (r->cancellable)) {
|
||||
nmdbus_secret_agent_call_delete_secrets_finish (priv->proxy, result, &error);
|
||||
r->callback (r->agent, r, NULL, error, r->callback_data);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_hash_table_remove (priv->requests, r);
|
||||
}
|
||||
|
||||
gconstpointer
|
||||
|
|
@ -444,54 +432,54 @@ nm_secret_agent_delete_secrets (NMSecretAgent *self,
|
|||
NMSecretAgentCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NMSecretAgentPrivate *priv;
|
||||
GVariant *dict;
|
||||
Request *r;
|
||||
const char *cpath;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
cpath = nm_connection_get_path (connection);
|
||||
|
||||
/* No secrets sent; agents must be smart enough to track secrets using the UUID or something */
|
||||
return agent_new_save_delete (self,
|
||||
connection,
|
||||
NM_CONNECTION_SERIALIZE_NO_SECRETS,
|
||||
"DeleteSecrets",
|
||||
callback,
|
||||
callback_data);
|
||||
dict = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_NO_SECRETS);
|
||||
|
||||
r = request_new (self, cpath, NULL, callback, callback_data);
|
||||
nmdbus_secret_agent_call_delete_secrets (priv->proxy,
|
||||
dict, cpath,
|
||||
NULL,
|
||||
agent_delete_cb, r);
|
||||
g_hash_table_insert (priv->requests, r, r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static void proxy_cleanup (NMSecretAgent *self);
|
||||
|
||||
static void
|
||||
name_owner_changed_cb (NMBusManager *dbus_mgr,
|
||||
const char *name,
|
||||
const char *old_owner,
|
||||
const char *new_owner,
|
||||
name_owner_changed_cb (GObject *proxy,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSecretAgent *self = NM_SECRET_AGENT (user_data);
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
char *owner;
|
||||
|
||||
if (!new_owner && !g_strcmp0 (old_owner, priv->dbus_owner))
|
||||
proxy_cleanup (self);
|
||||
}
|
||||
|
||||
static void
|
||||
proxy_cleanup (NMSecretAgent *self)
|
||||
{
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (self);
|
||||
|
||||
if (priv->proxy) {
|
||||
g_signal_handlers_disconnect_by_func (priv->proxy, proxy_cleanup, self);
|
||||
owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (proxy));
|
||||
if (!owner) {
|
||||
g_signal_handlers_disconnect_by_func (priv->proxy, name_owner_changed_cb, self);
|
||||
g_clear_object (&priv->proxy);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (nm_bus_manager_get (), name_owner_changed_cb, self);
|
||||
g_signal_emit (self, signals[DISCONNECTED], 0);
|
||||
|
||||
g_clear_pointer (&priv->dbus_owner, g_free);
|
||||
}
|
||||
} else
|
||||
g_free (owner);
|
||||
}
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
NMSecretAgent *
|
||||
nm_secret_agent_new (DBusGMethodInvocation *context,
|
||||
nm_secret_agent_new (GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
const char *identifier,
|
||||
NMSecretAgentCapabilities capabilities)
|
||||
|
|
@ -500,6 +488,7 @@ nm_secret_agent_new (DBusGMethodInvocation *context,
|
|||
NMSecretAgentPrivate *priv;
|
||||
char *hash_str;
|
||||
struct passwd *pw;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_val_if_fail (context != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL);
|
||||
|
|
@ -523,18 +512,17 @@ nm_secret_agent_new (DBusGMethodInvocation *context,
|
|||
priv->hash = g_str_hash (hash_str);
|
||||
g_free (hash_str);
|
||||
|
||||
priv->proxy = nm_bus_manager_new_proxy (nm_bus_manager_get (),
|
||||
context,
|
||||
priv->dbus_owner,
|
||||
NM_DBUS_PATH_SECRET_AGENT,
|
||||
NM_DBUS_INTERFACE_SECRET_AGENT);
|
||||
g_assert (priv->proxy);
|
||||
g_signal_connect_swapped (priv->proxy, "destroy",
|
||||
G_CALLBACK (proxy_cleanup), self);
|
||||
g_signal_connect (nm_bus_manager_get (),
|
||||
NM_BUS_MANAGER_NAME_OWNER_CHANGED,
|
||||
proxy = nm_bus_manager_new_proxy (nm_bus_manager_get (),
|
||||
context,
|
||||
NMDBUS_TYPE_SECRET_AGENT_PROXY,
|
||||
priv->dbus_owner,
|
||||
NM_DBUS_PATH_SECRET_AGENT,
|
||||
NM_DBUS_INTERFACE_SECRET_AGENT);
|
||||
g_assert (proxy);
|
||||
g_signal_connect (proxy, "notify::g-name-owner",
|
||||
G_CALLBACK (name_owner_changed_cb),
|
||||
self);
|
||||
priv->proxy = NMDBUS_SECRET_AGENT (proxy);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
@ -553,7 +541,7 @@ dispose (GObject *object)
|
|||
{
|
||||
NMSecretAgentPrivate *priv = NM_SECRET_AGENT_GET_PRIVATE (object);
|
||||
|
||||
proxy_cleanup (NM_SECRET_AGENT (object));
|
||||
g_clear_object (&priv->proxy);
|
||||
g_clear_object (&priv->subject);
|
||||
|
||||
G_OBJECT_CLASS (nm_secret_agent_parent_class)->dispose (object);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __NETWORKMANAGER_SECRET_AGENT_H__
|
||||
#define __NETWORKMANAGER_SECRET_AGENT_H__
|
||||
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include "nm-default.h"
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ typedef struct {
|
|||
|
||||
GType nm_secret_agent_get_type (void);
|
||||
|
||||
NMSecretAgent *nm_secret_agent_new (DBusGMethodInvocation *context,
|
||||
NMSecretAgent *nm_secret_agent_new (GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
const char *identifier,
|
||||
NMSecretAgentCapabilities capabilities);
|
||||
|
|
@ -78,7 +77,7 @@ gboolean nm_secret_agent_has_permission (NMSecretAgent *agent,
|
|||
|
||||
typedef void (*NMSecretAgentCallback) (NMSecretAgent *agent,
|
||||
gconstpointer call,
|
||||
GHashTable *new_secrets, /* NULL for save & delete */
|
||||
GVariant *new_secrets, /* NULL for save & delete */
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <nm-dbus-interface.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-session-monitor.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-auth-subject.h"
|
||||
#include "nm-agent-manager.h"
|
||||
|
|
@ -37,10 +35,11 @@
|
|||
#include "nm-core-internal.h"
|
||||
#include "nm-audit-manager.h"
|
||||
|
||||
#include "nmdbus-settings-connection.h"
|
||||
|
||||
#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
|
||||
#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
|
||||
|
||||
|
||||
#define _LOG_DOMAIN LOGD_SETTINGS
|
||||
#define _LOG_PREFIX_NAME "settings-connection"
|
||||
|
||||
|
|
@ -81,33 +80,6 @@
|
|||
#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
|
||||
|
||||
static void impl_settings_connection_get_settings (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_update (NMSettingsConnection *self,
|
||||
GHashTable *new_settings,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_update_unsaved (NMSettingsConnection *self,
|
||||
GHashTable *new_settings,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_save (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_delete (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_get_secrets (NMSettingsConnection *self,
|
||||
const gchar *setting_name,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_connection_clear_secrets (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
#include "nm-settings-connection-glue.h"
|
||||
|
||||
static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_EXPORTED_OBJECT,
|
||||
|
|
@ -183,88 +155,93 @@ typedef struct {
|
|||
typedef gboolean (*ForEachSecretFunc) (NMSettingSecretFlags flags,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
static GVariant *
|
||||
for_each_secret (NMConnection *self,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
gboolean remove_non_secrets,
|
||||
ForEachSecretFunc callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
GVariantBuilder secrets_builder, setting_builder;
|
||||
GVariantIter secrets_iter, *setting_iter;
|
||||
const char *setting_name;
|
||||
GHashTable *setting_hash;
|
||||
|
||||
/* This function, given a hash of hashes representing new secrets of
|
||||
* an NMConnection, walks through each toplevel hash (which represents a
|
||||
* NMSetting), and for each setting, walks through that setting hash's
|
||||
/* This function, given a dict of dicts representing new secrets of
|
||||
* an NMConnection, walks through each toplevel dict (which represents a
|
||||
* NMSetting), and for each setting, walks through that setting dict's
|
||||
* properties. For each property that's a secret, it will check that
|
||||
* secret's flags in the backing NMConnection object, and call a supplied
|
||||
* callback.
|
||||
*
|
||||
* The one complexity is that the VPN setting's 'secrets' property is
|
||||
* *also* a hash table (since the key/value pairs are arbitrary and known
|
||||
* *also* a dict (since the key/value pairs are arbitrary and known
|
||||
* only to the VPN plugin itself). That means we have three levels of
|
||||
* GHashTables that we potentially have to traverse here. When we hit the
|
||||
* dicts that we potentially have to traverse here. When we hit the
|
||||
* VPN setting's 'secrets' property, we special-case that and iterate over
|
||||
* each item in that 'secrets' hash table, calling the supplied callback
|
||||
* each item in that 'secrets' dict, calling the supplied callback
|
||||
* each time.
|
||||
*/
|
||||
|
||||
g_return_if_fail (callback);
|
||||
g_return_val_if_fail (callback, NULL);
|
||||
|
||||
/* Walk through the list of setting hashes */
|
||||
g_hash_table_iter_init (&iter, secrets);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting_hash)) {
|
||||
g_variant_iter_init (&secrets_iter, secrets);
|
||||
g_variant_builder_init (&secrets_builder, NM_VARIANT_TYPE_CONNECTION);
|
||||
while (g_variant_iter_next (&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) {
|
||||
NMSetting *setting;
|
||||
GHashTableIter secret_iter;
|
||||
const char *secret_name;
|
||||
GValue *val;
|
||||
GVariant *val;
|
||||
|
||||
if (g_hash_table_size (setting_hash) == 0)
|
||||
continue;
|
||||
|
||||
/* Get the actual NMSetting from the connection so we can get secret flags
|
||||
* from the connection data, since flags aren't secrets. What we're
|
||||
* iterating here is just the secrets, not a whole connection.
|
||||
*/
|
||||
setting = nm_connection_get_setting_by_name (self, setting_name);
|
||||
if (setting == NULL)
|
||||
if (setting == NULL) {
|
||||
g_variant_iter_free (setting_iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Walk through the list of keys in each setting hash */
|
||||
g_hash_table_iter_init (&secret_iter, setting_hash);
|
||||
while (g_hash_table_iter_next (&secret_iter, (gpointer) &secret_name, (gpointer) &val)) {
|
||||
g_variant_builder_init (&setting_builder, NM_VARIANT_TYPE_SETTING);
|
||||
while (g_variant_iter_next (setting_iter, "{sv}", &secret_name, &val)) {
|
||||
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||
|
||||
/* VPN secrets need slightly different treatment here since the
|
||||
* "secrets" property is actually a hash table of secrets.
|
||||
*/
|
||||
if (NM_IS_SETTING_VPN (setting) && (g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS) == 0)) {
|
||||
GHashTableIter vpn_secrets_iter;
|
||||
if (NM_IS_SETTING_VPN (setting) && !g_strcmp0 (secret_name, NM_SETTING_VPN_SECRETS)) {
|
||||
GVariantBuilder vpn_secrets_builder;
|
||||
GVariantIter vpn_secrets_iter;
|
||||
const char *vpn_secret_name, *secret;
|
||||
|
||||
/* Iterate through each secret from the VPN hash in the overall secrets hash */
|
||||
g_hash_table_iter_init (&vpn_secrets_iter, g_value_get_boxed (val));
|
||||
while (g_hash_table_iter_next (&vpn_secrets_iter, (gpointer) &secret_name, NULL)) {
|
||||
secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||
if (!nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL)) {
|
||||
if (remove_non_secrets)
|
||||
g_hash_table_iter_remove (&vpn_secrets_iter);
|
||||
/* Iterate through each secret from the VPN dict in the overall secrets dict */
|
||||
g_variant_builder_init (&vpn_secrets_builder, G_VARIANT_TYPE ("a{ss}"));
|
||||
g_variant_iter_init (&vpn_secrets_iter, val);
|
||||
while (g_variant_iter_next (&vpn_secrets_iter, "{&s&s}", &vpn_secret_name, &secret)) {
|
||||
if (!nm_setting_get_secret_flags (setting, vpn_secret_name, &secret_flags, NULL)) {
|
||||
if (!remove_non_secrets)
|
||||
g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret);
|
||||
continue;
|
||||
}
|
||||
if (!callback (secret_flags, callback_data))
|
||||
g_hash_table_iter_remove (&vpn_secrets_iter);
|
||||
|
||||
if (callback (secret_flags, callback_data))
|
||||
g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret);
|
||||
}
|
||||
|
||||
g_variant_builder_add (&setting_builder, "{sv}",
|
||||
secret_name, g_variant_builder_end (&vpn_secrets_builder));
|
||||
} else {
|
||||
if (!nm_setting_get_secret_flags (setting, secret_name, &secret_flags, NULL)) {
|
||||
if (remove_non_secrets)
|
||||
g_hash_table_iter_remove (&secret_iter);
|
||||
if (!remove_non_secrets)
|
||||
g_variant_builder_add (&setting_builder, "{sv}", secret_name, val);
|
||||
continue;
|
||||
}
|
||||
if (!callback (secret_flags, callback_data))
|
||||
g_hash_table_iter_remove (&secret_iter);
|
||||
if (callback (secret_flags, callback_data))
|
||||
g_variant_builder_add (&setting_builder, "{sv}", secret_name, val);
|
||||
}
|
||||
g_variant_unref (val);
|
||||
}
|
||||
|
||||
g_variant_iter_free (setting_iter);
|
||||
g_variant_builder_add (&secrets_builder, "{sa{sv}}", setting_name, &setting_builder);
|
||||
}
|
||||
|
||||
return g_variant_builder_end (&secrets_builder);
|
||||
}
|
||||
|
||||
typedef gboolean (*FindSecretFunc) (NMSettingSecretFlags flags,
|
||||
|
|
@ -284,22 +261,24 @@ find_secret_for_each_func (NMSettingSecretFlags flags,
|
|||
|
||||
if (!data->found)
|
||||
data->found = data->find_func (flags, data->find_func_data);
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_secret (NMConnection *self,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
FindSecretFunc callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
FindSecretData data;
|
||||
GVariant *dummy;
|
||||
|
||||
data.find_func = callback;
|
||||
data.find_func_data = callback_data;
|
||||
data.found = FALSE;
|
||||
|
||||
for_each_secret (self, secrets, FALSE, find_secret_for_each_func, &data);
|
||||
dummy = for_each_secret (self, secrets, FALSE, find_secret_for_each_func, &data);
|
||||
g_variant_unref (dummy);
|
||||
return data.found;
|
||||
}
|
||||
|
||||
|
|
@ -836,7 +815,7 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||
gboolean agent_has_modify,
|
||||
const char *setting_name,
|
||||
NMSecretAgentGetSecretsFlags flags,
|
||||
GHashTable *secrets,
|
||||
GVariant *secrets,
|
||||
GError *error,
|
||||
gpointer user_data,
|
||||
gpointer other_data2,
|
||||
|
|
@ -925,21 +904,19 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||
| NM_SETTING_SECRET_FLAG_NOT_REQUIRED);
|
||||
}
|
||||
|
||||
for_each_secret (NM_CONNECTION (self), secrets, TRUE, validate_secret_flags, &cmp_flags);
|
||||
|
||||
/* Update the connection with our existing secrets from backing storage */
|
||||
nm_connection_clear_secrets (NM_CONNECTION (self));
|
||||
dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
|
||||
if (!dict || nm_connection_update_secrets (NM_CONNECTION (self), setting_name, dict, &local)) {
|
||||
GVariant *secrets_dict;
|
||||
GVariant *filtered_secrets;
|
||||
|
||||
/* Update the connection with the agent's secrets; by this point if any
|
||||
* system-owned secrets exist in 'secrets' the agent that provided them
|
||||
* will have been authenticated, so those secrets can replace the existing
|
||||
* system secrets.
|
||||
*/
|
||||
secrets_dict = nm_utils_connection_hash_to_dict (secrets);
|
||||
if (nm_connection_update_secrets (NM_CONNECTION (self), setting_name, secrets_dict, &local)) {
|
||||
filtered_secrets = for_each_secret (NM_CONNECTION (self), secrets, TRUE, validate_secret_flags, &cmp_flags);
|
||||
if (nm_connection_update_secrets (NM_CONNECTION (self), setting_name, filtered_secrets, &local)) {
|
||||
/* Now that all secrets are updated, copy and cache new secrets,
|
||||
* then save them to backing storage.
|
||||
*/
|
||||
|
|
@ -962,6 +939,8 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||
setting_name,
|
||||
call_id);
|
||||
}
|
||||
|
||||
g_variant_unref (filtered_secrets);
|
||||
} else {
|
||||
_LOGD ("(%s:%u) failed to update with agent secrets: (%d) %s",
|
||||
setting_name,
|
||||
|
|
@ -969,7 +948,6 @@ agent_secrets_done_cb (NMAgentManager *manager,
|
|||
local ? local->code : -1,
|
||||
(local && local->message) ? local->message : "(unknown)");
|
||||
}
|
||||
g_variant_unref (secrets_dict);
|
||||
} else {
|
||||
_LOGD ("(%s:%u) failed to update with existing secrets: (%d) %s",
|
||||
setting_name,
|
||||
|
|
@ -1012,7 +990,6 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
|
|||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
|
||||
GVariant *existing_secrets;
|
||||
GHashTable *existing_secrets_hash;
|
||||
guint32 call_id = 0;
|
||||
gs_free char *joined_hints = NULL;
|
||||
|
||||
|
|
@ -1035,11 +1012,12 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
|
|||
}
|
||||
|
||||
existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
|
||||
existing_secrets_hash = nm_utils_connection_dict_to_hash (existing_secrets);
|
||||
if (existing_secrets)
|
||||
g_variant_ref_sink (existing_secrets);
|
||||
call_id = nm_agent_manager_get_secrets (priv->agent_mgr,
|
||||
NM_CONNECTION (self),
|
||||
subject,
|
||||
existing_secrets_hash,
|
||||
existing_secrets,
|
||||
setting_name,
|
||||
flags,
|
||||
hints,
|
||||
|
|
@ -1047,8 +1025,6 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
|
|||
self,
|
||||
callback,
|
||||
callback_data);
|
||||
if (existing_secrets_hash)
|
||||
g_hash_table_unref (existing_secrets_hash);
|
||||
if (existing_secrets)
|
||||
g_variant_unref (existing_secrets);
|
||||
|
||||
|
|
@ -1077,7 +1053,7 @@ nm_settings_connection_cancel_secrets (NMSettingsConnection *self,
|
|||
/**** User authorization **************************************/
|
||||
|
||||
typedef void (*AuthCallback) (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer data);
|
||||
|
|
@ -1085,7 +1061,7 @@ typedef void (*AuthCallback) (NMSettingsConnection *self,
|
|||
static void
|
||||
pk_auth_cb (NMAuthChain *chain,
|
||||
GError *chain_error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSettingsConnection *self = NM_SETTINGS_CONNECTION (user_data);
|
||||
|
|
@ -1134,7 +1110,7 @@ pk_auth_cb (NMAuthChain *chain,
|
|||
* Returns: the #NMAuthSubject on success, or %NULL on failure and sets @error
|
||||
*/
|
||||
static NMAuthSubject *
|
||||
_new_auth_subject (DBusGMethodInvocation *context, GError **error)
|
||||
_new_auth_subject (GDBusMethodInvocation *context, GError **error)
|
||||
{
|
||||
NMAuthSubject *subject;
|
||||
|
||||
|
|
@ -1151,7 +1127,7 @@ _new_auth_subject (DBusGMethodInvocation *context, GError **error)
|
|||
|
||||
static void
|
||||
auth_start (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
const char *check_permission,
|
||||
AuthCallback callback,
|
||||
|
|
@ -1239,16 +1215,15 @@ check_writable (NMConnection *self, GError **error)
|
|||
|
||||
static void
|
||||
get_settings_auth_cb (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
else {
|
||||
GVariant *settings;
|
||||
GHashTable *settings_hash;
|
||||
NMConnection *dupl_con;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wifi;
|
||||
|
|
@ -1286,17 +1261,15 @@ get_settings_auth_cb (NMSettingsConnection *self,
|
|||
*/
|
||||
settings = nm_connection_to_dbus (NM_CONNECTION (dupl_con), NM_CONNECTION_SERIALIZE_NO_SECRETS);
|
||||
g_assert (settings);
|
||||
settings_hash = nm_utils_connection_dict_to_hash (settings);
|
||||
dbus_g_method_return (context, settings_hash);
|
||||
g_hash_table_destroy (settings_hash);
|
||||
g_variant_unref (settings);
|
||||
g_dbus_method_invocation_return_value (context,
|
||||
g_variant_new ("(@a{sa{sv}})", settings));
|
||||
g_object_unref (dupl_con);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_connection_get_settings (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMAuthSubject *subject;
|
||||
GError *error = NULL;
|
||||
|
|
@ -1305,14 +1278,12 @@ impl_settings_connection_get_settings (NMSettingsConnection *self,
|
|||
if (subject) {
|
||||
auth_start (self, context, subject, NULL, get_settings_auth_cb, NULL);
|
||||
g_object_unref (subject);
|
||||
} else {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
} else
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
DBusGMethodInvocation *context;
|
||||
GDBusMethodInvocation *context;
|
||||
NMAgentManager *agent_mgr;
|
||||
NMAuthSubject *subject;
|
||||
NMConnection *new_settings;
|
||||
|
|
@ -1320,7 +1291,7 @@ typedef struct {
|
|||
} UpdateInfo;
|
||||
|
||||
typedef struct {
|
||||
DBusGMethodInvocation *context;
|
||||
GDBusMethodInvocation *context;
|
||||
NMAuthSubject *subject;
|
||||
} CallbackInfo;
|
||||
|
||||
|
|
@ -1384,9 +1355,9 @@ update_complete (NMSettingsConnection *self,
|
|||
GError *error)
|
||||
{
|
||||
if (error)
|
||||
dbus_g_method_return_error (info->context, error);
|
||||
g_dbus_method_invocation_return_gerror (info->context, error);
|
||||
else
|
||||
dbus_g_method_return (info->context);
|
||||
g_dbus_method_invocation_return_value (info->context, NULL);
|
||||
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_UPDATE, NM_CONNECTION (self), !error,
|
||||
info->subject, error ? error->message : NULL);
|
||||
|
|
@ -1424,7 +1395,7 @@ con_update_cb (NMSettingsConnection *self,
|
|||
|
||||
static void
|
||||
update_auth_cb (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer data)
|
||||
|
|
@ -1492,8 +1463,8 @@ get_update_modify_permission (NMConnection *old, NMConnection *new)
|
|||
|
||||
static void
|
||||
impl_settings_connection_update_helper (NMSettingsConnection *self,
|
||||
GHashTable *new_settings,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *new_settings,
|
||||
gboolean save_to_disk)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
|
||||
|
|
@ -1515,14 +1486,9 @@ impl_settings_connection_update_helper (NMSettingsConnection *self,
|
|||
|
||||
/* Check if the settings are valid first */
|
||||
if (new_settings) {
|
||||
GVariant *new_settings_dict = nm_utils_connection_hash_to_dict (new_settings);
|
||||
|
||||
tmp = nm_simple_connection_new_from_dbus (new_settings_dict, &error);
|
||||
g_variant_unref (new_settings_dict);
|
||||
if (!tmp) {
|
||||
g_assert (error);
|
||||
tmp = nm_simple_connection_new_from_dbus (new_settings, &error);
|
||||
if (!tmp)
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
subject = _new_auth_subject (context, &error);
|
||||
|
|
@ -1562,37 +1528,34 @@ error:
|
|||
g_clear_object (&tmp);
|
||||
g_clear_object (&subject);
|
||||
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_clear_error (&error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_connection_update (NMSettingsConnection *self,
|
||||
GHashTable *new_settings,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *new_settings)
|
||||
{
|
||||
g_assert (new_settings);
|
||||
impl_settings_connection_update_helper (self, new_settings, context, TRUE);
|
||||
impl_settings_connection_update_helper (self, context, new_settings, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_connection_update_unsaved (NMSettingsConnection *self,
|
||||
GHashTable *new_settings,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *new_settings)
|
||||
{
|
||||
g_assert (new_settings);
|
||||
impl_settings_connection_update_helper (self, new_settings, context, FALSE);
|
||||
impl_settings_connection_update_helper (self, context, new_settings, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_connection_save (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
/* Do nothing if the connection is already synced with disk */
|
||||
if (nm_settings_connection_get_unsaved (self))
|
||||
impl_settings_connection_update_helper (self, NULL, context, TRUE);
|
||||
impl_settings_connection_update_helper (self, context, NULL, TRUE);
|
||||
else
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1603,9 +1566,9 @@ con_delete_cb (NMSettingsConnection *self,
|
|||
CallbackInfo *info = user_data;
|
||||
|
||||
if (error)
|
||||
dbus_g_method_return_error (info->context, error);
|
||||
g_dbus_method_invocation_return_gerror (info->context, error);
|
||||
else
|
||||
dbus_g_method_return (info->context);
|
||||
g_dbus_method_invocation_return_value (info->context, NULL);
|
||||
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, NM_CONNECTION (self),
|
||||
!error, info->subject, error ? error->message : NULL);
|
||||
|
|
@ -1614,7 +1577,7 @@ con_delete_cb (NMSettingsConnection *self,
|
|||
|
||||
static void
|
||||
delete_auth_cb (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer data)
|
||||
|
|
@ -1624,7 +1587,7 @@ delete_auth_cb (NMSettingsConnection *self,
|
|||
if (error) {
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, NM_CONNECTION (self), FALSE, subject,
|
||||
error->message);
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1654,7 +1617,7 @@ get_modify_permission_basic (NMSettingsConnection *self)
|
|||
|
||||
static void
|
||||
impl_settings_connection_delete (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMAuthSubject *subject = NULL;
|
||||
GError *error = NULL;
|
||||
|
|
@ -1671,9 +1634,8 @@ impl_settings_connection_delete (NMSettingsConnection *self,
|
|||
|
||||
return;
|
||||
out_err:
|
||||
dbus_g_method_return_error (context, error);
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DELETE, NM_CONNECTION (self), FALSE, subject, error->message);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
|
@ -1687,14 +1649,13 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
|
||||
DBusGMethodInvocation *context = user_data;
|
||||
GDBusMethodInvocation *context = user_data;
|
||||
GVariant *dict;
|
||||
GHashTable *hash;
|
||||
|
||||
priv->reqs = g_slist_remove (priv->reqs, GUINT_TO_POINTER (call_id));
|
||||
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
else {
|
||||
/* Return secrets from agent and backing storage to the D-Bus caller;
|
||||
* nm_settings_connection_get_secrets() will have updated itself with
|
||||
|
|
@ -1702,20 +1663,15 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
|
|||
* by the time we get here.
|
||||
*/
|
||||
dict = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
|
||||
if (dict)
|
||||
hash = nm_utils_connection_dict_to_hash (dict);
|
||||
else
|
||||
hash = g_hash_table_new (NULL, NULL);
|
||||
dbus_g_method_return (context, hash);
|
||||
g_hash_table_destroy (hash);
|
||||
if (dict)
|
||||
g_variant_unref (dict);
|
||||
if (!dict)
|
||||
dict = g_variant_new_array (G_VARIANT_TYPE ("{sa{sv}}"), NULL, 0);
|
||||
g_dbus_method_invocation_return_value (context, g_variant_new ("(@a{s{a{sv}}})", dict));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dbus_get_secrets_auth_cb (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
|
|
@ -1742,7 +1698,7 @@ dbus_get_secrets_auth_cb (NMSettingsConnection *self,
|
|||
}
|
||||
|
||||
if (error || local) {
|
||||
dbus_g_method_return_error (context, error ? error : local);
|
||||
g_dbus_method_invocation_return_gerror (context, error ? error : local);
|
||||
g_clear_error (&local);
|
||||
}
|
||||
|
||||
|
|
@ -1751,8 +1707,8 @@ dbus_get_secrets_auth_cb (NMSettingsConnection *self,
|
|||
|
||||
static void
|
||||
impl_settings_connection_get_secrets (NMSettingsConnection *self,
|
||||
const gchar *setting_name,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
const gchar *setting_name)
|
||||
{
|
||||
NMAuthSubject *subject;
|
||||
GError *error = NULL;
|
||||
|
|
@ -1766,10 +1722,8 @@ impl_settings_connection_get_secrets (NMSettingsConnection *self,
|
|||
dbus_get_secrets_auth_cb,
|
||||
g_strdup (setting_name));
|
||||
g_object_unref (subject);
|
||||
} else {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
} else
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1780,9 +1734,9 @@ clear_secrets_cb (NMSettingsConnection *self,
|
|||
CallbackInfo *info = user_data;
|
||||
|
||||
if (error)
|
||||
dbus_g_method_return_error (info->context, error);
|
||||
g_dbus_method_invocation_return_gerror (info->context, error);
|
||||
else
|
||||
dbus_g_method_return (info->context);
|
||||
g_dbus_method_invocation_return_value (info->context, NULL);
|
||||
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, NM_CONNECTION (self),
|
||||
!error, info->subject, error ? error->message : NULL);
|
||||
|
|
@ -1791,7 +1745,7 @@ clear_secrets_cb (NMSettingsConnection *self,
|
|||
|
||||
static void
|
||||
dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
|
|
@ -1800,7 +1754,7 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
|
|||
CallbackInfo *info;
|
||||
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, NM_CONNECTION (self),
|
||||
FALSE, subject, error->message);
|
||||
} else {
|
||||
|
|
@ -1824,7 +1778,7 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
|
|||
|
||||
static void
|
||||
impl_settings_connection_clear_secrets (NMSettingsConnection *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMAuthSubject *subject;
|
||||
GError *error = NULL;
|
||||
|
|
@ -1839,10 +1793,9 @@ impl_settings_connection_clear_secrets (NMSettingsConnection *self,
|
|||
NULL);
|
||||
g_object_unref (subject);
|
||||
} else {
|
||||
dbus_g_method_return_error (context, error);
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_CLEAR_SECRETS, NM_CONNECTION (self),
|
||||
FALSE, NULL, error->message);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2586,7 +2539,15 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
|
|||
G_TYPE_NONE, 0);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class),
|
||||
&dbus_glib_nm_settings_connection_object_info);
|
||||
NMDBUS_TYPE_SETTINGS_CONNECTION_SKELETON,
|
||||
"Update", impl_settings_connection_update,
|
||||
"UpdateUnsaved", impl_settings_connection_update_unsaved,
|
||||
"Delete", impl_settings_connection_delete,
|
||||
"GetSettings", impl_settings_connection_get_settings,
|
||||
"GetSecrets", impl_settings_connection_get_secrets,
|
||||
"ClearSecrets", impl_settings_connection_clear_secrets,
|
||||
"Save", impl_settings_connection_save,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@
|
|||
#include <string.h>
|
||||
#include <gmodule.h>
|
||||
#include <pwd.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#if HAVE_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
|
|
@ -61,7 +59,6 @@
|
|||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-settings.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-system-config-interface.h"
|
||||
|
|
@ -78,6 +75,8 @@
|
|||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-dispatcher.h"
|
||||
|
||||
#include "nmdbus-settings.h"
|
||||
|
||||
#define LOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
nm_log ((level), LOGD_CORE, \
|
||||
|
|
@ -122,35 +121,6 @@ EXPORT(nm_settings_connection_replace_and_commit)
|
|||
static void claim_connection (NMSettings *self,
|
||||
NMSettingsConnection *connection);
|
||||
|
||||
static gboolean impl_settings_list_connections (NMSettings *self,
|
||||
GPtrArray **connections,
|
||||
GError **error);
|
||||
|
||||
static void impl_settings_get_connection_by_uuid (NMSettings *self,
|
||||
const char *uuid,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_add_connection (NMSettings *self,
|
||||
GHashTable *settings,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_add_connection_unsaved (NMSettings *self,
|
||||
GHashTable *settings,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_load_connections (NMSettings *self,
|
||||
char **filenames,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_reload_connections (NMSettings *self,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_settings_save_hostname (NMSettings *self,
|
||||
const char *hostname,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
#include "nm-settings-glue.h"
|
||||
|
||||
static void unmanaged_specs_changed (NMSystemConfigInterface *config, gpointer user_data);
|
||||
static void unrecognized_specs_changed (NMSystemConfigInterface *config, gpointer user_data);
|
||||
|
||||
|
|
@ -161,8 +131,6 @@ G_DEFINE_TYPE_EXTENDED (NMSettings, nm_settings, NM_TYPE_EXPORTED_OBJECT, 0,
|
|||
|
||||
|
||||
typedef struct {
|
||||
NMBusManager *dbus_mgr;
|
||||
|
||||
NMAgentManager *agent_mgr;
|
||||
|
||||
NMConfig *config;
|
||||
|
|
@ -176,6 +144,7 @@ typedef struct {
|
|||
GSList *unrecognized_specs;
|
||||
GSList *get_connections_cache;
|
||||
|
||||
gboolean started;
|
||||
gboolean startup_complete;
|
||||
|
||||
struct {
|
||||
|
|
@ -309,20 +278,24 @@ nm_settings_for_each_connection (NMSettings *self,
|
|||
for_each_func (self, NM_SETTINGS_CONNECTION (data), user_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
impl_settings_list_connections (NMSettings *self,
|
||||
GPtrArray **connections,
|
||||
GError **error)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
GPtrArray *connections;
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
|
||||
*connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
|
||||
connections = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
g_ptr_array_add (*connections, g_strdup ((const char *) key));
|
||||
return TRUE;
|
||||
g_ptr_array_add (connections, key);
|
||||
g_ptr_array_add (connections, NULL);
|
||||
|
||||
g_dbus_method_invocation_return_value (context,
|
||||
g_variant_new ("(^ao)", connections->pdata));
|
||||
g_ptr_array_unref (connections);
|
||||
}
|
||||
|
||||
NMSettingsConnection *
|
||||
|
|
@ -348,8 +321,8 @@ nm_settings_get_connection_by_uuid (NMSettings *self, const char *uuid)
|
|||
|
||||
static void
|
||||
impl_settings_get_connection_by_uuid (NMSettings *self,
|
||||
const char *uuid,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
const char *uuid)
|
||||
{
|
||||
NMSettingsConnection *connection = NULL;
|
||||
NMAuthSubject *subject = NULL;
|
||||
|
|
@ -383,13 +356,14 @@ impl_settings_get_connection_by_uuid (NMSettings *self,
|
|||
}
|
||||
|
||||
g_clear_object (&subject);
|
||||
dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection)));
|
||||
g_dbus_method_invocation_return_value (
|
||||
context,
|
||||
g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection))));
|
||||
return;
|
||||
|
||||
error:
|
||||
g_assert (error);
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
g_clear_object (&subject);
|
||||
}
|
||||
|
||||
|
|
@ -561,6 +535,9 @@ nm_settings_get_hostname (NMSettings *self)
|
|||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
char *hostname = NULL;
|
||||
|
||||
if (!priv->started)
|
||||
return NULL;
|
||||
|
||||
if (priv->hostname.hostnamed_proxy) {
|
||||
hostname = g_strdup (priv->hostname.value);
|
||||
goto out;
|
||||
|
|
@ -1185,7 +1162,7 @@ send_agent_owned_secrets (NMSettings *self,
|
|||
static void
|
||||
pk_add_cb (NMAuthChain *chain,
|
||||
GError *chain_error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSettings *self = NM_SETTINGS (user_data);
|
||||
|
|
@ -1273,11 +1250,11 @@ is_adhoc_wpa (NMConnection *connection)
|
|||
|
||||
void
|
||||
nm_settings_add_connection_dbus (NMSettings *self,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
DBusGMethodInvocation *context,
|
||||
NMSettingsAddCallback callback,
|
||||
gpointer user_data)
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
GDBusMethodInvocation *context,
|
||||
NMSettingsAddCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -1381,15 +1358,17 @@ static void
|
|||
impl_settings_add_connection_add_cb (NMSettings *self,
|
||||
NMSettingsConnection *connection,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (error) {
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_return_gerror (context, error);
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, NULL, FALSE, subject, error->message);
|
||||
} else {
|
||||
dbus_g_method_return (context, nm_connection_get_path (NM_CONNECTION (connection)));
|
||||
g_dbus_method_invocation_return_value (
|
||||
context,
|
||||
g_variant_new ("(o)", nm_connection_get_path (NM_CONNECTION (connection))));
|
||||
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_ADD, NM_CONNECTION (connection), TRUE,
|
||||
subject, NULL);
|
||||
}
|
||||
|
|
@ -1397,17 +1376,14 @@ impl_settings_add_connection_add_cb (NMSettings *self,
|
|||
|
||||
static void
|
||||
impl_settings_add_connection_helper (NMSettings *self,
|
||||
GHashTable *settings,
|
||||
gboolean save_to_disk,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *settings,
|
||||
gboolean save_to_disk)
|
||||
{
|
||||
NMConnection *connection;
|
||||
GVariant *dict;
|
||||
GError *error = NULL;
|
||||
|
||||
dict = nm_utils_connection_hash_to_dict (settings);
|
||||
connection = nm_simple_connection_new_from_dbus (dict, &error);
|
||||
g_variant_unref (dict);
|
||||
connection = nm_simple_connection_new_from_dbus (settings, &error);
|
||||
if (connection) {
|
||||
nm_settings_add_connection_dbus (self,
|
||||
connection,
|
||||
|
|
@ -1418,30 +1394,29 @@ impl_settings_add_connection_helper (NMSettings *self,
|
|||
g_object_unref (connection);
|
||||
} else {
|
||||
g_assert (error);
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_add_connection (NMSettings *self,
|
||||
GHashTable *settings,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *settings)
|
||||
{
|
||||
impl_settings_add_connection_helper (self, settings, TRUE, context);
|
||||
impl_settings_add_connection_helper (self, context, settings, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_add_connection_unsaved (NMSettings *self,
|
||||
GHashTable *settings,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
GVariant *settings)
|
||||
{
|
||||
impl_settings_add_connection_helper (self, settings, FALSE, context);
|
||||
impl_settings_add_connection_helper (self, context, settings, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ensure_root (NMBusManager *dbus_mgr,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
gulong caller_uid;
|
||||
GError *error = NULL;
|
||||
|
|
@ -1450,16 +1425,14 @@ ensure_root (NMBusManager *dbus_mgr,
|
|||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Unable to determine request UID.");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
return FALSE;
|
||||
}
|
||||
if (caller_uid != 0) {
|
||||
error = g_error_new_literal (NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_PERMISSION_DENIED,
|
||||
"Permission denied");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1468,15 +1441,15 @@ ensure_root (NMBusManager *dbus_mgr,
|
|||
|
||||
static void
|
||||
impl_settings_load_connections (NMSettings *self,
|
||||
char **filenames,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
char **filenames)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
GPtrArray *failures;
|
||||
GSList *iter;
|
||||
int i;
|
||||
|
||||
if (!ensure_root (priv->dbus_mgr, context))
|
||||
if (!ensure_root (nm_bus_manager_get (), context))
|
||||
return;
|
||||
|
||||
failures = g_ptr_array_new ();
|
||||
|
|
@ -1497,18 +1470,22 @@ impl_settings_load_connections (NMSettings *self,
|
|||
}
|
||||
|
||||
g_ptr_array_add (failures, NULL);
|
||||
dbus_g_method_return (context, failures->len == 1, failures->pdata);
|
||||
g_dbus_method_invocation_return_value (
|
||||
context,
|
||||
g_variant_new ("(b^as)",
|
||||
failures->len == 1,
|
||||
failures->pdata));
|
||||
g_ptr_array_unref (failures);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_settings_reload_connections (NMSettings *self,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
GSList *iter;
|
||||
|
||||
if (!ensure_root (priv->dbus_mgr, context))
|
||||
if (!ensure_root (nm_bus_manager_get (), context))
|
||||
return;
|
||||
|
||||
for (iter = priv->plugins; iter; iter = g_slist_next (iter)) {
|
||||
|
|
@ -1517,7 +1494,7 @@ impl_settings_reload_connections (NMSettings *self,
|
|||
nm_system_config_interface_reload_connections (plugin);
|
||||
}
|
||||
|
||||
dbus_g_method_return (context, TRUE);
|
||||
g_dbus_method_invocation_return_value (context, g_variant_new ("(b)", TRUE));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -1590,7 +1567,7 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname)
|
|||
static void
|
||||
pk_hostname_cb (NMAuthChain *chain,
|
||||
GError *chain_error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMSettings *self = NM_SETTINGS (user_data);
|
||||
|
|
@ -1626,11 +1603,10 @@ pk_hostname_cb (NMAuthChain *chain,
|
|||
}
|
||||
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
else
|
||||
dbus_g_method_return (context);
|
||||
g_dbus_method_invocation_return_value (context, NULL);
|
||||
|
||||
g_clear_error (&error);
|
||||
nm_auth_chain_unref (chain);
|
||||
}
|
||||
|
||||
|
|
@ -1663,8 +1639,8 @@ validate_hostname (const char *hostname)
|
|||
|
||||
static void
|
||||
impl_settings_save_hostname (NMSettings *self,
|
||||
const char *hostname,
|
||||
DBusGMethodInvocation *context)
|
||||
GDBusMethodInvocation *context,
|
||||
const char *hostname)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
NMAuthChain *chain;
|
||||
|
|
@ -1692,8 +1668,7 @@ impl_settings_save_hostname (NMSettings *self,
|
|||
|
||||
done:
|
||||
if (error)
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_clear_error (&error);
|
||||
g_dbus_method_invocation_take_error (context, error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2094,25 +2069,35 @@ setup_hostname_file_monitors (NMSettings *self)
|
|||
}
|
||||
|
||||
NMSettings *
|
||||
nm_settings_new (GError **error)
|
||||
nm_settings_new (void)
|
||||
{
|
||||
NMSettings *self;
|
||||
NMSettingsPrivate *priv;
|
||||
GDBusProxy *proxy;
|
||||
GVariant *variant;
|
||||
GError *local_error = NULL;
|
||||
|
||||
self = g_object_new (NM_TYPE_SETTINGS, NULL);
|
||||
|
||||
priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
priv->config = nm_config_get ();
|
||||
priv->dbus_mgr = nm_bus_manager_get ();
|
||||
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (self));
|
||||
return self;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_settings_start (NMSettings *self, GError **error)
|
||||
{
|
||||
NMSettingsPrivate *priv;
|
||||
GDBusProxy *proxy;
|
||||
GVariant *variant;
|
||||
GError *local_error = NULL;
|
||||
|
||||
priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
/* Load the plugins; fail if a plugin is not found. */
|
||||
if (!load_plugins (self, nm_config_get_plugins (priv->config), error)) {
|
||||
g_object_unref (self);
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
load_connections (self);
|
||||
|
|
@ -2143,8 +2128,9 @@ nm_settings_new (GError **error)
|
|||
if (!priv->hostname.hostnamed_proxy)
|
||||
setup_hostname_file_monitors (self);
|
||||
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (self));
|
||||
return self;
|
||||
priv->started = TRUE;
|
||||
g_object_notify (G_OBJECT (self), NM_SETTINGS_HOSTNAME);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2182,8 +2168,6 @@ dispose (GObject *object)
|
|||
g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref);
|
||||
priv->auths = NULL;
|
||||
|
||||
priv->dbus_mgr = NULL;
|
||||
|
||||
g_object_unref (priv->agent_mgr);
|
||||
|
||||
if (priv->hostname.hostnamed_proxy) {
|
||||
|
|
@ -2239,17 +2223,18 @@ get_property (GObject *object, guint prop_id,
|
|||
NMSettings *self = NM_SETTINGS (object);
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
const GSList *specs, *iter;
|
||||
GSList *copy = NULL;
|
||||
GHashTableIter citer;
|
||||
GPtrArray *array;
|
||||
const char *path;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_UNMANAGED_SPECS:
|
||||
array = g_ptr_array_new ();
|
||||
specs = nm_settings_get_unmanaged_specs (self);
|
||||
for (iter = specs; iter; iter = g_slist_next (iter))
|
||||
copy = g_slist_append (copy, g_strdup (iter->data));
|
||||
g_value_take_boxed (value, copy);
|
||||
g_ptr_array_add (array, g_strdup (iter->data));
|
||||
g_ptr_array_add (array, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
|
||||
break;
|
||||
case PROP_HOSTNAME:
|
||||
g_value_take_string (value, nm_settings_get_hostname (self));
|
||||
|
|
@ -2262,11 +2247,12 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_boolean (value, !!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS));
|
||||
break;
|
||||
case PROP_CONNECTIONS:
|
||||
array = g_ptr_array_sized_new (g_hash_table_size (priv->connections));
|
||||
array = g_ptr_array_sized_new (g_hash_table_size (priv->connections) + 1);
|
||||
g_hash_table_iter_init (&citer, priv->connections);
|
||||
while (g_hash_table_iter_next (&citer, (gpointer) &path, NULL))
|
||||
g_ptr_array_add (array, g_strdup (path));
|
||||
g_value_take_boxed (value, array);
|
||||
g_ptr_array_add (array, NULL);
|
||||
g_value_take_boxed (value, (char **) g_ptr_array_free (array, FALSE));
|
||||
break;
|
||||
case PROP_STARTUP_COMPLETE:
|
||||
g_value_set_boolean (value, nm_settings_get_startup_complete (self));
|
||||
|
|
@ -2297,7 +2283,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_UNMANAGED_SPECS,
|
||||
g_param_spec_boxed (NM_SETTINGS_UNMANAGED_SPECS, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
|
@ -2318,7 +2304,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
g_object_class_install_property
|
||||
(object_class, PROP_CONNECTIONS,
|
||||
g_param_spec_boxed (NM_SETTINGS_CONNECTIONS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
|
@ -2330,7 +2316,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_STRUCT_OFFSET (NMSettingsClass, connection_added),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
signals[CONNECTION_UPDATED] =
|
||||
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_UPDATED,
|
||||
|
|
@ -2339,7 +2325,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_STRUCT_OFFSET (NMSettingsClass, connection_updated),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
signals[CONNECTION_UPDATED_BY_USER] =
|
||||
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER,
|
||||
|
|
@ -2348,7 +2334,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
signals[CONNECTION_REMOVED] =
|
||||
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_REMOVED,
|
||||
|
|
@ -2357,7 +2343,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_STRUCT_OFFSET (NMSettingsClass, connection_removed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
signals[CONNECTION_VISIBILITY_CHANGED] =
|
||||
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_VISIBILITY_CHANGED,
|
||||
|
|
@ -2366,7 +2352,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_STRUCT_OFFSET (NMSettingsClass, connection_visibility_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
signals[AGENT_REGISTERED] =
|
||||
g_signal_new (NM_SETTINGS_SIGNAL_AGENT_REGISTERED,
|
||||
|
|
@ -2375,7 +2361,7 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_STRUCT_OFFSET (NMSettingsClass, agent_registered),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SECRET_AGENT);
|
||||
|
||||
|
||||
signals[NEW_CONNECTION] =
|
||||
|
|
@ -2383,16 +2369,17 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (class),
|
||||
&dbus_glib_nm_settings_object_info);
|
||||
|
||||
dbus_g_error_domain_register (NM_SETTINGS_ERROR,
|
||||
NM_DBUS_INTERFACE_SETTINGS,
|
||||
NM_TYPE_SETTINGS_ERROR);
|
||||
dbus_g_error_domain_register (NM_CONNECTION_ERROR,
|
||||
NM_DBUS_INTERFACE_SETTINGS_CONNECTION,
|
||||
NM_TYPE_CONNECTION_ERROR);
|
||||
NMDBUS_TYPE_SETTINGS_SKELETON,
|
||||
"ListConnections", impl_settings_list_connections,
|
||||
"GetConnectionByUuid", impl_settings_get_connection_by_uuid,
|
||||
"AddConnection", impl_settings_add_connection,
|
||||
"AddConnectionUnsaved", impl_settings_add_connection_unsaved,
|
||||
"LoadConnections", impl_settings_load_connections,
|
||||
"ReloadConnections", impl_settings_reload_connections,
|
||||
"SaveHostname", impl_settings_save_hostname,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ typedef struct {
|
|||
|
||||
GType nm_settings_get_type (void);
|
||||
|
||||
NMSettings *nm_settings_new (GError **error);
|
||||
NMSettings *nm_settings_new (void);
|
||||
gboolean nm_settings_start (NMSettings *self, GError **error);
|
||||
|
||||
typedef void (*NMSettingsForEachFunc) (NMSettings *settings,
|
||||
NMSettingsConnection *connection,
|
||||
|
|
@ -86,14 +87,14 @@ void nm_settings_for_each_connection (NMSettings *settings,
|
|||
typedef void (*NMSettingsAddCallback) (NMSettings *settings,
|
||||
NMSettingsConnection *connection,
|
||||
GError *error,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMAuthSubject *subject,
|
||||
gpointer user_data);
|
||||
|
||||
void nm_settings_add_connection_dbus (NMSettings *self,
|
||||
NMConnection *connection,
|
||||
gboolean save_to_disk,
|
||||
DBusGMethodInvocation *context,
|
||||
GDBusMethodInvocation *context,
|
||||
NMSettingsAddCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ AM_CPPFLAGS = \
|
|||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ibft"\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DSBINDIR=\"$(sbindir)\"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include <nm-setting-connection.h>
|
||||
|
||||
#include "nm-default.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-system-config-interface.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ AM_CPPFLAGS = \
|
|||
|
||||
AM_LDFLAGS = \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(CODE_COVERAGE_LDFLAGS)
|
||||
|
||||
noinst_PROGRAMS = test-ibft
|
||||
|
|
|
|||
|
|
@ -2,15 +2,31 @@ SUBDIRS = . tests
|
|||
|
||||
@GNOME_CODE_COVERAGE_RULES@
|
||||
|
||||
nm-ifcfg-rh-glue.h: nm-ifcfg-rh.xml
|
||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_ifcfg_rh --mode=glib-server --output=$@ $<
|
||||
# See note about gdbus-codegen in introspection/Makefile.am
|
||||
|
||||
BUILT_SOURCES = \
|
||||
nm-ifcfg-rh-glue.h
|
||||
noinst_LTLIBRARIES = libnmdbus-ifcfg-rh.la
|
||||
|
||||
nodist_libnmdbus_ifcfg_rh_la_SOURCES = \
|
||||
nmdbus-ifcfg-rh.c \
|
||||
nmdbus-ifcfg-rh.h
|
||||
|
||||
libnmdbus_ifcfg_rh_la_CPPFLAGS = $(filter-out -DGLIB_VERSION_MAX_ALLOWED%,$(AM_CPPFLAGS))
|
||||
|
||||
nmdbus-ifcfg-rh.h: nm-ifcfg-rh.xml
|
||||
$(AM_V_GEN) gdbus-codegen \
|
||||
--generate-c-code $(basename $@) \
|
||||
--c-namespace NMDBus \
|
||||
--interface-prefix com.redhat \
|
||||
$<
|
||||
|
||||
nmdbus-ifcfg-rh.c: nmdbus-ifcfg-rh.h
|
||||
@true
|
||||
|
||||
BUILT_SOURCES = nmdbus-ifcfg-rh.h nmdbus-ifcfg-rh.c
|
||||
|
||||
pkglib_LTLIBRARIES = libnm-settings-plugin-ifcfg-rh.la
|
||||
|
||||
noinst_LTLIBRARIES = libifcfg-rh-io.la
|
||||
noinst_LTLIBRARIES += libifcfg-rh-io.la
|
||||
|
||||
libifcfg_rh_io_la_SOURCES = \
|
||||
shvar.c \
|
||||
|
|
@ -33,7 +49,6 @@ AM_CPPFLAGS = \
|
|||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(NSS_CFLAGS) \
|
||||
-DG_LOG_DOMAIN=\""NetworkManager-ifcfg-rh"\" \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\" \
|
||||
|
|
@ -46,7 +61,7 @@ libnm_settings_plugin_ifcfg_rh_la_SOURCES = \
|
|||
nm-ifcfg-connection.h
|
||||
|
||||
libnm_settings_plugin_ifcfg_rh_la_LDFLAGS = -module -avoid-version
|
||||
libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la
|
||||
libnm_settings_plugin_ifcfg_rh_la_LIBADD = libifcfg-rh-io.la libnmdbus-ifcfg-rh.la
|
||||
|
||||
dbusservicedir = $(DBUS_SYS_DIR)
|
||||
dbusservice_DATA = nm-ifcfg-rh.conf
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
<tp:docstring>
|
||||
Given an ifcfg file, return various internal information about it.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_ifcfgrh_get_ifcfg_details"/>
|
||||
<arg name="ifcfg" type="s" direction="in">
|
||||
<tp:docstring>
|
||||
The full path to an ifcfg file.
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
|
||||
#include <gmodule.h>
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#if HAVE_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
#endif
|
||||
|
|
@ -43,7 +39,6 @@
|
|||
|
||||
#include "nm-default.h"
|
||||
#include "common.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "plugin.h"
|
||||
#include "nm-system-config-interface.h"
|
||||
#include "nm-config.h"
|
||||
|
|
@ -54,6 +49,9 @@
|
|||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
#include "utils.h"
|
||||
#include "nm-dbus-compat.h"
|
||||
|
||||
#include "nmdbus-ifcfg-rh.h"
|
||||
|
||||
#define IFCFGRH1_DBUS_SERVICE_NAME "com.redhat.ifcfgrh1"
|
||||
#define IFCFGRH1_DBUS_OBJECT_PATH "/com/redhat/ifcfgrh1"
|
||||
|
|
@ -77,14 +75,6 @@
|
|||
#define ERR_GET_MSG(err) (((err) && (err)->message) ? (err)->message : "(unknown)")
|
||||
|
||||
|
||||
static gboolean impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
|
||||
const char *in_ifcfg,
|
||||
const char **out_uuid,
|
||||
const char **out_path,
|
||||
GError **error);
|
||||
|
||||
#include "nm-ifcfg-rh-glue.h"
|
||||
|
||||
static NMIfcfgConnection *update_connection (SCPluginIfcfg *plugin,
|
||||
NMConnection *source,
|
||||
const char *full_path,
|
||||
|
|
@ -109,7 +99,7 @@ typedef struct {
|
|||
GFileMonitor *ifcfg_monitor;
|
||||
guint ifcfg_monitor_id;
|
||||
|
||||
DBusGConnection *bus;
|
||||
gboolean has_dbus_service;
|
||||
} SCPluginIfcfgPrivate;
|
||||
|
||||
|
||||
|
|
@ -696,12 +686,10 @@ add_connection (NMSystemConfigInterface *config,
|
|||
return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static void
|
||||
impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
|
||||
const char *in_ifcfg,
|
||||
const char **out_uuid,
|
||||
const char **out_path,
|
||||
GError **error)
|
||||
GDBusMethodInvocation *context,
|
||||
const char *in_ifcfg)
|
||||
{
|
||||
NMIfcfgConnection *connection;
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -709,55 +697,53 @@ impl_ifcfgrh_get_ifcfg_details (SCPluginIfcfg *plugin,
|
|||
const char *path;
|
||||
|
||||
if (!g_path_is_absolute (in_ifcfg)) {
|
||||
g_set_error (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"ifcfg path '%s' is not absolute", in_ifcfg);
|
||||
return FALSE;
|
||||
g_dbus_method_invocation_return_error (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"ifcfg path '%s' is not absolute", in_ifcfg);
|
||||
return;
|
||||
}
|
||||
|
||||
connection = find_by_path (plugin, in_ifcfg);
|
||||
if ( !connection
|
||||
|| nm_ifcfg_connection_get_unmanaged_spec (connection)
|
||||
|| nm_ifcfg_connection_get_unrecognized_spec (connection)) {
|
||||
g_set_error (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"ifcfg file '%s' unknown", in_ifcfg);
|
||||
return FALSE;
|
||||
g_dbus_method_invocation_return_error (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||
"ifcfg file '%s' unknown", in_ifcfg);
|
||||
return;
|
||||
}
|
||||
|
||||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
|
||||
if (!s_con) {
|
||||
g_set_error (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to retrieve the connection setting");
|
||||
return FALSE;
|
||||
g_dbus_method_invocation_return_error (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to retrieve the connection setting");
|
||||
return;
|
||||
}
|
||||
|
||||
uuid = nm_setting_connection_get_uuid (s_con);
|
||||
if (!uuid) {
|
||||
g_set_error (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to get the UUID");
|
||||
return FALSE;
|
||||
g_dbus_method_invocation_return_error (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to get the UUID");
|
||||
return;
|
||||
}
|
||||
|
||||
path = nm_connection_get_path (NM_CONNECTION (connection));
|
||||
if (!path) {
|
||||
g_set_error (error,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to get the connection D-Bus path");
|
||||
return FALSE;
|
||||
g_dbus_method_invocation_return_error (context,
|
||||
NM_SETTINGS_ERROR,
|
||||
NM_SETTINGS_ERROR_FAILED,
|
||||
"unable to get the connection D-Bus path");
|
||||
return;
|
||||
}
|
||||
|
||||
*out_uuid = g_strdup (uuid);
|
||||
*out_path = g_strdup (path);
|
||||
|
||||
return TRUE;
|
||||
g_dbus_method_invocation_return_value (context,
|
||||
g_variant_new ("(so)", uuid, path));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -770,46 +756,43 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
|
|||
{
|
||||
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
||||
GError *error = NULL;
|
||||
gboolean success = FALSE;
|
||||
GDBusConnection *bus;
|
||||
GVariant *ret;
|
||||
guint32 result;
|
||||
|
||||
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
|
||||
priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||
if (!priv->bus) {
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!bus) {
|
||||
_LOGW ("Couldn't connect to D-Bus: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
} else {
|
||||
DBusConnection *tmp;
|
||||
DBusGProxy *proxy;
|
||||
int result;
|
||||
|
||||
tmp = dbus_g_connection_get_connection (priv->bus);
|
||||
dbus_connection_set_exit_on_disconnect (tmp, FALSE);
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (priv->bus,
|
||||
DBUS_SERVICE_DBUS,
|
||||
DBUS_PATH_DBUS,
|
||||
DBUS_INTERFACE_DBUS);
|
||||
|
||||
if (!dbus_g_proxy_call (proxy, "RequestName", &error,
|
||||
G_TYPE_STRING, IFCFGRH1_DBUS_SERVICE_NAME,
|
||||
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &result,
|
||||
G_TYPE_INVALID)) {
|
||||
_LOGW ("Couldn't acquire D-Bus service: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
} else if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
||||
_LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)");
|
||||
} else
|
||||
success = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
if (priv->bus) {
|
||||
dbus_g_connection_unref (priv->bus);
|
||||
priv->bus = NULL;
|
||||
}
|
||||
ret = g_dbus_connection_call_sync (bus,
|
||||
DBUS_SERVICE_DBUS,
|
||||
DBUS_PATH_DBUS,
|
||||
DBUS_INTERFACE_DBUS,
|
||||
"RequestName",
|
||||
g_variant_new ("(su)",
|
||||
IFCFGRH1_DBUS_SERVICE_NAME,
|
||||
DBUS_NAME_FLAG_DO_NOT_QUEUE),
|
||||
G_VARIANT_TYPE ("(u)"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL, &error);
|
||||
g_object_unref (bus);
|
||||
if (ret) {
|
||||
g_variant_get (ret, "(u)", &result);
|
||||
g_variant_unref (ret);
|
||||
|
||||
if (result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||
priv->has_dbus_service = TRUE;
|
||||
else
|
||||
_LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)");
|
||||
} else {
|
||||
_LOGW ("Couldn't acquire D-Bus service: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -819,11 +802,6 @@ dispose (GObject *object)
|
|||
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object);
|
||||
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
||||
|
||||
if (priv->bus) {
|
||||
dbus_g_connection_unref (priv->bus);
|
||||
priv->bus = NULL;
|
||||
}
|
||||
|
||||
if (priv->connections) {
|
||||
g_hash_table_destroy (priv->connections);
|
||||
priv->connections = NULL;
|
||||
|
|
@ -875,9 +853,12 @@ static void
|
|||
sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
NMExportedObjectClass *exported_object_class = NM_EXPORTED_OBJECT_CLASS (req_class);
|
||||
|
||||
g_type_class_add_private (req_class, sizeof (SCPluginIfcfgPrivate));
|
||||
|
||||
exported_object_class->export_path = IFCFGRH1_DBUS_OBJECT_PATH;
|
||||
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
|
@ -895,7 +876,9 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
|
|||
NM_SYSTEM_CONFIG_INTERFACE_CAPABILITIES);
|
||||
|
||||
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (req_class),
|
||||
&dbus_glib_nm_ifcfg_rh_object_info);
|
||||
NMDBUS_TYPE_IFCFGRH1_SKELETON,
|
||||
"GetIfcfgDetails", impl_ifcfgrh_get_ifcfg_details,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -920,10 +903,8 @@ nm_system_config_factory (void)
|
|||
if (!singleton) {
|
||||
singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL));
|
||||
priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton);
|
||||
if (priv->bus)
|
||||
dbus_g_connection_register_g_object (priv->bus,
|
||||
IFCFGRH1_DBUS_OBJECT_PATH,
|
||||
G_OBJECT (singleton));
|
||||
if (priv->has_dbus_service)
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (singleton));
|
||||
_LOGD ("Acquired D-Bus service %s", IFCFGRH1_DBUS_SERVICE_NAME);
|
||||
} else
|
||||
g_object_ref (singleton);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ AM_CPPFLAGS = \
|
|||
|
||||
AM_LDFLAGS = \
|
||||
$(GLIB_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(CODE_COVERAGE_LDFLAGS)
|
||||
|
||||
noinst_PROGRAMS = test-ifcfg-rh test-ifcfg-rh-utils
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ AM_CPPFLAGS = \
|
|||
-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
|
||||
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS) \
|
||||
-DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
-DSBINDIR=\"$(sbindir)\"
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue