Commit graph

313 commits

Author SHA1 Message Date
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
Dan Williams
78e9c564b2 keyfile: fix use-after-free in log messages 2012-09-25 15:03:13 -05:00
Jiří Klimeš
eb407143fd ifcfg-rh: read/write 'secondaries' property of 'connection' setting
as SECONDARY_UUIDS variable
2012-09-21 13:47:01 +02:00
Dan Williams
1966aba8e9 core: determine whether connection timestamps are set or not
Currently there's no way to differentiate between a connection that has
never been activated, and a connection that has never been *successfully*
activated.  In both cases nm_settings_connection_get_timestamp() returns
zero.  But it's useful to know whether a connection hasn't even been
tried yet, so enhance the timestamp code to return whether or not the
timestamp has been found in the timestamp cache or not, and make the
NMDevice core set an explict timestamp of 0 if the connection failed
on the first attempt.

We'll use this later to conditionally autoconnect WiFi connections
depending on whether they've ever successfully connected or not, but
still allow preloaded connections without a timestamp to autoconnect
as they always have.
2012-09-20 10:11:36 -05:00
Dan Williams
e962f06253 keyfile: use friendly MAC address format for WiMAX 2012-08-15 16:51:59 -05:00
Paul Menzel
b2d97cc96c ifnet: fix typo fut*u*re 2012-08-15 14:24:50 -05:00
Dan Williams
1d7949e66c build: fix up includes; prefer builddir over srcdir
WiMAX failed distcheck if the iwmxsdk devel files were installed but
--enable-wimax=no was used, since the distcheck configure bits found
the iwmxsdk headers, defaulted WiMAX support to 'on', and then proceeded
to use the generated headers from the top srcdir, where of course
wimax was turned off (due to --enable-wimax=no).  Instead, everything
should use the headers from the builddir, which reflects the options
that 'make distcheck' actually selects.

