Commit Graph

63 Commits

Author SHA1 Message Date
Thomas Haller
073cc01f52 dispatcher: fix crash while logging from signal handler
Bug rh#1017884 describes a crash, where dbus_init() failed, which causes
a g_warning(). While writing the warning, a SIGTERM hit, and the
signal_handler() tries to call again g_message().

The logging functions of glib are not reentrant and call abort() when
invoked recursivly. The solution, is to use g_unix_signal_add, which
will dispatch the handler on the mainloop asynchronously.

This bug is not that serious, because the dispatcher was about to
terminate anyway. However, it gets registered as a crash by the system
(ABRT).

https://bugzilla.redhat.com/show_bug.cgi?id=1017884

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-19 00:20:12 +01:00
Thomas Haller
f059298896 trivial: whitespace fix
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 21:32:08 +01:00
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Thomas Haller
e670528778 dispatcher: fix memory leak in nm-dispatcher-action
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:46 +02:00
Dan Winship
bfce3f7dc8 build: switch from $(INCLUDES) to $(AM_CPPFLAGS) to make automake happy
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.

In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
2013-08-22 11:49:16 -04:00
Pavel Šimerda
320a9d16a3 all: replace struct in_addr with guint32 2013-08-03 00:15:07 -05:00
Jiří Klimeš
12955fcda6 dispatcher: fix tests after ac536c2124
We need to use G_TYPE_STRV instead of DBUS_TYPE_G_ARRAY_OF_STRING, because
G_TYPE_STRV will be the type that will come to the dispatcher over D-Bus.
2013-06-24 13:57:52 +02:00
Tomas Hozza
ac536c2124 dispatcher: expose domains in IP4/6 config
Previously the function add_domains() expected the
"domains" value to be of type DBUS_TYPE_G_ARRAY_OF_STRING
but the value is in fact of type G_TYPE_STRV. Also
added check to log critical message in case of "val"
not holding G_TYPE_STRV type.

