Commit graph

344 commits

Author SHA1 Message Date
Colin Walters
dc6f5f5dd7 keyfile: handle NetworkManager.conf not existing
Since in gnome-ostree we're trying to move towards an empty /etc.
We'll create it on demand if necessary.
2013-03-07 15:49:28 -06:00
Colin Walters
21ba714f78 keyfile: Use "goto out" style error handling
Just code cleanup: This is much less error-prone than manual nesting,
and will mesh very well with future changes to use the libgsystem
cleanup macros.
2013-03-07 15:46:15 -06:00
Dan Winship
6f44b7f3c6 all: remove redundant return-if-fail checks
NM_IS_FOO(x) returns FALSE if x is NULL, so we don't need a separate
(x != NULL) check before it.
2013-03-07 07:32:27 -05: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
Dan Williams
47d8db57b5 trivial: plug some memory leaks
(review+ danw)
2013-02-25 16:07:03 +01:00
Pavel Šimerda
f0277c19aa settings: add support for code coverage to the settings plugins
Use:

  ./autogen.sh --enable-code-coverage
  make
  make -C src/settings check-code-coverage
2013-02-19 13:05:52 +01:00
Dan Winship
5266e25e2b libnm-utils: add :carrier-detect properties
For settings corresponding to devices that have a :carrier property
(ie bond, bridge, infiniband, vlan, and wired), add a :carrier-detect
property specifying how that affects the connection:

  yes: The connection can only be activated when the device
      has carrier, and will be deactivated if the device loses
      carrier (for more than 4 seconds).
  no: The connection ignores carrier on the device; it can be
      activated when there is no carrier, and stays activated
      when carrier is lost.
  on-activate: The connection can only be activated when the
      device has carrier, but it will not be deactivated if the
      device loses carrier.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Winship
b54a4e601d core: fix a bug in NMSettingsConnection
nm_settings_connection_init() was calling nm_connection_set_path(),
but this was pointless since that would end up getting cleared by the
property's default value shortly after init() returned (and
claim_connection() depended on this). So remove that code.

https://bugzilla.gnome.org/show_bug.cgi?id=693829
2013-02-14 13:59:53 -05:00
Dan Winship
08f04466e8 all: remove more pointless NULL checks
GObject creation cannot normally fail, except for types that implement
GInitable and take a GError in their _new() method. Some NM types
override constructor() and return NULL in some cases, but these
generally only happen in the case of programmer error (eg, failing to
set a mandatory property), and so crashing is reasonable (and most
likely inevitable anyway).

So, remove all NULL checks after calls to g_object_new() and its
myriad wrappers.

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:36 -05:00
Dan Winship
d04f286327 all: remove pointless NULL checks
g_malloc(), etc, never return NULL, by API contract. Likewise, by
extension, no other glib function ever returns NULL due to lack of
memory. So remove lots of unnecessary checks (the vast majority of
which would have immediately crashed had they ever run anyway, since
g_set_error(), g_warning(), and nm_log_*() all need to allocate
memory).

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:13 -05:00
Dan Winship
414af39c3c keyfile: fix some test error message cut+paste errors 2013-02-12 15:50:20 -05:00
Dan Williams
e5f8b426bf settings: load keyfile plugin even if no plugins are given
If no config file was specified, and if no other plugins were given
on the command-line, the keyfile plugin would not be loaded.  This
meant no connections would be read, and no connections could be
created either.