At the same time, re-order various includes everywhere to ensure that
the builddir paths come before the srcdir paths to prevent this from
happening in the future.
2012-08-06 17:27:17 -05:00
Ross Vandegrift
43d4d16b5b ifupdown: Allow netmask to be CIDR-style prefix length (bgo #679123) 2012-08-06 15:07:42 -05:00
Pavel Šimerda
4fdca493ad ifupdown: testcase for CIDR-style prefix length (bgo #679123) 2012-08-06 15:07:42 -05:00
Jiří Klimeš
edb85e9720 core: fix NM_IS_*_CLASS(klass) macros
The argument is 'klass' not 'obj'.
2012-07-27 13:15:54 +02:00
Dan Winship
3324bd2cdf ifcfg-rh: ignore IP config on bond slaves
NM was requiring that bond slaves have either no IP config or an
explicit "none"/"disabled" config. But the system scripts just ignore
any IP config that is present on a slave, so change NM to do that too
(but warn about it).

https://bugzilla.redhat.com/show_bug.cgi?id=838907
2012-07-23 12:52:32 -04:00
Jiří Klimeš
974c39fe3e ifcfg-rh: fix a segfault when unescaping a string (rh #841391)
The crash occured for variables like these:
VAR="
VAR='
2012-07-19 14:30:29 +02:00
Jiří Klimeš
21fa0f8349 settings: fix keyfile plugin priority when explicitly configured (bgo #679655)
The regression was introduced by b38f39cfc6 that
built keyfile plugin into NM (instead of using .so).
2012-07-10 16:04:14 +02:00
Dan Williams
74e262b303 agents: add a "user-requested" flag to secret agent requests
Allows agents to provide different behavior depending on whether the
secrets request was initiated by a user (eg by picking a connection
from a UI menu or by 'nmcli con up') or was automatically started by
NetworkManager.

See https://bugzilla.gnome.org/show_bug.cgi?id=660293
2012-06-27 09:42:47 -05:00
Jiří Klimeš
4938996973 ifcfg-rh: fix unescaping single quotes in WPA passphrases (WPA_PSK) (rh #833616)
When the last character of the PSK was a backslash and the whole PSK was
enclosed in single quotes, the unquoting/unescaping code mistakenly took
trailing \' as an escaped quote and thus changed \ to '.

See also 79757f10f3 (that introduced the code).
2012-06-22 13:04:18 +02:00
Jiří Klimeš
78dda3b093 core: unblock signals for child processes we spawn out of NM (rh #739836)
Commit 217c5bf6ac fixed processing of unix
signals: signals are blocked in all threads and a dedicated thread handles the
signals using sigwait().
However, the commit forgot that child processes inherit signal mask as well.
That is why we have to unblock signals for child processes we spawn from NM, so
that they can receive signals.
2012-05-21 15:00:51 +02:00
Pantelis Koukousoulas
9039c24bf5 adsl: carrier handling and PPPoA support
This is the "juice" of the patch series. Initial cut at carrier handling
(by polling /sys/class/atm/$iface/carrier) and also support for calling
pppd with the proper command-line to achieve a connection.

Also implement the necessary boilerplate for the NM state machine to
be happy with our device.

This is a "duct tape and gum" implementation, i.e., prefer copy&paste
over proper refactoring, due to limited time, but the foundations are
now there, so we can make it work right slowly-slowly :)

With this patch, you can already test carrier management but not yet
make a complete connection.

Relevant extract from logs:
<info> (ueagle-atm0): carrier now ON (device state 20)
<info> (ueagle-atm0): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]

Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
2012-05-18 15:42:55 -05:00
Jiří Klimeš
57bb91f7f0 ifnet: handle 'biosdevname' interface names better (bgo #674765) (lp:962587)
Finding out interface type from interface name string is fragile. It is easily
broken, e.g. by biosdevname changing interface names to em<n> or p<n>*p<n>.
Sadly, Gentoo network configuration scripts are rather stupid, using format:
variable_${interface|mac|essid|apmac}.
http://www.gentoo.org/doc/en/handbook/2007.0/handbook-x86.xml?full=1#book_part4_chap2
The entries interface|mac|essid|apmac are basically indistinguishable. It's not
possible to say whether 'p1p1' is an interface or SSID, for example.

Fix the current behaviour a bit by checking whether the string is an interface.
If so, and it is not a Wi-Fi one, set the connection type as wired. Else it is
regarded as wireless.
2012-05-18 10:19:13 +02:00
Dan Williams
75257f5d7e core: move connection provider interface to src/ 2012-05-17 13:21:47 -05:00
Dan Williams
682cd73524 keyfile: be more helpful about the property that's invalid or missing 2012-05-15 09:19:31 -05:00
Dan Williams
9a3995daf6 settings: fix example plugin LDFLAGS
C&P error.
2012-05-14 15:51:31 -05:00
Dan Williams
a5df15d75a settings: add nm_connection_provider_get_connections() to connection provider interface
Will be used by some other stuff.
2012-05-14 10:46:32 -05:00
Dan Williams
5c0607d522 examples: add an example system settings plugin 2012-05-07 15:19:09 -05:00
Dan Williams
4fe48b1273 core: add connection provider interface
Allows better encapsulation of the functionality of the NMSettings
object that we want to expose to the device class.  They don't need
the whole object so to keep things simple and contained we'll just
give them a smaller interface to use.
2012-05-02 17:33:17 -05:00
Dan Winship
f378457f25 ifcfg-rh: fix vlan DEVICE parsing
A vlan DEVICE name must be either $(OTHERDEVICE).$(VLAN_ID) or
vlan$(VLAN_ID). Enforce that. In particular, don't:
(a) crash if the name has no "." and doesn't start with "vlan",
(b) loop forever if the $(VLAN_ID) part is non-numeric, or
(c) silently ignore non-numberic characters after the $(VLAN_ID).
2012-04-25 14:56:51 -04:00
Jiří Klimeš
21bc3ab517 ifnet: do not call g_strv_length() on NULL 2012-04-12 13:45:58 +02:00
Mu Qiao
5f4d238baa ifnet: fix quote handling for global data (bgo #673548) 2012-04-12 13:45:31 +02:00
Jiří Klimeš
fe3f010044 ifcfg-rh: clear MACADDR before writing it in wired setting (bgo #672646)
Else it's not possible to delete Cloned MAC (e.g. in the editor).
2012-04-03 14:57:31 +02:00
Jiří Klimeš
876f318ee8 ifupdown: add missing test18-wired-static-verify-ip6 to Makefile.am 2012-03-27 15:55:21 +02:00
Dan Williams
8126947e08 settings: quiet warning when checking for AdHoc WPA connections 2012-03-23 09:59:20 -05:00
Mathieu Trudel-Lapierre
1a531b7ecf keyfile: fix testcases after InfiniBand transport-mode default change 2012-03-19 10:10:36 -05:00
Dan Williams
69247a00ea wifi: disable Ad-Hoc WPA connections (lp:905748)
The kernel is broken for Ad-Hoc WPA, and creates the connections
as open connections instead.  Yeah, eventually we can use
wpa_supplicant with RSN support, but for now we just have to
disable Ad-Hoc WPA because it's a problem to say we're creating
a protected network but then have the kernel not do that for
us.  Will be re-enabled once all the necessary bits have been
fixed.

Note that Ad-Hoc WPA has been broken since at least 2.6.32 with
mac80211-based drivers, which is what most users will be using.
2012-03-16 17:58:23 -05:00