This caused dispatcher not to export IPx_DOMAINS
environment variable.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2013-06-21 16:27:23 -05:00
Dan Williams
06a415d9ea systemd: add service for dispatcher (rh #948433) 2013-06-03 10:53:07 -05:00
Dan Williams
b69171061c dhcp: use private socket to return status if available
Allows DHCP to work when a bus daemon isn't running.  This also
fixes a race condition where when multiple interfaces are attempting
to get a DHCP lease at the same time, if one DHCP client instance
triggers the callout, that instance gets the bus name, and any
other client triggering the callout at that time will fail because
the bus name is already taken.  Since this commit allows using
a private socket, where no process has a bus name, this race is
avoided.

Also move the DHCP helper from callouts/ to src/dhcp-manager/ to
consolidate all the DHCP stuff and clean up some of the helper's
code.
2013-04-08 11:30:31 -05:00
Jiří Klimeš
82fb1978a4 all: use G_VALUE_INIT to initialize GValue variables
It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
2013-03-25 08:41:18 +01:00
Dan Winship
f936400c38 tests: clean up gtester usage
Use g_test_add_func() and g_test_add_data_func() to simplify the test
cases, getting rid of the GLIB_CHECK_VERSION calls in the process.
2013-02-26 13:07:33 +01:00
Dan Winship
ed9e2d8377 build: avoid GValueArray deprecation warnings
Avoid warnings about GValueArray being deprecated by adding macros
that wrap G_GNUC_BEGIN_IGNORE_DEPRECATIONS /
G_GNUC_END_IGNORE_DEPRECATIONS around the GValueArray calls.
2013-02-26 13:07:33 +01:00
Pavel Šimerda
faa1bcb540 build: improve documentation and test configure options
Use --enable-doc and --enable-tests instead of --with-docs and
--with-tests. This is consistent with other features and with
--enable-gtk-doc option. Support current variants as fallback.

Don't build tests unless --enable-tests is specified.
2012-11-13 20:23:06 +01:00
Pavel Šimerda
d82669d3fd build: unify NetworkManager path handling (some paths are changed)
Use autoconf/automake variables for NetworkManager paths. Use
NetworkManager subdirectory where appropriate.

Files in /var/run (or /run on some distros) are moved into a separate
directory as is usual with other daemons. It makes the filesystem
more readable and file prefixing unnecessary.

/var/run/NetworkManager.pid -> /var/run/NetworkManager/NetworkManager.pid
/var/run/nm-dns-dnsmasq.pid -> /var/run/NetworkManager/dnsmasq.pid
/var/run/nm-dns-dnsmasq.conf -> /var/run/NetworkManager/dnsmasq.conf

The /var/run/NetworkManager directory is created at runtime, if it doesn't
exist.

Note: Path-based security policies like SELinux and AppArmor may need to
be adapted.
2012-11-05 14:01:47 +01:00
Colin Walters
59f2cd0f8d build: remove G_DISABLE_DEPRECATED
This functionality is (mostly) obsoleted by the newer
GLIB_VERSION_MIN_REQUIRED and GLIB_VERSION_MAX_ALLOWED defines.  With
this, your build doesn't all of a sudden blow up if we deprecate
something in GLib - you have to explicitly opt-in to the newer
version.

G_DISABLE_DEPRECATED does still apply for macros and things that can't
take __attribute__((deprecated)), but it's not really worth the pain
and cargo culting around just for that.
2012-10-31 19:41:07 +01:00
Colin Walters
50712597ae dispatcher: Don't segfault if no dispatcher scripts exist (bgo #685451)
If /etc/NetworkManager/dispatcher.d didn't exist or was
empty, we'd try to pull the first element of a 0-sized array.

To fix this cleanly, we need to explicitly separate discovery
of binaries to execute from setting up the callback data.
2012-10-04 16:33:54 -04:00
Dan Winship
6878d20ac4 all: Don't use ctype.h macros
The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
2012-09-26 12:14:37 -04:00
Dan Williams
0201d6da87 core: convert dispatcher to asynchronous operation and return its results
In preparation for making NM wait on the dispatcher, make the dispatcher
call scripts asynchronously, and report the script results back to NM.
2012-09-11 17:06:16 -05:00
Dan Williams
a03e7fb74f callouts: don't queue the DHCP callout's bus name request (bgo #680041)
If queueing the name isn't allowed, and two instances that start in
close succession, one instance will fail because it can't claim the
bus name.
2012-07-16 19:54:07 -05:00
Dan Williams
757a34fcdd callouts: remove glib code from DHCP callout
The whole callout is pure dbus, not dbus-glib, so there's really no need
for glib code there.  Even so, DBUS_LIBS contains dbus-glib and gobject,
so we're still linking to glib/gobject.
2012-07-16 19:54:07 -05:00
Dan Williams
17c1f1e953 dispatcher: normalize return codes 2012-06-06 10:26:26 -05:00
Colin Walters
74ec56d956 build: fix srcdir != builddir for new generated headers 2012-02-22 16:27:28 -06:00
Colin Walters
dab7dfaf35 build: fix srcdir != builddir
nm-version.h is in ${top_builddir}/include.
2012-01-09 14:20:36 -06:00
Dan Williams
6109388df2 Revert "dispatcher: handle DHCP Options property correctly"
This reverts commit e5e3dbf415.

The patch fixes the issue but it should really be resolved by the
NM dispatcher code in NetworkManagerUtils.c flattening the DHCP
Options property instead, keeping the dispatcher code simpler.
2011-05-11 15:24:40 -05:00
Jiří Klimeš
e5e3dbf415 dispatcher: handle DHCP Options property correctly 2011-05-11 16:16:48 +02:00
Dan Williams
a08e9b928e core: fix dispatcher handling of empty VPN interface (bgo #649773)
We pass a VPN IP iface of "" through D-Bus (since dbus doesn't do NULL)
and the dispatcher code wasn't ignoring that as it should have been.
2011-05-10 11:33:43 -05:00
Dan Williams
f898dbf1a9 dispatcher: enhance dispatcher script environment (bgo #648382)
For VPN connections, the interface name would be that of the VPN's
IP interface, but the script environment would be the that of the
VPN's parent device.  Enhance the environment by adding any VPN
specific details as additional environment variables prefixed by
"VPN_".  Leave the existing environment setup intact for backwards
compatiblity.

Additionally, the dispatcher never got updated for IPv6 support,
so push IPv6 configuration and DHCPv6 configuration into the
environment too.

Even better, push everything the dispatcher needs to it instead
of making the dispatcher make D-Bus requests back to NM, which
sometimes fails if NM has already torn down the device or the
connection which the device was using.

And add some testcases to ensure that we don't break backwards compat,
the testcases here were grabbed from a 0.8.4 machine with a hacked up
dispatcher to dump everything it was given from NM.
2011-05-02 22:54:28 -05:00
Dan Williams
bb7e03f846 dispatcher: put WINS servers into dispatcher script environment (bgo #624238) 2011-04-26 14:18:51 -05:00
Dan Williams
e12edca3a0 dispatcher: add connection friendly name (ID) to script environment 2011-03-30 11:32:31 -05:00
Dan Williams
cfaa80b261 Merge remote branch 'origin/master' into rm-userset 2010-11-16 18:08:48 -06:00
Jiří Klimeš
4501e33b85 dispatcher: don't warn about invalid connection for 'hostname' action (rh #627649) 2010-11-01 16:02:32 +01:00
Daniel Gnoutcheff
fb96309899 DBus: merge NetworkManger{,SystemSettings}
Remove the org.freedesktop.NetworkManagerSystemSettings bus name and
have everybody talk to org.freedesktop.NetworkManager. Now that we have
a single settings service that's embedded in the main daemon, we don't
need separate names anymore.
2010-08-07 01:19:46 -04:00
Pablo Castellano
ce5c0d5ac6 build: enable AM_SILENT_RULES (bgo #625263) 2010-08-03 12:58:46 -07:00
Dan Williams
0762b2c77b dispatcher: fix (harmless) memory leak (bgo #585714) 2009-12-24 15:55:59 -06:00
Dan Williams
58fcc8efe6 libnm-glib: libnm_glib -> libnm-glib
Bothered me for a long time; now that we've bumped the soname, we can
rename the library too.
2009-08-26 13:07:35 -05:00
Dan Williams
537c2f1f86 build: always link locally-built libraries first (bgo #580131) 2009-08-20 12:31:17 -05:00
Daniel Drake
ff88cf12c2 olpc: add mesh device logic and config setting 2009-08-05 16:34:02 -04:00
Michael Biebl
1c3c6c2a66 Remove DBUS_API_SUBJECT_TO_CHANGE
We require dbus 1.1 anyway
2009-05-02 18:00:22 -04:00
Dan Williams
ba5a7024bd core: use _GNU_SOURCE consistently 2009-04-21 18:29:25 -04:00
Dan Williams
3888405134 dbus: final dbus policy fixes (bgo #563730)
Keep explicit denials, consolidate stuff, ensure that when denying
send_interface it's almost always matched with send_destination.
2009-02-17 10:43:53 -05:00
Dan Williams
73659e724c makefile cleanups
0.7 requires dbus 1.1 or greater (for system bus activation), so make that
explicit, and remove compat code for D-Bus 0.6 and earlier.  Consolidate
the various glib pkgconfig checks into one, since most anything will require
gthread, glib, and gobject anyway.  Fixup the docs makefile to be more
automake-compatible and let 'make clean' actually work correctly when
docs are built.
2009-02-15 11:20:25 -05:00
Jan Kantert
4ca66db721 Use g_timeout_add_seconds() to reduce wakeups
(and refine the older glib compat mechanism, by Dan)
2008-12-31 18:57:36 -05:00
Dan Williams
ef20c1bbdc 2008-11-23 Dan Williams <dcbw@redhat.com>
* callouts/nm-dispatcher-action.c
		- (construct_envp, nm_dispatcher_action): pass connection UUID to
			scripts in the environment



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4329 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-24 02:07:20 +00:00
Dan Williams
dd6c440c44 Normalize license headers
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4248 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-11-03 04:22:46 +00:00
Dan Williams
bfb7243663 2008-10-29 Dan Williams <dcbw@redhat.com>
* libnm-util/libnm-util.ver
	  libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip4-config.h
		- Make properties private and add accessor functions

	* callouts/nm-dispatcher-action.c
	  libnm-glib/libnm-glib-test.c
	  libnm-util/nm-utils.c
	  src/NetworkManagerPolicy.c
	  src/NetworkManagerSystem.c
	  src/NetworkManagerUtils.c
	  src/dhcp-manager/nm-dhcp-dhclient.c
	  src/dhcp-manager/nm-dhcp-manager.c
	  src/dnsmasq-manager/nm-dnsmasq-manager.c
	  src/nm-device-wifi.c
	  src/nm-device.c
	  src/nm-hso-gsm-device.c
	  src/nm-ip4-config.c
	  src/nm-ip4-config.h
	  src/ppp-manager/nm-ppp-manager.c
	  src/vpn-manager/nm-vpn-connection.c
	  system-settings/plugins/ifcfg-fedora/reader.c
	  system-settings/plugins/ifcfg-suse/parser.c
	  system-settings/plugins/ifcfg-suse/plugin.c
	  system-settings/plugins/ifupdown/parser.c
	  test/nm-tool.c
	  vpn-daemons/vpnc/properties/nm-vpnc.c
		- Use IP4 accessor functions



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4233 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-29 14:35:25 +00:00
Dan Williams
1182e8579b 2008-10-08 Dan Williams <dcbw@redhat.com>
Add a 'hostname' dispatcher action triggered on hostname changes (bgo #552983)

	* src/NetworkManagerUtils.c
		- (nm_utils_call_dispatcher): add a 'hostname' action

	* src/NetworkManagerPolicy.c
		- (set_system_hostname): dispatch hostname changes

	* callouts/nm-dispatcher-action.c
		- (nm_dispatcher_action): handle 'hostname' actions



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4158 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-10-08 22:40:42 +00:00
Dan Williams
a419bdfb9e 2008-08-17 Dan Williams <dcbw@redhat.com>
* callouts/Makefile.am
	  src/Makefile.am
		- Move dispatcher directory creation to callouts/Makefile.am

	* system-settings/plugins/keyfile/Makefile.am
		- Create keyfile connections directory in DESTDIR (bgo #546833)



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3976 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-17 22:54:49 +00:00
Dan Williams
9ac5baeb92 2008-08-13 Dan Williams <dcbw@redhat.com>
* callouts/nm-dispatcher-action.c
		- Add IP4 config info to script environment



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3947 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-13 11:45:28 +00:00
Dan Williams
641a7072b8 2008-08-07 Dan Williams <dcbw@redhat.com>
* callouts/nm-dispatcher-action.c
		- (nm_dispatcher_action): grab device path and create the device; pass
			the device's DHCP4 config to script caller
		- (dispatch_scripts): dump the DHCP4 config to the environment of called
			scripts

	* libnm-glib/nm-dhcp4-config.c
	  libnm-glib/nm-dhcp4-config.h
		- (nm_dhcp4_config_get_options): expose
		- (nm_dhcp4_config_get_one_option): renamed from nm_dhcp4_config_get_option



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3907 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-08-07 17:47:08 +00:00