Always load the keyfile plugin.
2013-02-11 15:45:48 -06:00
Dan Williams
cd5da9bf88 wired: move hardware address handling back to NMDeviceWired subclasses
The code flow is actually somewhat simpler this way since the
subclasses don't have to ask NMDeviceWired for the address
every time.  Plus then NMDeviceWired doesn't have to know
anything about its subclasses in the constructor.
2013-01-24 14:56:38 -06:00
Dan Williams
240cc2f233 settings: add note about killing inotify helper (bgo #532815)
We can kill this code when we depend on a new enough glib that
includes the patches from the referenced bug report.
2013-01-11 13:02:12 -06:00
Jiří Klimeš
954ce65e99 ifcfg-rh: treat missing IPv6 setting as IPv6 "auto" method (rh #830434) 2012-12-18 10:40:35 +01:00
Dan Williams
8b7287ab66 core: fix agent secret cancelation
Two issues here: first, the daemon code was using the wrong D-Bus type
(strings instead of object-path) to send the connection path to the
secret agent, which resulted in a method-not-found error and nothing
happening in the agent.

Second, the agent-side method call verification code would fail the
request anyway, becuase verify_request() determined success based
on the reconstructed connection, which isn't given when canceling
secrets requests.
2012-12-04 11:31:12 -06:00
Jiří Klimeš
0ada524a82 keyfile: add some tests for bridges 2012-11-30 13:21:51 -06:00
Dan Williams
20e60deccb ifcfg-rh: add support for reading/writing bridge port connections
Allows to attach any connection to a bridge using the BRIDGE= key.
IP configuration is optional for bridge components but not
prohibited. Test case included.
2012-11-30 13:21:51 -06:00
Thomas Graf
6bc5213b66 ifcfg-rh: add support for reading/writing bridge connections
Including testcase.
2012-11-30 13:21:51 -06:00
Dan Williams
a9077724a9 ifnet: allow testcase to remove backup files (fixes distcheck)
Can't leave the backup files lying around when doing 'make distcheck',
so when backup up a file, return the backup file path so that the
caller can (optionally) remove it.
2012-11-30 13:08:26 -06:00
Dan Williams
e609ca05a2 ifnet: fix srcdir != builddir issue with certificate paths
If the certificate path from the supplicant config is not absolute,
we need to make it absolute.  When building with a different builddir,
the certificate from the supplicant config is actually in the srcdir,
but the builddir is the current PWD.
2012-11-30 13:08:21 -06:00
Dan Williams
2e6cad94f3 ifnet: simplify testcase 2012-11-30 13:08:16 -06:00
Dan Williams
5ff6ad26f0 ifnet: simplify test supplicant config
Only list network blocks we're actually testing.
2012-11-30 13:08:10 -06:00
Dan Williams
cb0683f01d ifnet: use g_assert_cmpstr() in a few places 2012-11-30 13:08:02 -06:00
Dan Williams
faf0f5daa1 ifnet: fix some builddir != srcdir issues in testcases 2012-11-21 11:42:06 -06:00
Gene Czarcinski
90b99522d7 dhcp: fix DHCPv6 to support server-side dynamic DNS (bgo #684242)
This patch makes DHCPv6 support more or less equivalent to that
one of IPv4 DHCP.

(dcbw: fix some formatting, rearrange code so it's less convoluted,
fix up writing hostname to ifcfg files)
2012-11-16 17:26:19 -06:00
Pavel Šimerda
aa0c7d863d build: srcdir != builddir issues in plugins 2012-11-14 19:39:23 +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
e19ef483b7 build: avoid -Wshadow
NM wouldn't build on Gentoo with GCC 4.6.3.
2012-11-13 19:53:32 +01:00
Pavel Šimerda
7a92eff69c keyfile: improve address and route tests
Add tests for the new address/route format. Simplify the test program

TODO test new routing format
2012-11-07 16:39:54 +01:00
Pavel Šimerda
cca9cfc84d keyfile: read and write a nicer format for IPv4 and IPv6 addresses and routes
You can now use 'address=' even for IPv6 and it's the encouraged way
to set up a single address manually. For multiple addresses,
'address0=', 'address1=', etc, should be preferred.

Example:

  address=10.0.0.15/24/10.0.0.1
  address0=192.168.0.1/24
  address1=10.0.0.16/32

Example (backward compatibility):

  addresses=10.0.0.15/24/10.0.0.1
  addresses0=192.168.0.1/24
  addresses1=10.0.0.16/32
2012-11-07 16:39:54 +01:00
Pavel Šimerda
0d82ca5c04 keyfile: unify IPv4/IPv6 address and routing configuration (bgo #682943)
IPv4 and IPv6 address configuration is now handled together and supports
the following syntax (slashes can be replaced with semicolons):

  address/plen
  address/plen,gateway

IPv4 and IPv6 route configuration is also handled uniformly and supports
the following syntax:

  address/plen (for device routes)
  address/plen,gateway (for gateway routes)
  address/plen,gateway,metric (for gateway routes with metric)

For compatibility reasons, slash (/), comma (,) and semicolon (;) are
considered equal by the parser. The /plen part is optional for both
addresses and routes for compatibility reasons.

Leaving out the prefix length is not considered a good idea. IPv6
addresses default to 64 and IPv4 now defaults to 24 which is the closest
possible IPv4 counterpart. Routes default to single addresses.

Example 1:

  [ipv4]
  method=manual
  addresses1=192.168.56.5/24,192.168.56.1
  addresses2=192.168.57.5/24
  routes1=4.5.6.0/24
  routes2=1.2.3.0/24,4.5.6.7
  routes3=7.8.9.0/24,4.5.6.7,99

  [ipv6]
  method=manual
  addresses1=2001:db8:a🅱️:3/64,2001:db8:a🅱️:1
  addresses2=2001:db8:c:d::3/64
  routes1=2001:db8:e:f::/64,2001:db8:a🅱️:4

Example 2 (equivalent):

  [ipv4]
  method=manual
  addresses1=192.168.56.5;24;192.168.56.1
  addresses2=192.168.57.5;24
  routes1=4.5.6.0;24
  routes2=1.2.3.0;24;4.5.6.7
  routes3=7.8.9.0;24;4.5.6.7;99

  [ipv6]
  method=manual
  addresses1=2001:db8:a🅱️:3;64;2001:db8:a🅱️:1
  addresses2=2001:db8:c:d::3;64
  routes1=2001:db8:e:f::;64;2001:db8:a🅱️:4

For writing, I have arbitrarily chosen one of the formats 'reader'
can parse. Address and prefix length are separated by slash (/),
everything else is separated by comma (,).

	addresses1=address/plen,gateway
	routes1=address/plen,gateway,metric

Note: The modified 'reader' exposes a bug in the 'writer' and ignores
out badly-formatted routes. This problem is also fixed by this
commit. Keyfile tests now pass.
2012-11-07 16:39:54 +01:00
Pavel Šimerda
2e826b152d keyfile: cleanup IPv4/IPv6 address reading code 2012-11-07 16:39:53 +01:00
Jiří Klimeš
2ff378b44b settings: do not emit "REMOVED" signal in do_delete() (bgo #683800)
It is emitted in nm_settings_connection_remove() called by plugins when the
connection was removed.
This prevents the signal from appearing twice on D-Bus.

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2012-11-06 14:19:29 +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
Dan Winship
a7eb347655 ifcfg-rh: /etc/hostname should override /etc/sysconfig/network
When determining the system hostname, /etc/hostname should override
/etc/sysconfig/network, so monitor both files.

When setting the hostname, set it in /etc/hostname, and delete the
/etc/sysconfig/network HOSTNAME entry if present.

https://bugzilla.redhat.com/show_bug.cgi?id=831735
2012-11-02 11:20:31 -04:00
Jiří Klimeš
eeb19fe216 keyfile: don't rename system connection files (bgo #682570)
When updating connections, it is less confusing to reuse the existing file
instead of renaming files according to connection's ID. That reduces surprises
of moving connection files when a connection is edited.
2012-11-01 11:59:00 +01:00
Colin Walters
1977fb6c49 build: clean up GLib-related pkg-config usage (bgo #687218)
We had separate checks for glib-2.0, gobject-2.0, gmodule-2.0, and
gio-unix-2.0.  It doesn't make sense to link a binary against all 4
because gio-unix-2.0 depends on glib-2.0 and gobject-2.0.  Doing this
actually breaks things in unusual circumstances.

Generally, few bits of NM actually just use glib, and not gio.  We
might as well coalesce those requirements together, even if it means
in some cases we "overlink".  Additionally, I chose for now to fold
gmodule-2.0 in as well, even though many fewer programs need it.  The
cost of overlinking is quite small.

The benefit of this is less repeated junk in Makefile.am, as well as
more centralized control over GLib.  A followup patch will allow us to
set -DGLIB_VERSION_MIN_REQUIRED in just one place, rather than having
to replicate it 4 times.

The NM configure is still suboptimal - for example, libpolkit-1
depends on gio-2.0, so really we should determine the compiler flags
all in one pass.  But it doesn't matter too much for now.
2012-10-31 21:08:18 +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
77264eb682 build: various srcdir != builddir fixes 2012-10-30 12:24:26 -05:00
Pavel Šimerda
012c5f4b27 distro: replace --with-distro with feature-based options (bgo #663602)
Distribution-specific builds are now handled by feature and not by
distro. This allows you to fine-tune the options to your liking and
also allowed us to reduce the number of specific values.

The default values of these options are still derived from *-version
and *-release files in /etc.

The following five distribution-specific features are now available
(and default on distributions in parenthesis):

  --enable-ifcfg-rh (Fedora, RHEL and Mandriva)
  --enable-ifcfg-suse (SUSE)
  --enable-ifupdown (Debian and Ubuntu)
  --enable-ifnet (Gentoo)
  --with-netconfig (SUSE)

Since --with-distro is now removed, there is nothing to prevent generic
builds. If you build on an unknown distribution, all of the features
above will be disabled by default.
2012-10-30 00:36:05 +01:00
Jiří Klimeš
65029e0f89 settings: update seen-bssids property in 802-11-wireless setting for GetSettings
https://bugzilla.gnome.org/show_bug.cgi?id=672501
2012-10-16 15:48:41 +02:00
Marius Kotsbak
b4f2f6f596 ifupdown: fix for compile error 2012-10-11 15:49:50 -05:00
Dan Williams
c0d3004d44 ifcfg-rh: trivial: fix possibly uninitialized variable usage 2012-10-04 13:38:13 -05:00
Dan Winship
f14ecfb9f5 build: distcheck fixes 2012-10-04 09:36:19 -04:00
Dan Winship
a7ad36987a ifcfg-rh: write out wired settings on vlan connections
VLAN connections can have "hardware" settings in addition to the
VLAN-specific ones. ifcfg-rh was reading in wired settings for VLANs,
but was not writing them back out.
2012-09-27 13:57:47 -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 Winship
77c90d3f36 ifcfg-rh: Fix the filename in two error messages 2012-09-26 12:10:24 -04:00
Dan Winship
c87f1758be ifcfg-rh: Fix bonds-of-InfiniBand
Move the bond-slave check out of the wired-specific code so that it
can be shared with the infiniband code again.
2012-09-26 12:10:23 -04:00